浏览代码

[feat]亲密度分析,报告上传页,当非vip用户点击下一步时,增加一个生成过程和模糊的报告

hezihao 7 月之前
父节点
当前提交
82c998a759

+ 25 - 11
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_controller.dart

@@ -82,10 +82,11 @@ class IntimacyAnalyseUploadController extends BaseController {
   Rxn<MemberInfo> get userInfo => accountRepository.memberStatusInfo;
 
   /// 报告是否生成中
-  Rx<bool> isReportCreating = false.obs;
+  Rx<bool> isResultGenerating = false.obs;
 
   /// 当前键盘信息
-  Rxn<KeyboardInfo> get currentKeyboardInfo => keyboardRepository.chooseKeyboardInfo;
+  Rxn<KeyboardInfo> get currentKeyboardInfo =>
+      keyboardRepository.chooseKeyboardInfo;
 
   /// 当前选择的预测方向
   Rx<String> currentDirectionOption = "".obs;
@@ -295,13 +296,18 @@ class IntimacyAnalyseUploadController extends BaseController {
   }
 
   /// 点击了下一步按钮
-  void clickNextBtn() async {
-    // 非Vip,跳转到商店页
+  /// [isNeedForceVip] 是否强制需要VIP
+  void clickNextBtn(bool isNeedForceVip) async {
+    // 是否VIP
     bool isVip = accountRepository.memberStatusInfo.value?.isMember ?? false;
-    if (!isVip) {
-      ToastUtil.show(StringName.needVipTip);
-      StorePage.start();
-      return;
+
+    if (isNeedForceVip) {
+      // 非Vip,跳转到商店页
+      if (!isVip) {
+        ToastUtil.show(StringName.needVipTip);
+        StorePage.start();
+        return;
+      }
     }
 
     // 上传的图片后端地址
@@ -335,7 +341,15 @@ class IntimacyAnalyseUploadController extends BaseController {
 
     // 切换到报告生成中
     isUploadPage.value = false;
-    isReportCreating.value = true;
+    isResultGenerating.value = true;
+
+    // 非Vip,实现一个假的生成中,然后创建一个模糊的报告内容
+    if (!isVip) {
+      Future.delayed(Duration(milliseconds: 4000), () {
+        isResultGenerating.value = false;
+      });
+      return;
+    }
 
     try {
       // 分析亲密度
@@ -348,10 +362,10 @@ class IntimacyAnalyseUploadController extends BaseController {
 
       AtmobLog.d(tag, "分析亲密度 => ${response.toJson()}");
 
-      isReportCreating.value = false;
+      isResultGenerating.value = false;
       intimacyAnalyzeResult.value = response;
     } catch (error) {
-      isReportCreating.value = false;
+      isResultGenerating.value = false;
       AtmobLog.e(tag, error.toString());
       if (error is ServerErrorException) {
         // 需要Vip权限

+ 33 - 20
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_page.dart

@@ -282,7 +282,7 @@ class IntimacyAnalyseUploadPage
             // 分析结果
             intimacyAnalyzeResult: controller.intimacyAnalyzeResult.value,
             unlock: controller.userInfo.value?.isMember ?? false,
-            isReportCreating: controller.isReportCreating.value,
+            isReportCreating: controller.isResultGenerating.value,
           ),
         ],
       );
@@ -595,21 +595,29 @@ class IntimacyAnalyseUploadPage
         ),
       );
     } else {
-      // 结果页,显示立即分析按钮
-      if (controller.intimacyAnalyzeResult.value == null) {
-        return Container(
-          width: double.maxFinite,
-          margin: EdgeInsets.only(
-            left: 13.w,
-            top: 8.h,
-            right: 13.w,
-            bottom: 20.h,
-          ),
-          child: _buildAnalyseBtn(),
-        );
-      } else {
-        // 生成定制人设按钮
+      // 结果页
+      if (controller.isResultGenerating.value) {
+        // 生成中,不显示按钮
         return SizedBox();
+      } else {
+        // 生成完成,判断是否已解锁
+        bool isUnlock = controller.userInfo.value?.isMember ?? false;
+        if (!isUnlock) {
+          // 未解锁,显示立即分析按钮
+          return Container(
+            width: double.maxFinite,
+            margin: EdgeInsets.only(
+              left: 13.w,
+              top: 8.h,
+              right: 13.w,
+              bottom: 20.h,
+            ),
+            child: _buildAnalyseBtn(),
+          );
+        } else {
+          // 已解锁,生成定制人设按钮
+          return SizedBox();
+        }
       }
     }
   }
@@ -692,7 +700,7 @@ class IntimacyAnalyseUploadPage
           text: StringName.nextStep,
           color: ColorName.colorBrand,
           onPressed: () {
-            controller.clickNextBtn();
+            controller.clickNextBtn(false);
           },
         ),
       );
@@ -711,7 +719,9 @@ class IntimacyAnalyseUploadPage
           desc: StringName.intimacyAnalyseAnalysisUseAiTip,
           radius: 30.r,
           padding: EdgeInsets.symmetric(vertical: 7.h),
-          onPressed: () {},
+          onPressed: () {
+            controller.clickNextBtn(true);
+          },
         ),
       );
     });
@@ -719,6 +729,8 @@ class IntimacyAnalyseUploadPage
 
   /// 构建卡片列表
   Widget _buildCardList() {
+    // 是否已解锁
+    bool isUnlock = controller.userInfo.value?.isMember ?? false;
     return Obx(() {
       // 上传页
       if (controller.isUploadPage.value) {
@@ -728,6 +740,7 @@ class IntimacyAnalyseUploadPage
             _buildUploadStepCard(),
             // 预测方向卡片
             _buildPredictionDirectionStepCard(),
+            SizedBox(height: 90.h),
           ],
         );
       } else {
@@ -738,6 +751,8 @@ class IntimacyAnalyseUploadPage
             _buildAnalysisResultCard(),
             // 报告结果卡片
             _buildAnalysisReport(),
+            // 内容距离底部的距离
+            isUnlock ? SizedBox(height: 20.h) : SizedBox(height: 90.h),
           ],
         );
       }
@@ -750,9 +765,7 @@ class IntimacyAnalyseUploadPage
       child: Stack(
         children: [
           // 卡片列表
-          SingleChildScrollView(
-            child: Column(children: [_buildCardList(), SizedBox(height: 80.h)]),
-          ),
+          SingleChildScrollView(child: Column(children: [_buildCardList()])),
           // 底部操作按钮
           Positioned(
             left: 0,

+ 4 - 4
lib/module/intimacy_analyse/widget/intimacy_analyse_report_widget.dart

@@ -43,14 +43,14 @@ class IntimacyAnalyseReportWidget extends StatelessWidget {
     if (isPreview) {
       return PreviewReportCardWidget(previewReportContent: reportContent);
     }
-    // 未解锁
-    if (!unlock) {
-      return UnlockReportCardWidget();
-    }
     // 报告生成中
     if (isReportCreating) {
       return CreatingReportCardWidget();
     }
+    // 未解锁
+    if (!unlock) {
+      return UnlockReportCardWidget();
+    }
     // 已出报告
     return ExistReportCardWidget(
       reportContent: reportContent,