Commit 4706b45f7a83ac0fb1577be6c8a738e8eee24a00
Merge remote-tracking branch 'origin/feat-wqf-payment' into xiaoyu_cocossteve
Showing
9 changed files
with
45 additions
and
14 deletions
lib/common/core/app_consts.dart
| ... | ... | @@ -12,6 +12,6 @@ class AppConsts { |
| 12 | 12 | |
| 13 | 13 | /// 先声SDK |
| 14 | 14 | static String xsAppKey = 'a418'; |
| 15 | - static String xsAppSecretKey = BasicConfig().isTestDev?'1a16f31f2611bf32fb7b3fc38f5b2c81':'c11163aa6c834a028da4a4b30955be99'; | |
| 16 | - static String xsAppService = BasicConfig().isTestDev?'ws://trial.cloud.ssapi.cn:8080':'"wss://api.cloud.ssapi.cn'; | |
| 15 | + static String xsAppSecretKey = BasicConfig.isTestDev?'1a16f31f2611bf32fb7b3fc38f5b2c81':'c11163aa6c834a028da4a4b30955be99'; | |
| 16 | + static String xsAppService = BasicConfig.isTestDev?'ws://trial.cloud.ssapi.cn:8080':'"wss://api.cloud.ssapi.cn'; | |
| 17 | 17 | } | ... | ... |
lib/common/request/basic_config.dart
| 1 | +import 'package:flutter/cupertino.dart'; | |
| 2 | + | |
| 1 | 3 | class BasicConfig { |
| 2 | - bool isTestDev = true; | |
| 3 | - // bool isTestDev = false; | |
| 4 | + // static bool isTestDev = true; | |
| 5 | + static bool isTestDev = false; | |
| 6 | + | |
| 7 | + | |
| 8 | + // 暂时未启用 | |
| 9 | + static bool isEnvProd() { | |
| 10 | + bool kReleaseMode = const bool.fromEnvironment('dart.vm.product'); | |
| 11 | + if (kReleaseMode) { | |
| 12 | + debugPrint("dart.vm.product-现在是release环境."); | |
| 13 | + } else { | |
| 14 | + debugPrint("dart.vm.product-现在是debug环境."); | |
| 15 | + } | |
| 16 | + return kReleaseMode; | |
| 17 | + } | |
| 18 | + | |
| 4 | 19 | } | ... | ... |
lib/common/request/config.dart
| ... | ... | @@ -3,8 +3,8 @@ import 'package:wow_english/common/request/basic_config.dart'; |
| 3 | 3 | ///request config |
| 4 | 4 | class RequestConfig { |
| 5 | 5 | static String baseUrlDev = 'http://wow-app.dev.kouyuxingqiu.com/'; |
| 6 | - static String baseUrlProd = 'http://app-api.pro.kouyuxingqiu.com/'; | |
| 7 | - static String baseUrl = BasicConfig().isTestDev ? baseUrlDev : baseUrlProd; | |
| 6 | + static String baseUrlProd = 'https://app-api.wowenglish.com.cn/'; | |
| 7 | + static String baseUrl = BasicConfig.isTestDev ? baseUrlDev : baseUrlProd; | |
| 8 | 8 | |
| 9 | 9 | static const connectTimeout = Duration(seconds: 15); |
| 10 | 10 | static const successCode = 200; | ... | ... |
lib/models/user_entity.dart
| ... | ... | @@ -68,6 +68,22 @@ class UserEntity { |
| 68 | 68 | return valid ?? false; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | + // 计算用户vip到期日 | |
| 72 | + String? getEffectiveDate() { | |
| 73 | + if (effectiveDate == null) { | |
| 74 | + return null; | |
| 75 | + } | |
| 76 | + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(int.parse(effectiveDate!)); | |
| 77 | + // 获取年、月、日 | |
| 78 | + String year = dateTime.year.toString(); | |
| 79 | + String month = dateTime.month.toString().padLeft(2, '0'); // 如果月份是个位数,则在前面加上0,使其两位数 | |
| 80 | + String day = dateTime.day.toString().padLeft(2, '0'); // 如果日期是个位数,则在前面加上0,使其两位数 | |
| 81 | + | |
| 82 | + // 拼接成日期字符串 | |
| 83 | + String formattedDate = '$year-$month-$day'; | |
| 84 | + return formattedDate; | |
| 85 | + } | |
| 86 | + | |
| 71 | 87 | UserEntity copyWith({ |
| 72 | 88 | int? id, |
| 73 | 89 | String? name, | ... | ... |
lib/pages/home/bloc.dart
| ... | ... | @@ -9,8 +9,8 @@ import '../../utils/log_util.dart'; |
| 9 | 9 | import 'event.dart'; |
| 10 | 10 | import 'state.dart'; |
| 11 | 11 | |
| 12 | -class ModuleSelectBloc extends Bloc<HomeEvent, HomeState> { | |
| 13 | - ModuleSelectBloc() : super(HomeState().init()) { | |
| 12 | +class HomeBloc extends Bloc<HomeEvent, HomeState> { | |
| 13 | + HomeBloc() : super(HomeState().init()) { | |
| 14 | 14 | on<InitEvent>(_init); |
| 15 | 15 | } |
| 16 | 16 | ... | ... |
lib/pages/home/view.dart
| ... | ... | @@ -28,7 +28,7 @@ class HomePage extends StatelessWidget { |
| 28 | 28 | Widget build(BuildContext context) { |
| 29 | 29 | return BlocProvider( |
| 30 | 30 | create: (BuildContext context) => |
| 31 | - ModuleSelectBloc() | |
| 31 | + HomeBloc() | |
| 32 | 32 | ..add(InitEvent()), |
| 33 | 33 | child: Builder(builder: (context) => _HomePageView()), |
| 34 | 34 | ); |
| ... | ... | @@ -42,7 +42,7 @@ class _HomePageView extends StatelessWidget { |
| 42 | 42 | BlocListener<UserBloc, UserState>(listener: (context, state) { |
| 43 | 43 | debugPrint('WQF ModuleSelectPage BlocListener state: $state'); |
| 44 | 44 | }), |
| 45 | - BlocListener<ModuleSelectBloc, HomeState>( | |
| 45 | + BlocListener<HomeBloc, HomeState>( | |
| 46 | 46 | listener: (context, state) { |
| 47 | 47 | Log.d("WQF HomePage listener state: $state"); |
| 48 | 48 | if (state is UpdateDialogState) { |
| ... | ... | @@ -54,7 +54,7 @@ class _HomePageView extends StatelessWidget { |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | Widget _homeView() => |
| 57 | - BlocBuilder<ModuleSelectBloc, HomeState>( | |
| 57 | + BlocBuilder<HomeBloc, HomeState>( | |
| 58 | 58 | builder: (context, state) { |
| 59 | 59 | return Scaffold( |
| 60 | 60 | body: Container( | ... | ... |
lib/pages/home/widgets/BaseHomeHeaderWidget.dart
| ... | ... | @@ -79,7 +79,7 @@ class BaseHomeHeaderWidget extends StatelessWidget { |
| 79 | 79 | style: TextStyle(color: Colors.white, fontSize: 30.0), |
| 80 | 80 | )), |
| 81 | 81 | Offstage( |
| 82 | - offstage: AppConfigHelper.shouldHidePay(), | |
| 82 | + offstage: AppConfigHelper.shouldHidePay() || !UserUtil.isLogined(), | |
| 83 | 83 | child: Row(children: <Widget>[ |
| 84 | 84 | Image( |
| 85 | 85 | width: 20.0.w, | ... | ... |
lib/pages/user/user_page.dart
lib/utils/log_util.dart
| ... | ... | @@ -3,7 +3,7 @@ import 'package:wow_english/common/request/basic_config.dart'; |
| 3 | 3 | enum LogLevel { debug, info, warning, error } |
| 4 | 4 | |
| 5 | 5 | class Log { |
| 6 | - static LogLevel level = BasicConfig().isTestDev ? LogLevel.debug : LogLevel.error; | |
| 6 | + static LogLevel level = BasicConfig.isTestDev ? LogLevel.debug : LogLevel.error; | |
| 7 | 7 | |
| 8 | 8 | /// debug |
| 9 | 9 | static void d(Object? object) { | ... | ... |