Просмотр исходного кода

将会员同步提醒提前到NewIndex

chendeben 1 год назад
Родитель
Сommit
410dc233c3
2 измененных файлов с 60 добавлено и 17 удалено
  1. 52 15
      entry/src/main/ets/pages/NewIndex.ets
  2. 8 2
      entry/src/main/ets/pages/UserCenter.ets

+ 52 - 15
entry/src/main/ets/pages/NewIndex.ets

@@ -28,6 +28,7 @@ import { resourceManager } from '@kit.LocalizationKit';
 import { systemShare } from '@kit.ShareKit';
 import { uniformTypeDescriptor } from '@kit.ArkData';
 import { hilog } from '@kit.PerformanceAnalysisKit';
+import { DialogHelper } from '@pura/harmony-dialog';
 
 
 const TAG = 'NewIndex'; // 日志标签
@@ -174,13 +175,39 @@ struct NewIndex{
     ScreenUtil.setScreenSize();
     this.bundleName =   AppUtil.getBundleName()
     this.versionName =  AppUtil.getVersionName();
-  // await ImageKnife.getInstance().initFileCache(this.context, 256, 256 * 1024 * 1024)
+    // await ImageKnife.getInstance().initFileCache(this.context, 256, 256 * 1024 * 1024)
     this.isShowSponsorship = Utility.isOpenTime()
     let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', CommonConstants.DEFAULT_THEME_COLOR);
     hilog.info(0x0000, 'Heanup', '当前 NewIndex themeColor:'+themeColor);
     AppStorage.setOrCreate('themeColor', themeColor);
     this.themeColor=themeColor
 
+    // ====== 本地会员同步提醒逻辑 ======
+    let isLogin = PreferencesUtil.getBooleanSync('isLogin', false);
+    console.log('Heanup isLogin:'+isLogin)
+    console.log('Heanup Utility.isNobleForOld():'+Utility.isNobleForOld())
+
+    if (!isLogin && Utility.isNobleForOld()) {
+      setTimeout(() => {
+        DialogHelper.showCustomContentDialog({
+          dialogId: 'syncNobleDialog',
+          title: '会员同步提示',
+          contentBuilder: () => {
+            this.syncNobleDialogContentBuilder();
+          },
+          buttons: [
+            { value: '暂不登录' },
+            {
+              value: '去登录',
+              action: () => {
+                router.pushUrl({ url: 'pages/UserCenter', params: { fromSyncNoble: true } });
+              }
+            }
+          ]
+        });
+      }, 500);
+    }
+    // ====== 本地会员同步提醒逻辑 END ======
   }
 
   /**
@@ -299,20 +326,20 @@ struct NewIndex{
           Button({ type: ButtonType.Capsule, stateEffect: true }) {
             Row() {
               // 菜单图标
-            if (typeof item.img === 'object' && item.img !== null && (item.img as sysResource).type === 'symbol') {
-              SymbolGlyph((item.img as sysResource).value as Resource)
-                // .size({ width: 22, height: 22 })
-                .fontSize(22)
-                .fontColor([this.themeColor])
-                .alignSelf(ItemAlign.Center)
-                .margin({ left: 2 })
-            }else {
-              Image(item.img as Resource)
-                .height(22)
-                .alignSelf(ItemAlign.Center)
-                .fillColor(this.themeColor)
-                .margin({ left: 2 })
-            }
+              if (typeof item.img === 'object' && item.img !== null && (item.img as sysResource).type === 'symbol') {
+                SymbolGlyph((item.img as sysResource).value as Resource)
+                  // .size({ width: 22, height: 22 })
+                  .fontSize(22)
+                  .fontColor([this.themeColor])
+                  .alignSelf(ItemAlign.Center)
+                  .margin({ left: 2 })
+              }else {
+                Image(item.img as Resource)
+                  .height(22)
+                  .alignSelf(ItemAlign.Center)
+                  .fillColor(this.themeColor)
+                  .margin({ left: 2 })
+              }
 
               // 菜单标题
               Text(item.title)
@@ -669,4 +696,14 @@ struct NewIndex{
   //   }
   // }
 
+  /*** 本地会员同步弹窗内容Builder */
+  @Builder
+  syncNobleDialogContentBuilder(): void {
+    Text('检测到您是本地会员,为保障权益请登录账号,会员权益将自动同步到您的账号。')
+      .fontSize(16)
+      .fontColor('#222')
+      .width('100%')
+      .textAlign(TextAlign.Center)
+      .padding(16)
+  }
 }

+ 8 - 2
entry/src/main/ets/pages/UserCenter.ets

@@ -263,8 +263,14 @@ export struct UserCenter {
       void this.fetchUserInfo();
     }
     console.log('Heanup isLogin:'+this.isLogin)
-    // 新增:未登录但本地是会员,弹窗提示登录同步会员
-    if (!this.isLogin && Utility.isNobleForOld()) {
+
+    // 只在非同步跳转时弹窗提醒
+    let params = router.getParams() as Record<string, Object>;
+    let fromSyncNoble = params && params['fromSyncNoble'] === true;
+    if (fromSyncNoble) {
+      // 自动弹出登录框
+      this.showLoginDialog();
+    } else if (!this.isLogin && Utility.isNobleForOld()) {
       DialogHelper.showCustomContentDialog({
         dialogId: 'syncNobleDialog',
         title: '会员同步提示',