Ver Fonte

修改会员判断

chendeben há 1 ano atrás
pai
commit
68ee3ef04d

+ 27 - 3
entry/src/main/ets/common/util/Utility.ets

@@ -47,12 +47,36 @@ export class Utility {
     return PreferencesUtil.getBooleanSync('hasActiveSubscription', false);
   }
 
+  /**
+   * 旧版客户端判断会员状态
+   * @returns
+   */
+  static isNobleForOld():boolean{
+    if(!Utility.isOpenTime())//提交审核的审核,刚刚开始可以全部是赞助用户。
+      return true
+    return PreferencesUtil.getBooleanSync('isNoble',false)
+  }
+
   /**
    * setNoble方法废弃,保留兼容但不做任何操作
    */
-  static setNoble(expireDate: string) {
-    // 线上会员体系下不再需要本地设置会员标志
-    // 兼容老代码,什么都不做
+  static setNoble(expireDate:string){
+    let isNoble = false
+    if(StrUtil.isNotEmpty(expireDate)){
+      if(expireDate===VipPage.FOREVER_DATE){
+        isNoble = true
+      }else{
+        const currentDate = new Date();
+        const targetDate = DateUtil.getFormatDate(expireDate)
+
+        if (currentDate > targetDate) {
+          isNoble = false
+        }else{
+          isNoble = true
+        }
+      }
+    }
+    PreferencesUtil.putSync('isNoble',isNoble)
   }
 
   /**

+ 4 - 3
entry/src/main/ets/pages/UserCenter.ets

@@ -192,7 +192,7 @@ export struct UserCenter {
     await UserUtil.getUserInfoByCode(code).then(async ()=>{
       // 登录后同步本地会员到线上(仅本地有会员且线上无会员时)
       Utility.getLocalNobleExpireDate().then((expireDate)=>{
-        if (Utility.isNoble() && !this.hasActiveSubscription && expireDate) {
+        if (Utility.isNobleForOld() && !this.hasActiveSubscription && expireDate) {
           UserUtil.syncLocalNobleToServer(expireDate).then((success)=>{
             if (success) {
               ToastUtil.showToast('本地会员已同步到账号');
@@ -214,7 +214,7 @@ export struct UserCenter {
     await UserUtil.getUserInfoByHuawei(openID, unionID, nickname, avatarUri).then(async (data)=>{
       // 登录后同步本地会员到线上(仅本地有会员且线上无会员时)
       Utility.getLocalNobleExpireDate().then((expireDate)=>{
-        if (Utility.isNoble() && !this.hasActiveSubscription && expireDate) {
+        if (Utility.isNobleForOld() && !this.hasActiveSubscription && expireDate) {
           UserUtil.syncLocalNobleToServer(expireDate).then((success)=>{
             if (success) {
               ToastUtil.showToast('本地会员已同步到账号');
@@ -262,8 +262,9 @@ export struct UserCenter {
     if (this.isLogin) {
       void this.fetchUserInfo();
     }
+    console.log('Heanup isLogin:'+this.isLogin)
     // 新增:未登录但本地是会员,弹窗提示登录同步会员
-    if (!this.isLogin && Utility.isNoble()) {
+    if (!this.isLogin && Utility.isNobleForOld()) {
       DialogHelper.showCustomContentDialog({
         dialogId: 'syncNobleDialog',
         title: '会员同步提示',