Bläddra i källkod

[fit]修复bug,允许登录dialog返回,添加人设生成中的加载弹窗,去掉下拉刷新显示英文时间,商店默认微信支付

云天逵 7 månader sedan
förälder
incheckning
bb766a6074

+ 1 - 0
assets/string/base/string.xml

@@ -34,6 +34,7 @@
 
     <string name="network_error">网络异常</string>
     <string name="need_vip_tip">请开通会员解锁权益~</string>
+    <string name="sensitive_content">涉及敏感内容</string>
 
     <string name="account_no_login">账号未登录</string>
     <string name="login_account">登录账号</string>

+ 4 - 1
lib/data/consts/error_code.dart

@@ -5,8 +5,9 @@ class ErrorCode {
   static const int verificationCodeError = 1005; //验证码错误
   static const int noLoginError = 1006; //未登录
   static const int noMember = 1007; //没有会员
+  static const int sensitive = 1023; //敏感内容
 
-/// 会员服务相关错误码
+  /// 会员服务相关错误码
 
   static const int isMember = 1301; //您已经是会员了
   static const int payOrderError = 1004;
@@ -20,6 +21,8 @@ extension ErrorDescription on int {
         return StringName.loginVerificationCodeRequestFailedToast;
       case ErrorCode.noLoginError:
         return StringName.accountNoLogin;
+      case ErrorCode.sensitive:
+        return StringName.sensitiveContent;
       default:
         return 'UNKNOWN_ERROR';
     }

+ 1 - 0
lib/data/repository/keyboard_repository.dart

@@ -62,6 +62,7 @@ class KeyboardRepository {
   }
 
   Future refreshData() async {
+    _homeLoveIndex.value = null;
     await Future.delayed(const Duration(milliseconds: 500));
     // 延迟为了保证首页数据能够正常获取,不然保存的时候,获取太快了,导致还是拉到旧的数值
     refreshKeyboardList();

+ 6 - 3
lib/di/get_it.config.dart

@@ -231,6 +231,12 @@ extension GetItInjectableX on _i174.GetIt {
         gh<_i243.AtmobApi>(),
       ),
     );
+    gh.factory<_i161.KeyBoardController>(
+      () => _i161.KeyBoardController(
+        gh<_i274.KeyboardRepository>(),
+        gh<_i83.AccountRepository>(),
+      ),
+    );
     gh.factory<_i922.KeyboardManageController>(
       () => _i922.KeyboardManageController(
         gh<_i274.KeyboardRepository>(),
@@ -269,9 +275,6 @@ extension GetItInjectableX on _i174.GetIt {
     gh.factory<_i566.IntimacyScaleController>(
       () => _i566.IntimacyScaleController(gh<_i274.KeyboardRepository>()),
     );
-    gh.factory<_i161.KeyBoardController>(
-      () => _i161.KeyBoardController(gh<_i274.KeyboardRepository>()),
-    );
     gh.factory<_i701.NewUserController>(
       () => _i701.NewUserController(
         gh<_i83.AccountRepository>(),

+ 1 - 0
lib/dialog/content/character_tab_group_content_view.dart

@@ -54,6 +54,7 @@ class CharacterTabGroupContentView
               controller: controller.refreshController,
               header: const ClassicHeader(),
               footer: ClassicFooter(
+                showMessage: false,
                 noMoreText: StringName.noMoreData,
                 failedText: StringName.loadFailed,
                 processedText: StringName.loadCompleted,

+ 1 - 0
lib/dialog/custom_character/custom_character_add_view.dart

@@ -45,6 +45,7 @@ class CustomCharacterAddView extends BaseView<CustomCharacterAddController> {
               controller: controller.refreshController,
               header: const ClassicHeader(),
               footer: ClassicFooter(
+                showMessage: false,
                 noMoreText: StringName.noMoreData,
                 failedText: StringName.loadFailed,
                 processedText: StringName.loadCompleted,

+ 2 - 2
lib/dialog/custom_label_dialog.dart

@@ -76,8 +76,8 @@ class CustomLabelDialog {
                             child: TextField(
                               controller: textController,
                               // maxLength: maxLength,
-                              maxLines: null,
-                              expands: true,
+                              maxLines: 1,
+
                               textAlign: TextAlign.center,
                               textAlignVertical: TextAlignVertical.center,
                               decoration: InputDecoration(

+ 1 - 1
lib/dialog/keyboard_generating_dialog.dart

@@ -12,7 +12,7 @@ class KeyboardGeneratingDialog {
     SmartDialog.show(
       tag: tag,
       backType: SmartBackType.block,
-      clickMaskDismiss: true,
+      clickMaskDismiss: false,
       alignment: Alignment.center,
       animationType: SmartAnimationType.centerScale_otherSlide,
       builder: (_) {

+ 1 - 1
lib/dialog/login/login_dialog.dart

@@ -10,7 +10,7 @@ class LoginDialog {
 
   static void show() {
     SmartDialog.show(
-      backType: SmartBackType.block,
+      backType: SmartBackType.normal,
       clickMaskDismiss: true,
       alignment: Alignment.bottomCenter,
       animationType: SmartAnimationType.centerScale_otherSlide,

+ 1 - 0
lib/module/character/content/character_group_content_view.dart

@@ -29,6 +29,7 @@ class CharacterGroupContentView
               controller: controller.refreshController,
               header: const ClassicHeader(),
               footer: ClassicFooter(
+                showMessage: false,
                 noMoreText: StringName.noMoreData,
                 failedText: StringName.loadFailed,
                 processedText: StringName.loadCompleted,

+ 9 - 0
lib/module/character_custom/character_custom_controller.dart

@@ -218,4 +218,13 @@ class CharacterCustomController extends BaseController {
       ToastUtil.show(errorMessage);
     }
   }
+
+  ///清空数据
+  void clearData() {
+    AtmobLog.d(tag, "clearData");
+    currentStep.value = StepType.home;
+    hobbiesSelectLabels.clear();
+    characterSelectLabels.clear();
+    currentNameValue.value = "";
+  }
 }

+ 2 - 2
lib/module/character_custom/character_custom_page.dart

@@ -529,8 +529,8 @@ class CharacterCustomPage extends BasePage<CharacterCustomController> {
               ),
               child: TextField(
                 // maxLength: maxLength,
-                maxLines: null,
-                expands: true,
+                maxLines: 1,
+                // expands: true,
                 textAlign: TextAlign.center,
                 textAlignVertical: TextAlignVertical.center,
                 onChanged: (value) {

+ 20 - 0
lib/module/character_custom/detail/character_custom_detail_controller.dart

@@ -5,10 +5,15 @@ import 'package:keyboard/data/bean/custom_config_info.dart';
 import 'package:keyboard/data/repository/characters_repository.dart';
 import 'package:get/get.dart';
 import 'package:keyboard/data/repository/config_repository.dart';
+import 'package:keyboard/module/character_custom/character_custom_controller.dart';
 import 'package:keyboard/module/store/store_page.dart';
+import 'package:keyboard/resource/string.gen.dart';
 import 'package:keyboard/utils/atmob_log.dart';
 
+import '../../../di/get_it.dart';
+import '../../../dialog/keyboard_generating_dialog.dart';
 import '../../../resource/assets.gen.dart';
+import '../../../router/app_pages.dart';
 import '../../../utils/age_zodiac_sign_util.dart';
 import '../../../utils/error_handler.dart';
 import '../../../utils/http_handler.dart';
@@ -228,6 +233,13 @@ class CharacterCustomDetailController extends BaseController {
     if (result != null) {
       _currentGender.value = result;
     }
+    if (result == 1 && _boyAvatars.isNotEmpty) {
+      _avatarUrl.value = _boyAvatars.first;
+    } else if (_girlAvatars.isNotEmpty) {
+      _avatarUrl.value = _girlAvatars.first;
+    } else {
+      _avatarUrl.value = "";
+    }
   }
 
   String get genderText {
@@ -280,6 +292,7 @@ class CharacterCustomDetailController extends BaseController {
   // 生成定制人设
   Future<void> generateCharacterCustom() async {
     try {
+      KeyboardGeneratingDialog.show();
       await charactersRepository.generateCharacterCustom(
         name: _currentNickname.value,
         gender: _currentGender.value,
@@ -296,6 +309,11 @@ class CharacterCustomDetailController extends BaseController {
         birthday: _currentBirthday.value,
         imageUrl: _avatarUrl.value,
       );
+      KeyboardGeneratingDialog.hide();
+      Get.back();
+      final characterCustomController = Get.find<CharacterCustomController>();
+      characterCustomController.clearData();
+
       ToastUtil.show("生成成功");
     } catch (error) {
       if (error is ServerErrorException && error.code == 1005) {
@@ -305,6 +323,8 @@ class CharacterCustomDetailController extends BaseController {
       if (error is ServerErrorException) {
         ToastUtil.show(error.message);
       }
+      KeyboardGeneratingDialog.hide();
+
     }
   }
 

+ 2 - 1
lib/module/character_custom/list/character_custom_list_page.dart

@@ -56,6 +56,7 @@ class CharacterCustomListPage extends BasePage<CharacterCustomListController> {
                           controller: controller.refreshController,
                           header: const ClassicHeader(),
                           footer: ClassicFooter(
+                            showMessage: false,
                             noMoreText: StringName.noMoreData,
                             failedText: StringName.loadFailed,
                             processedText: StringName.loadCompleted,
@@ -115,7 +116,7 @@ class CharacterCustomListPage extends BasePage<CharacterCustomListController> {
             StringName.characterCustomHistory,
             style: Styles.getTextStyleBlack204W500(17.sp),
           ),
-          SizedBox(),
+          SizedBox(width: 24.w,height: 24.w,),
         ],
       ),
     );

+ 9 - 5
lib/module/intimacy_scale/intimacy_scale_controller.dart

@@ -4,6 +4,7 @@ import 'package:get/get.dart';
 import 'package:keyboard/data/repository/keyboard_repository.dart';
 import 'package:keyboard/utils/toast_util.dart';
 import '../../data/bean/keyboard_info.dart';
+import '../../data/consts/error_code.dart';
 import '../../utils/error_handler.dart';
 import '../../utils/http_handler.dart';
 import '../../widget/flutter_ruler_picker.dart';
@@ -71,14 +72,17 @@ class IntimacyScaleController extends BaseController {
         keyboardId: currentKeyboardInfo.value!.id!,
         intimacy: currentCustomIntimacy.value,
       );
-      await keyboardRepository.getKeyboardHomeInfo();
+      await keyboardRepository.refreshData();
       Get.back();
     } catch (error) {
-      if (error is ServerErrorException && error.code == 1005) {
-        ToastUtil.show('请开通会员解锁权益~');
-        StorePage.start();
+      if (error is ServerErrorException) {
+        if (error.code == ErrorCode.noLoginError) {
+          ErrorHandler.toastError(error);
+        } else {
+          ErrorHandler.toastError(error);
+        }
       } else {
-        ToastUtil.show(error.toString());
+        ErrorHandler.toastError(error);
       }
     }
   }

+ 37 - 31
lib/module/intro/intro_controller.dart

@@ -1,30 +1,28 @@
 import 'dart:async';
-
-import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
-import 'package:flutter_screenutil/flutter_screenutil.dart';
-import 'package:injectable/injectable.dart';
-import 'package:keyboard/base/base_controller.dart';
 import 'package:get/get.dart';
-import 'package:keyboard/dialog/login/login_dialog.dart';
-import 'package:keyboard/module/new_user/new_user_page.dart';
+import 'package:keyboard/base/base_controller.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
 import '../../data/consts/constants.dart';
 import '../../resource/assets.gen.dart';
+import '../../dialog/login/login_dialog.dart';
+import '../../module/new_user/new_user_page.dart';
+import 'package:injectable/injectable.dart';
 
 @injectable
 class IntroController extends BaseController {
   final tag = "IntroController";
-  Rx<PageController> pageController = PageController().obs;
 
+  Rx<PageController> pageController = PageController().obs;
   var currentPage = 0.obs;
-
   Timer? _autoPageTimer;
 
   IntroController();
 
+  /// 页面数据列表
   final List<PageBean> pageList = [
     PageBean(
-      Text.rich(
+      title: Text.rich(
         textAlign: TextAlign.center,
         TextSpan(
           children: [
@@ -55,9 +53,14 @@ class IntroController extends BaseController {
           ],
         ),
       ),
-      Assets.anim.animIntroFirstData,
+      animUrl: Assets.anim.animIntroFirstData,
+      stayDuration: const Duration(milliseconds:4100),
+    ),
+    PageBean(
+      title: const SizedBox(),
+      animUrl: Assets.anim.animIntroSecondData,
+      stayDuration:const Duration(milliseconds: 5500)
     ),
-    PageBean(SizedBox(), Assets.anim.animIntroSecondData),
   ];
 
   @override
@@ -65,39 +68,39 @@ class IntroController extends BaseController {
     super.onInit();
     setFirstIntro(false);
   }
+
   @override
   void onReady() {
     super.onReady();
-    _resetTimer();
+    _startAutoSwitchTimer();
   }
-  void _resetTimer() {
+
+  /// 开始自动切页计时
+  void _startAutoSwitchTimer() {
     _autoPageTimer?.cancel();
-    _autoPageTimer = Timer.periodic(const Duration(seconds: 3), (timer) {
-      swiperIntro();
-    });
+    final duration = pageList[currentPage.value].stayDuration;
+    _autoPageTimer = Timer(duration, swiperIntro);
   }
 
-
+  /// 执行切页
   void swiperIntro() {
     if (currentPage.value == pageList.length - 1) {
       pageController.value.jumpToPage(0);
-
+      currentPage.value = 0;
     } else {
-      // 跳转到下一页
-
       pageController.value.nextPage(
         duration: const Duration(milliseconds: 500),
         curve: Curves.easeInOut,
       );
       currentPage.value++;
     }
+    _startAutoSwitchTimer(); // 切完后,重新根据新页面设定计时
   }
 
-
+  /// 页面切换时回调
   void onPageChanged(int index) {
-
     currentPage.value = index;
-    _resetTimer();
+    _startAutoSwitchTimer();
   }
 
   void clickLogin() {
@@ -114,16 +117,19 @@ class IntroController extends BaseController {
 
   @override
   void onClose() {
-    super.onClose();
     _autoPageTimer?.cancel();
+    super.onClose();
   }
-
-
 }
 
 class PageBean {
-  Widget title;
-  String animUrl;
-
-  PageBean(this.title, this.animUrl);
+  final Widget title;
+  final String animUrl;
+  final Duration stayDuration; // 每页停留时间
+
+  PageBean({
+    required this.title,
+    required this.animUrl,
+    required this.stayDuration,
+  });
 }

+ 38 - 4
lib/module/keyboard/keyboard_controller.dart

@@ -5,16 +5,16 @@ import 'package:get/get.dart';
 import 'package:injectable/injectable.dart';
 import 'package:keyboard/base/base_controller.dart';
 import 'package:keyboard/data/api/response/keyboard_home_info_response.dart';
+import 'package:keyboard/data/repository/account_repository.dart';
 import 'package:keyboard/data/repository/keyboard_repository.dart';
 import 'package:keyboard/module/intimacy_analyse/enums/intimacy_analyse_tab.dart';
 import 'package:keyboard/module/keyboard_manage/keyboard_manage_page.dart';
 import 'package:keyboard/module/store/new_discount/new_discount_page.dart';
 import 'package:keyboard/module/store/store_page.dart';
-import 'package:keyboard/module/user_info/user_info_page.dart';
 import 'package:keyboard/module/user_profile/user_profile_page.dart';
 
 import '../../data/api/response/keyboard_love_index_response.dart';
-import '../../utils/atmob_log.dart';
+import '../../data/bean/member_info.dart';
 import '../../utils/keyboard_tutorial_util.dart';
 import '../intimacy_analyse/intimacy_analyse_page.dart';
 import '../intimacy_scale/intimacy_scale_page.dart';
@@ -27,8 +27,14 @@ class KeyBoardController extends BaseController {
 
   final KeyboardRepository keyboardRepository;
 
+  final AccountRepository accountRepository;
+
   KeyboardHomeInfoResponse? get homeInfo => keyboardRepository.homeInfo.value;
 
+  MemberInfo? get memberInfo => accountRepository.memberStatusInfo.value;
+
+  bool get isLogin => accountRepository.isLogin.value;
+
   Rxn<KeyboardLoveIndexResponse> get loveIndex =>
       keyboardRepository.homeLoveIndex;
   static const int countdownTime = 10 * 60 * 100;
@@ -39,13 +45,41 @@ class KeyBoardController extends BaseController {
 
   // 各项指标数据
 
-  KeyBoardController(this.keyboardRepository);
+  KeyBoardController(this.keyboardRepository, this.accountRepository);
 
   @override
   void onInit() {
     super.onInit();
 
-    startCountdown();
+    // 初始判断一次
+    _updateBannerState();
+
+    // 实时监听登录状态变化
+    ever(accountRepository.isLogin, (_) {
+      _updateBannerState();
+    });
+
+    // 实时监听会员信息变化
+    ever(accountRepository.memberStatusInfo, (_) {
+      _updateBannerState();
+    });
+  }
+
+  /// 根据当前登录状态 & 会员信息更新 banner显示逻辑
+  void _updateBannerState() {
+    if (isLogin && (memberInfo?.isMember == true)) {
+
+      isShowBanner.value = false;
+      _timer?.cancel(); // 停止倒计时
+    } else {
+
+      if (isShowBanner.value == false) {
+        isShowBanner.value = true;
+      }
+      if (_timer == null || !_timer!.isActive) {
+        startCountdown();
+      }
+    }
   }
 
   void clickVip() {

+ 3 - 0
lib/module/login/login_page.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
 import 'package:flutter/src/widgets/framework.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:keyboard/base/base_page.dart';
@@ -79,6 +80,7 @@ class LoginPage extends BasePage<LoginController> {
               maxLines: 1,
               maxLength: 11,
               keyboardType: TextInputType.phone,
+              inputFormatters: [FilteringTextInputFormatter.digitsOnly],
               textAlignVertical: TextAlignVertical.center,
               textInputAction: TextInputAction.next,
               decoration: InputDecoration(
@@ -127,6 +129,7 @@ class LoginPage extends BasePage<LoginController> {
               maxLines: 1,
               maxLength: 4,
               keyboardType: TextInputType.phone,
+              inputFormatters: [FilteringTextInputFormatter.digitsOnly],
               textAlignVertical: TextAlignVertical.center,
               textInputAction: TextInputAction.next,
               decoration: InputDecoration(

+ 18 - 8
lib/module/profile/edit/profile_edit_controller.dart

@@ -182,6 +182,11 @@ class ProfileEditController extends BaseController {
     if (result != null) {
       _currentGender.value = result;
     }
+    if (result == 1 && _boyAvatars.isNotEmpty) {
+      _avatarUrl.value = _boyAvatars.first;
+    } else if (_girlAvatars.isNotEmpty) {
+      _avatarUrl.value = _girlAvatars.first;
+    }
   }
 
   void clickBirthday() async {
@@ -199,12 +204,14 @@ class ProfileEditController extends BaseController {
     AtmobLog.d(tag, "clickRelationship");
   }
 
-  void clickGoKeyboardManage() async{
-   var result  = await KeyboardManagePage.start(customKeyboardInfo: _currentCustomKeyboardInfo.value);
-   if (result != null && result is List<CharacterInfo>) {
-     AtmobLog.d(tag, 'clickGoKeyboardManage result: $result');
-     _currentCustomKeyboardCharacterList.assignAll(result);
-   }
+  void clickGoKeyboardManage() async {
+    var result = await KeyboardManagePage.start(
+      customKeyboardInfo: _currentCustomKeyboardInfo.value,
+    );
+    if (result != null && result is List<CharacterInfo>) {
+      AtmobLog.d(tag, 'clickGoKeyboardManage result: $result');
+      _currentCustomKeyboardCharacterList.assignAll(result);
+    }
   }
 
   String get genderText {
@@ -212,9 +219,12 @@ class ProfileEditController extends BaseController {
     if (_currentGender.value == 2) return '女';
     return '请选择';
   }
+
   AssetGenImage? get genderImage {
-    if (_currentGender.value == 1) return Assets.images.iconCharacterCustomDetailMale;
-    if (_currentGender.value == 2) return Assets.images.iconCharacterCustomDetailFemale;
+    if (_currentGender.value == 1)
+      return Assets.images.iconCharacterCustomDetailMale;
+    if (_currentGender.value == 2)
+      return Assets.images.iconCharacterCustomDetailFemale;
     return null;
   }
 

+ 0 - 31
lib/module/store/new_discount/new_discount_controller.dart

@@ -156,41 +156,10 @@ class NewDiscountController extends BaseController
   }
 
   void refreshStoreData() {
-    // _storeDataFuture?.cancel();
-    // _storeDataFuture = AsyncUtil.retryWithExponentialBackoff(
-    //   () => _requestGoodsInfoList(),
-    //   4,
-    // );
-    // _storeDataFuture?.catchError((error) {
-    //   ErrorHandler.toastError(error);
-    // });
 
     storeRepository.refreshNewDiscountGoodsInfoList();
   }
 
-  Future<void> _requestGoodsInfoList() async {
-    try {
-      final response = await storeRepository.getMemberNewUserGoodsList();
-      goodsInfoList.clear();
-      payWayList.clear();
-      _charactersList.clear();
-      _selectedGoodsInfoItem.value = null;
-      if (response.goodsInfoList?.isNotEmpty == true) {
-        goodsInfoList.addAll(response.goodsInfoList!);
-        _selectedGoodsInfoItem.value = goodsInfoList.first;
-      }
-      if (response.payInfoList?.isNotEmpty == true) {
-        payWayList.addAll(response.payInfoList!);
-        _selectedPayWay.value = payWayList.first;
-        updateFilteredGoodsList();
-      }
-      if (response.characterInfos?.isNotEmpty == true) {
-        _charactersList.addAll(response.characterInfos!);
-      }
-    } catch (e) {
-      AtmobLog.e(tag, e.toString());
-    }
-  }
 
   void updateFilteredGoodsList() {
     if (_selectedPayWay.value == null) {

+ 4 - 1
lib/module/store/store_controller.dart

@@ -157,7 +157,7 @@ class StoreController extends BaseController implements PaymentStatusCallback {
       }
       if (response.payInfoList?.isNotEmpty == true) {
         payWayList.addAll(response.payInfoList!);
-        _selectedPayWay.value = payWayList.first;
+        _selectedPayWay.value = payWayList.last;
         updateFilteredGoodsList();
       }
     } catch (e) {
@@ -177,6 +177,9 @@ class StoreController extends BaseController implements PaymentStatusCallback {
             goods.payOptionIds!.contains(selectedPayWayId);
       }).toList(),
     );
+    if (filteredGoodsList.isNotEmpty) {
+      _selectedGoodsInfoItem.value = filteredGoodsList.first;
+    }
   }
 
   void onGoodsItemClick(GoodsInfo goodsInfo) {

+ 2 - 0
lib/resource/string.gen.dart

@@ -27,6 +27,7 @@ class StringName {
   static final String vipLevel2Btn = 'vip_level2_btn'.tr; // 立即查看
   static final String networkError = 'network_error'.tr; // 网络异常
   static final String needVipTip = 'need_vip_tip'.tr; // 请开通会员解锁权益~
+  static final String sensitiveContent = 'sensitive_content'.tr; // 涉及敏感内容
   static final String accountNoLogin = 'account_no_login'.tr; // 账号未登录
   static final String loginAccount = 'login_account'.tr; // 登录账号
   static final String loginAgreePrivacy = 'login_agree_privacy'.tr; // 请先阅读并同意《隐私权政策》和《服务条款》
@@ -358,6 +359,7 @@ class StringMultiSource {
       'vip_level2_btn': '立即查看',
       'network_error': '网络异常',
       'need_vip_tip': '请开通会员解锁权益~',
+      'sensitive_content': '涉及敏感内容',
       'account_no_login': '账号未登录',
       'login_account': '登录账号',
       'login_agree_privacy': '请先阅读并同意《隐私权政策》和《服务条款》',