Commit 4706b45f7a83ac0fb1577be6c8a738e8eee24a00

Authored by xiaoyu
2 parents 9ebefc69 f74aeedc

Merge remote-tracking branch 'origin/feat-wqf-payment' into xiaoyu_cocossteve

lib/common/core/app_consts.dart
@@ -12,6 +12,6 @@ class AppConsts { @@ -12,6 +12,6 @@ class AppConsts {
12 12
13 /// 先声SDK 13 /// 先声SDK
14 static String xsAppKey = 'a418'; 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 class BasicConfig { 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,8 +3,8 @@ import 'package:wow_english/common/request/basic_config.dart';
3 ///request config 3 ///request config
4 class RequestConfig { 4 class RequestConfig {
5 static String baseUrlDev = 'http://wow-app.dev.kouyuxingqiu.com/'; 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 static const connectTimeout = Duration(seconds: 15); 9 static const connectTimeout = Duration(seconds: 15);
10 static const successCode = 200; 10 static const successCode = 200;
lib/models/user_entity.dart
@@ -68,6 +68,22 @@ class UserEntity { @@ -68,6 +68,22 @@ class UserEntity {
68 return valid ?? false; 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 UserEntity copyWith({ 87 UserEntity copyWith({
72 int? id, 88 int? id,
73 String? name, 89 String? name,
lib/pages/home/bloc.dart
@@ -9,8 +9,8 @@ import '../../utils/log_util.dart'; @@ -9,8 +9,8 @@ import '../../utils/log_util.dart';
9 import 'event.dart'; 9 import 'event.dart';
10 import 'state.dart'; 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 on<InitEvent>(_init); 14 on<InitEvent>(_init);
15 } 15 }
16 16
lib/pages/home/view.dart
@@ -28,7 +28,7 @@ class HomePage extends StatelessWidget { @@ -28,7 +28,7 @@ class HomePage extends StatelessWidget {
28 Widget build(BuildContext context) { 28 Widget build(BuildContext context) {
29 return BlocProvider( 29 return BlocProvider(
30 create: (BuildContext context) => 30 create: (BuildContext context) =>
31 - ModuleSelectBloc() 31 + HomeBloc()
32 ..add(InitEvent()), 32 ..add(InitEvent()),
33 child: Builder(builder: (context) => _HomePageView()), 33 child: Builder(builder: (context) => _HomePageView()),
34 ); 34 );
@@ -42,7 +42,7 @@ class _HomePageView extends StatelessWidget { @@ -42,7 +42,7 @@ class _HomePageView extends StatelessWidget {
42 BlocListener<UserBloc, UserState>(listener: (context, state) { 42 BlocListener<UserBloc, UserState>(listener: (context, state) {
43 debugPrint('WQF ModuleSelectPage BlocListener state: $state'); 43 debugPrint('WQF ModuleSelectPage BlocListener state: $state');
44 }), 44 }),
45 - BlocListener<ModuleSelectBloc, HomeState>( 45 + BlocListener<HomeBloc, HomeState>(
46 listener: (context, state) { 46 listener: (context, state) {
47 Log.d("WQF HomePage listener state: $state"); 47 Log.d("WQF HomePage listener state: $state");
48 if (state is UpdateDialogState) { 48 if (state is UpdateDialogState) {
@@ -54,7 +54,7 @@ class _HomePageView extends StatelessWidget { @@ -54,7 +54,7 @@ class _HomePageView extends StatelessWidget {
54 } 54 }
55 55
56 Widget _homeView() => 56 Widget _homeView() =>
57 - BlocBuilder<ModuleSelectBloc, HomeState>( 57 + BlocBuilder<HomeBloc, HomeState>(
58 builder: (context, state) { 58 builder: (context, state) {
59 return Scaffold( 59 return Scaffold(
60 body: Container( 60 body: Container(
lib/pages/home/widgets/BaseHomeHeaderWidget.dart
@@ -79,7 +79,7 @@ class BaseHomeHeaderWidget extends StatelessWidget { @@ -79,7 +79,7 @@ class BaseHomeHeaderWidget extends StatelessWidget {
79 style: TextStyle(color: Colors.white, fontSize: 30.0), 79 style: TextStyle(color: Colors.white, fontSize: 30.0),
80 )), 80 )),
81 Offstage( 81 Offstage(
82 - offstage: AppConfigHelper.shouldHidePay(), 82 + offstage: AppConfigHelper.shouldHidePay() || !UserUtil.isLogined(),
83 child: Row(children: <Widget>[ 83 child: Row(children: <Widget>[
84 Image( 84 Image(
85 width: 20.0.w, 85 width: 20.0.w,
lib/pages/user/user_page.dart
@@ -120,7 +120,7 @@ class _UserView extends StatelessWidget { @@ -120,7 +120,7 @@ class _UserView extends StatelessWidget {
120 child: Row( 120 child: Row(
121 children: [ 121 children: [
122 Text( 122 Text(
123 - "${user.effectiveDate} 到期", 123 + "${user.getEffectiveDate()} 到期",
124 style: TextStyle( 124 style: TextStyle(
125 color: const Color(0xFFE11212), 125 color: const Color(0xFFE11212),
126 fontSize: 17.sp, 126 fontSize: 17.sp,
lib/utils/log_util.dart
@@ -3,7 +3,7 @@ import &#39;package:wow_english/common/request/basic_config.dart&#39;; @@ -3,7 +3,7 @@ import &#39;package:wow_english/common/request/basic_config.dart&#39;;
3 enum LogLevel { debug, info, warning, error } 3 enum LogLevel { debug, info, warning, error }
4 4
5 class Log { 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 /// debug 8 /// debug
9 static void d(Object? object) { 9 static void d(Object? object) {