Răsfoiți Sursa

修复会员退出异常bug以及同步后没有立即更新会员信息

chendeben 1 an în urmă
părinte
comite
a70757b53d

+ 6 - 13
entry/src/main/ets/common/util/UserUtil.ets

@@ -260,15 +260,15 @@ export default class UserUtil {
           ToastUtil.showToast('微信登录成功');
           return json.data;
         } else {
-          ToastUtil.showToast('用户信息解析失败');
+          // ToastUtil.showToast('用户信息解析失败');
           return null;
         }
       } else {
-        ToastUtil.showToast('获取用户信息失败');
+        // ToastUtil.showToast('获取用户信息失败');
         return null;
       }
     } catch (e) {
-      ToastUtil.showToast('登录失败' + (e && e.message ? (': ' + e.message) : ''));
+      // ToastUtil.showToast('登录失败' + (e && e.message ? (': ' + e.message) : ''));
       return null;
     }
   }
@@ -313,15 +313,15 @@ export default class UserUtil {
           ToastUtil.showToast('华为登录成功');
           return json.data;
         } else {
-          ToastUtil.showToast('用户信息解析失败');
+          // ToastUtil.showToast('用户信息解析失败');
           return null;
         }
       } else {
-        ToastUtil.showToast('获取用户信息失败');
+        // ToastUtil.showToast('获取用户信息失败');
         return null;
       }
     } catch (e) {
-      ToastUtil.showToast('登录失败' + (e && e.message ? (': ' + e.message) : ''));
+      // ToastUtil.showToast('登录失败' + (e && e.message ? (': ' + e.message) : ''));
       return null;
     }
   }
@@ -340,7 +340,6 @@ export default class UserUtil {
       const response: http.HttpResponse = await httpRequest.request(url, options);
       if (response.responseCode === 200) {
         let res = response.result as string;
-        LogUtil.debug("fetchUserInfo res =" + res);
         let json: UserInfoApiResponse = JSON.parse(res) as UserInfoApiResponse;
         if (json.code === 0 && json.data) {
           const userId = json.data.system_info?.user_id ? Number(json.data.system_info?.user_id) : 0;
@@ -367,16 +366,12 @@ export default class UserUtil {
           PreferencesUtil.putSync('userToken', json.data.system_info?.token || '');
           return json.data;
         } else {
-          ToastUtil.showToast('刷新用户信息失败');
           return null;
         }
       } else {
-        ToastUtil.showToast('获取用户信息失败');
         return null;
       }
     } catch (e) {
-      ToastUtil.showToast('获取用户信息异常' + (e && e.message ? (': ' + e.message) : ''));
-      hilog.error(0x0000, 'UserUtil', `fetchUserInfo error: ${e.message}`);
       return null;
     }
   }
@@ -410,7 +405,6 @@ export default class UserUtil {
   static async syncLocalNobleToServer(expireDate: string): Promise<boolean> {
     try {
       const token = PreferencesUtil.getStringSync('userToken', '');
-      console.log("Heanup token:"+token+", expireDate:"+expireDate)
       if (!token || !expireDate) {
         ToastUtil.showToast('缺少token或到期时间');
         return false;
@@ -436,7 +430,6 @@ export default class UserUtil {
             let documentSaveResult = await documentViewPicker.save({ pickerMode: picker.DocumentPickerMode.DOWNLOAD })
             let download_path = new fileUri.FileUri(documentSaveResult[0]).path + '/'
             let filePath = download_path + LocalMusic.STR_LOCK_VIDEO+ '/' + VipPage.VIP_FILEPATH
-            console.log("Heanup filePath="+filePath)
             if (FileUtil.accessSync(filePath)) {
               FileUtil.unlink(filePath);
             }

+ 229 - 135
entry/src/main/ets/pages/UserCenter.ets

@@ -40,7 +40,8 @@ async function isHasWX(): Promise<boolean> {
   }
 }
 
-async function createWeChatOrder(app_id: string, mch_id: string, description: string, amount: number, out_trade_no_pre: string, uid: number, plan_id: string): Promise<string> {
+async function createWeChatOrder(app_id: string, mch_id: string, description: string, amount: number,
+  out_trade_no_pre: string, uid: number, plan_id: string): Promise<string> {
   let requestUrl = CommonConstants.WX_PAY_API
     + '?app_id=' + encodeURIComponent(app_id.trim())
     + '&mch_id=' + encodeURIComponent(mch_id.trim())
@@ -89,7 +90,7 @@ async function rsaSign2048(message: string): Promise<Uint8Array> {
     let key = keyGen.convertPemKeySync(null, CommonConstants.WX_PAY_RSA_PRIVATE_KEY)
 
     let sign = cryptoFramework.createSign('RSA2048|PKCS1|SHA256');
-    let msgBlob: cryptoFramework.DataBlob = {data: StrUtil.strToUint8Array(message)}
+    let msgBlob: cryptoFramework.DataBlob = { data: StrUtil.strToUint8Array(message) }
     sign.initSync(key.priKey)
     let signature = await sign.sign(msgBlob)
     return signature.data
@@ -125,18 +126,52 @@ export struct UserCenter {
   @State hasActiveSubscription: boolean = false;
   @State subscriptionName: string = '';
   @State subscriptionEndDate: string = '';
-  private wxApi = WXApi
-  private wxEventHandler = WXEventHandler
   @StorageProp('currentBreakpoint') currentBreakpoint: string = BreakpointTypeEnum.MD;
   @State vipFeatures: VipFeature[] = [
-    { icon: $r('app.media.wusunyinzhi'), title: '无损音质', description: '专享无损音乐支持,让每个音符都完美呈现', isVipOnly: true,hasCome:true },
+    {
+      icon: $r('app.media.wusunyinzhi'),
+      title: '无损音质',
+      description: '专享无损音乐支持,让每个音符都完美呈现',
+      isVipOnly: true,
+      hasCome: true
+    },
     // { icon: $r('app.media.lrc'), title: '歌词下载', description: '支持歌词API在线下载LRC歌词,实现完美同步', isVipOnly: true },
     // { icon: $r('app.media.cover'), title: '封面API', description: '支持设置自动下载封面', isVipOnly: true },
-    { icon: $r('app.media.theme'), title: '主题定制', description: '自定义播放器主题,打造独一无二的个性风格', isVipOnly: true,hasCome:true },
-    { icon: $r('app.media.no_ad'), title: '无广告', description: '清爽界面,无广告播放器', isVipOnly: true ,hasCome:true},
-    { icon: $r('app.media.skip'), title: '跳过头尾', description: '为某个歌单专门定制设置跳过头尾', isVipOnly: true ,hasCome:true},
-    { icon: $r('app.media.car'), title: 'HiCAR播放', description: '专为驾车体验优化的音乐播放模式', isVipOnly: true ,hasCome:false},
-    { icon: $r('app.media.music_wave'), title: '调音均衡器', description: '精准定制音效,带来极致听觉体验', isVipOnly: true ,hasCome:false},
+    {
+      icon: $r('app.media.theme'),
+      title: '主题定制',
+      description: '自定义播放器主题,打造独一无二的个性风格',
+      isVipOnly: true,
+      hasCome: true
+    },
+    {
+      icon: $r('app.media.no_ad'),
+      title: '无广告',
+      description: '清爽界面,无广告播放器',
+      isVipOnly: true,
+      hasCome: true
+    },
+    {
+      icon: $r('app.media.skip'),
+      title: '跳过头尾',
+      description: '为某个歌单专门定制设置跳过头尾',
+      isVipOnly: true,
+      hasCome: true
+    },
+    {
+      icon: $r('app.media.car'),
+      title: 'HiCAR播放',
+      description: '专为驾车体验优化的音乐播放模式',
+      isVipOnly: true,
+      hasCome: false
+    },
+    {
+      icon: $r('app.media.music_wave'),
+      title: '调音均衡器',
+      description: '精准定制音效,带来极致听觉体验',
+      isVipOnly: true,
+      hasCome: false
+    },
   ];
   @State vipPlans: VipPlanApi[] = [];
   @State selectedPayPlan: VipPlanApi | null = null;
@@ -147,90 +182,44 @@ export struct UserCenter {
   @StorageProp('topRectHeight') topRectHeight: number = px2vp(AppUtil.getStatusBarHeight());
   @StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number =
     ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
-  onColorModeChange() {
-    this.isDarkMode = this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK
-  }
+  private wxApi = WXApi
+  private wxEventHandler = WXEventHandler
 
   constructor() {
     super();
   }
 
-  // 微信回调处理
-  private onWXResp: OnWXResp = (resp): void => {
-    if (resp.errCode === ErrCode.ERR_OK) {
-      // 判断回调类型
-      if (resp.type === wxopensdk.Command.kCommandSendAuth) {
-        // 微信登录成功回调
-        const authResp = resp as wxopensdk.SendAuthResp; // 转换为授权响应类型,以便访问code
-        this.getUserInfoByCode(resp?.['code'])
-        DialogHelper.closeDialog('loginDialog');
-        ToastUtil.showToast('登录成功!');
-      } else if (resp.type === wxopensdk.Command.kCommandPay) {
-        // 微信支付成功回调
-        ToastUtil.showToast('支付成功!');
-        // 可在此处刷新会员状态或其他支付成功后的业务逻辑
-        // this.fetchVipPlans(); // 刷新会员套餐信息
-        this.fetchUserInfo();
-      } else {
-        // 其他类型的成功回调
-        ToastUtil.showToast('操作成功!');
-      }
-    } else {
-      // 处理错误情况
-      if (resp.type === wxopensdk.Command.kCommandSendAuth) {
-        ToastUtil.showToast('微信登录失败!');
-      } else if (resp.type === wxopensdk.Command.kCommandPay) {
-        ToastUtil.showToast('支付失败!');
-      } else {
-        ToastUtil.showToast('操作失败!');
-      }
-    }
+  onColorModeChange() {
+    this.isDarkMode = this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK
   }
 
   // 通过code换取用户信息
   async getUserInfoByCode(code: string) {
-    await UserUtil.getUserInfoByCode(code).then(async ()=>{
-      // 登录后同步本地会员到线上(仅本地有会员且线上无会员时)
-      Utility.getLocalNobleExpireDate().then((expireDate)=>{
-        if (Utility.isNobleForOld() && !this.hasActiveSubscription && expireDate) {
-          UserUtil.syncLocalNobleToServer(expireDate).then((success)=>{
-            if (success) {
-              ToastUtil.showToast('本地会员已同步到账号');
-              PreferencesUtil.putSync('isNoble', false);
-              this.fetchUserInfo();
-            } else {
-              this.fetchUserInfo();
-            }
-          });
-        } else {
-          this.fetchUserInfo();
-        }
-      });
-    });
+    await UserUtil.getUserInfoByCode(code);
+    // 登录后同步本地会员到线上(仅本地有会员且线上无会员时)
+    const expireDate = await Utility.getLocalNobleExpireDate();
+    if (Utility.isNobleForOld() && !this.hasActiveSubscription && expireDate) {
+      const success = await UserUtil.syncLocalNobleToServer(expireDate);
+      if (success) {
+        ToastUtil.showToast('本地会员已同步到账号');
+        PreferencesUtil.putSync('isNoble', false);
+      }
+    }
+    await this.fetchUserInfo();
   }
 
   // 通过华为账号信息换取用户信息和会员状态
   async getUserInfoByHuawei(openID: string, unionID: string, nickname: string, avatarUri: string) {
-    await UserUtil.getUserInfoByHuawei(openID, unionID, nickname, avatarUri).then(async (data)=>{
-      // 登录后同步本地会员到线上(仅本地有会员且线上无会员时)
-      Utility.getLocalNobleExpireDate().then((expireDate)=>{
-        if (Utility.isNobleForOld() && !this.hasActiveSubscription && expireDate) {
-          UserUtil.syncLocalNobleToServer(expireDate).then((success)=>{
-            if (success) {
-              ToastUtil.showToast('本地会员已同步到账号');
-              // 关键:同步成功后再刷新用户信息
-              this.fetchUserInfo();
-            } else {
-              // 同步失败也刷新一次
-              this.fetchUserInfo();
-            }
-          });
-        } else {
-          // 不需要同步会员,直接刷新
-          this.fetchUserInfo();
-        }
-      });
-    })
+    await UserUtil.getUserInfoByHuawei(openID, unionID, nickname, avatarUri);
+    // 登录后同步本地会员到线上(仅本地有会员且线上无会员时)
+    const expireDate = await Utility.getLocalNobleExpireDate();
+    if (Utility.isNobleForOld() && !this.hasActiveSubscription && expireDate) {
+      const success = await UserUtil.syncLocalNobleToServer(expireDate);
+      if (success) {
+        ToastUtil.showToast('本地会员已同步到账号');
+      }
+    }
+    await this.fetchUserInfo();
   }
 
   @Builder
@@ -242,6 +231,7 @@ export struct UserCenter {
       .textAlign(TextAlign.Center)
       .padding(16)
   }
+
   aboutToAppear(): void {
     this.topRectHeight = px2vp(AppUtil.getStatusBarHeight());
     let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', CommonConstants.DEFAULT_THEME_COLOR);
@@ -262,7 +252,7 @@ export struct UserCenter {
     if (this.isLogin) {
       void this.fetchUserInfo();
     }
-    console.log('Heanup isLogin:'+this.isLogin)
+    console.log('Heanup isLogin:' + this.isLogin)
 
     // 只在非同步跳转时弹窗提醒
     let params = router.getParams() as Record<string, Object>;
@@ -301,7 +291,7 @@ export struct UserCenter {
         // 顶部安全区
         Blank()
           .height(this.topRectHeight)
-          .backgroundColor(this.isDarkMode?$r('app.color.title_bar_bg'):this.themeColor)
+          .backgroundColor(this.isDarkMode ? $r('app.color.title_bar_bg') : this.themeColor)
           .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
         // 自定义标题栏(Stack实现绝对居中)
         Stack() {
@@ -328,7 +318,7 @@ export struct UserCenter {
         }
         .height(48)
         .width('100%')
-        .backgroundColor(this.isDarkMode?$r('app.color.user_center_card_background'):this.themeColor)
+        .backgroundColor(this.isDarkMode ? $r('app.color.user_center_card_background') : this.themeColor)
       }
 
       Scroll() {
@@ -345,7 +335,7 @@ export struct UserCenter {
       .edgeEffect(EdgeEffect.Spring)
       .layoutWeight(1)
       .padding({
-        bottom:45
+        bottom: 45
       })
     }
     .backgroundColor($r('app.color.index_background'))
@@ -353,7 +343,6 @@ export struct UserCenter {
     .height('100%')
     .layoutWeight(1)
 
-
   }
 
   // 用户信息卡片
@@ -367,7 +356,12 @@ export struct UserCenter {
           .borderRadius('50%')
           .clip(true)
           .backgroundColor(this.isDarkMode ? Color.Black : Color.White)
-          .shadow({ radius: 8, color: 0x11000000, offsetX: 0, offsetY: 2 })
+          .shadow({
+            radius: 8,
+            color: 0x11000000,
+            offsetX: 0,
+            offsetY: 2
+          })
         Column() {
           Row() {
             Text(this.isLogin ? this.userName : '未登录用户')
@@ -381,11 +375,12 @@ export struct UserCenter {
           }
           .justifyContent(FlexAlign.Start)
           .margin({ top: 2 })
+
           if (this.isLogin) {
             if (this.hasActiveSubscription) {
               Text(this.subscriptionName)
                 .fontSize(13)
-                .fontColor( themeColorWithAlpha(this.themeColor, 0.8, false))
+                .fontColor(themeColorWithAlpha(this.themeColor, 0.8, false))
                 .textAlign(TextAlign.Start)
               Text('到期:' + this.subscriptionEndDate)
                 .fontSize(11)
@@ -402,10 +397,11 @@ export struct UserCenter {
         .alignItems(HorizontalAlign.Start)
         .width(155)
         .margin({ left: 10 })
-        Column(){
+
+        Column() {
           if (this.isLogin) {
             Button('退出')
-              .fontColor( Color.White)
+              .fontColor(Color.White)
               .backgroundColor(this.isDarkMode ? $r('app.color.title_bar_bg') : this.themeColor)
               .height(36)
               .width(66)
@@ -423,16 +419,18 @@ export struct UserCenter {
                 this.subscriptionName = '';
                 this.subscriptionEndDate = '';
                 PreferencesUtil.putSync('isLogin', false);
+                PreferencesUtil.putSync('userId', 0);
                 PreferencesUtil.putSync('userName', '未登录用户');
                 PreferencesUtil.putSync('userAvatarUrl', '');
                 PreferencesUtil.putSync('subscriptionName', '');
                 PreferencesUtil.putSync('subscriptionEndDate', '');
                 PreferencesUtil.putSync('hasActiveSubscription', false);
+                PreferencesUtil.putSync('userToken', '');
                 ToastUtil.showToast('已退出登录')
               })
-          }else {
+          } else {
             Button('登录')
-              .fontColor( Color.White)
+              .fontColor(Color.White)
               .backgroundColor(this.isDarkMode ? $r('app.color.title_bar_bg') : this.themeColor)
               .height(36)
               .width(66)
@@ -442,7 +440,7 @@ export struct UserCenter {
           }
         }
         .alignItems(HorizontalAlign.End)
-        .margin({left:30, right: 10 })
+        .margin({ left: 30, right: 10 })
       }
       .onClick(() => {
         if (!this.isLogin) {
@@ -455,7 +453,12 @@ export struct UserCenter {
     .backgroundColor($r('app.color.user_center_card_background'))
     .borderRadius(24)
     .margin({ left: 14, right: 14, top: 15 })
-    .shadow({ radius: 8, color: 0x11000000, offsetX: 0, offsetY: 2 })
+    .shadow({
+      radius: 8,
+      color: 0x11000000,
+      offsetX: 0,
+      offsetY: 2
+    })
   }
 
   // 登录方式选择弹窗内容
@@ -529,7 +532,12 @@ export struct UserCenter {
       .justifyContent(FlexAlign.Center)
       .width('100%')
     }
-    .padding({ left: 24, right: 24, top: 8, bottom: 24 })
+    .padding({
+      left: 24,
+      right: 24,
+      top: 8,
+      bottom: 24
+    })
     .width('100%')
   }
 
@@ -541,8 +549,7 @@ export struct UserCenter {
       contentBuilder: () => {
         this.loginDialogContentBuilder();
       },
-      buttons: [
-      ]
+      buttons: []
     });
   }
 
@@ -569,18 +576,29 @@ export struct UserCenter {
                     .fontColor(themeColorWithAlpha(this.themeColor, 0.9, false))
                     .backgroundColor(themeColorWithAlpha(this.themeColor, 0.15, this.isDarkMode))
                     .borderRadius(8)
-                    .padding({ left: 6, right: 6, top: 2, bottom: 2 })
+                    .padding({
+                      left: 6,
+                      right: 6,
+                      top: 2,
+                      bottom: 2
+                    })
                     .margin({ top: 2, right: 2 })
-                }else {
+                } else {
                   Text('已开发')
                     .fontSize(10)
                     .fontColor(themeColorWithAlpha(this.themeColor, 0.9, false))
                     .backgroundColor(themeColorWithAlpha(this.themeColor, 0.15, this.isDarkMode))
                     .borderRadius(8)
-                    .padding({ left: 6, right: 6, top: 2, bottom: 2 })
+                    .padding({
+                      left: 6,
+                      right: 6,
+                      top: 2,
+                      bottom: 2
+                    })
                     .margin({ top: 2, right: 2 })
                 }
               }
+
               Row() {
                 Blank().layoutWeight(1)
                 Image(feature.icon)
@@ -608,17 +626,31 @@ export struct UserCenter {
                 Text('VIP专享')
                   .fontSize(10)
                   .fontColor(this.isDarkMode ? Color.White : this.themeColor)
-                  .backgroundColor(this.isDarkMode?$r('app.color.user_center_button_background'):themeColorWithAlpha(this.themeColor, 0.15, false))
+                  .backgroundColor(this.isDarkMode ? $r('app.color.user_center_button_background') :
+                  themeColorWithAlpha(this.themeColor, 0.15, false))
                   .borderRadius(8)
-                  .padding({ left: 6, right: 6, top: 2, bottom: 2 })
-                  .margin({ top: 2,bottom:6 })
+                  .padding({
+                    left: 6,
+                    right: 6,
+                    top: 2,
+                    bottom: 2
+                  })
+                  .margin({ top: 2, bottom: 6 })
               }
             }
             .backgroundColor($r('app.color.user_center_card_background'))
             .borderRadius(16)
-            .shadow({ radius: 8, color: 0x11000000, offsetX: 0, offsetY: 2 })
-            .border({ color:(this.isDarkMode?$r('app.color.user_center_button_background') :themeColorWithAlpha(this.themeColor, 0.08, false))//未选中时的边框颜色
-            , width: 2 })
+            .shadow({
+              radius: 8,
+              color: 0x11000000,
+              offsetX: 0,
+              offsetY: 2
+            })
+            .border({
+              color: (this.isDarkMode ? $r('app.color.user_center_button_background') :
+              themeColorWithAlpha(this.themeColor, 0.08, false))//未选中时的边框颜色
+            , width: 2
+            })
             .padding(12)
             .width('100%')
             .height(145)
@@ -628,11 +660,21 @@ export struct UserCenter {
       .columnsTemplate('1fr 1fr')
       .columnsGap(16)
       .rowsGap(16)
-      .margin({ left: 16, right: 16,top:0, bottom: 15 })
+      .margin({
+        left: 16,
+        right: 16,
+        top: 0,
+        bottom: 15
+      })
     }
     .backgroundColor(this.isDarkMode ? Color.Black : Color.White)
     .borderRadius(24)
-    .margin({ left: 16, right: 16,top:15, bottom: 15 })
+    .margin({
+      left: 16,
+      right: 16,
+      top: 15,
+      bottom: 15
+    })
   }
 
   // 支付方式选择弹窗内容
@@ -660,7 +702,12 @@ export struct UserCenter {
             }
           })
           .shape(CheckBoxShape.CIRCLE)
-          .margin({ left: 20, top: 8, bottom: 8, right: 20 })
+          .margin({
+            left: 20,
+            top: 8,
+            bottom: 8,
+            right: 20
+          })
           .width(22)
           .height(22)
       }
@@ -693,7 +740,12 @@ export struct UserCenter {
             }
           })
           .shape(CheckBoxShape.CIRCLE)
-          .margin({ left: 20, top: 8, bottom: 8, right: 20 })
+          .margin({
+            left: 20,
+            top: 8,
+            bottom: 8,
+            right: 20
+          })
           .width(22)
           .height(22)
       }
@@ -742,8 +794,11 @@ export struct UserCenter {
                 if (plan.original_price && plan.discount_percent && plan.discount_percent > 0) {
                   Text('¥' + plan.original_price)
                     .fontSize(14)
-                    .fontColor(themeColorWithAlpha(this.themeColor, 0.7,false))
-                    .decoration({ type: TextDecorationType.LineThrough, color: themeColorWithAlpha(this.themeColor, 0.7, false) })
+                    .fontColor(themeColorWithAlpha(this.themeColor, 0.7, false))
+                    .decoration({
+                      type: TextDecorationType.LineThrough,
+                      color: themeColorWithAlpha(this.themeColor, 0.7, false)
+                    })
                     .fontStyle(FontStyle.Italic)
                     .textAlign(TextAlign.Center)
                 }
@@ -757,14 +812,23 @@ export struct UserCenter {
                 .maxLines(1)
                 .textAlign(TextAlign.Center)
             }
-            .backgroundColor(this.selectedPayPlan && this.selectedPayPlan.id === plan.id ? themeColorWithAlpha(this.themeColor, 0.08, false) : (this.isDarkMode ? Color.Black : '#F7F7F7'))
+            .backgroundColor(this.selectedPayPlan && this.selectedPayPlan.id === plan.id ?
+            themeColorWithAlpha(this.themeColor, 0.08, false) : (this.isDarkMode ? Color.Black : '#F7F7F7'))
             .borderRadius(18)
-            .shadow({ radius: 8, color: 0x11000000, offsetX: 0, offsetY: 2 })
-            .border({ color: this.selectedPayPlan && this.selectedPayPlan.id === plan.id ?
-              (this.isDarkMode ? Color.White :themeColorWithAlpha(this.themeColor, 0.3, this.isDarkMode))//选中时的边框颜色
-              :
-              (this.isDarkMode?$r('app.color.user_center_button_background') :themeColorWithAlpha(this.themeColor, 0.08, this.isDarkMode))//未选中时的边框颜色
-            , width: 2 })
+            .shadow({
+              radius: 8,
+              color: 0x11000000,
+              offsetX: 0,
+              offsetY: 2
+            })
+            .border({
+              color: this.selectedPayPlan && this.selectedPayPlan.id === plan.id ?
+                (this.isDarkMode ? Color.White : themeColorWithAlpha(this.themeColor, 0.3, this.isDarkMode))//选中时的边框颜色
+                :
+                (this.isDarkMode ? $r('app.color.user_center_button_background') :
+                themeColorWithAlpha(this.themeColor, 0.08, this.isDarkMode))//未选中时的边框颜色
+            , width: 2
+            })
             .width(125)
             .height(125)
             .margin({ left: index === 0 ? 16 : 8, right: index === this.vipPlans.length - 1 ? 16 : 8 })
@@ -784,7 +848,7 @@ export struct UserCenter {
       Button(this.isVip ? '升级会员' : '立即开通')
         .borderRadius(24)
         .backgroundColor(this.isDarkMode ? $r('app.color.user_center_button_background') : this.themeColor)
-        .width(this.currentBreakpoint !== BreakpointTypeEnum.SM?'25%':'60%')
+        .width(this.currentBreakpoint !== BreakpointTypeEnum.SM ? '25%' : '60%')
         .fontColor(Color.White)
         .fontSize(18)
         .padding(12)
@@ -898,7 +962,7 @@ export struct UserCenter {
       const avatarUri = credential?.avatarUri ?? '';
       const openID = credential?.openID;
       const unionID = credential?.unionID ?? '';
-      hilog.info(domainId, logTag, `华为登录成功,昵称: ${nickName}, openID: ${openID}`);
+      // hilog.info(domainId, logTag, `华为登录成功,昵称: ${nickName}, openID: ${openID}`);
       // 调用接口获取用户信息和会员状态
       if (openID) {
         await this.getUserInfoByHuawei(openID, unionID, nickName, avatarUri);
@@ -1033,7 +1097,7 @@ export struct UserCenter {
   async doAliPay(plan: VipPlanApi) {
     const appName = PreferencesUtil.getStringSync('appName', 'TTMusic');
     OrderInfoUtil.getOrderInfo(Number(plan.price), appName, this.userId, plan.id).then((orderInfo) => {
-      console.log('Heanup: alipay orderInfo = '+json.stringify(orderInfo))
+      console.log('Heanup: alipay orderInfo = ' + json.stringify(orderInfo))
       new Pay().pay(orderInfo, true).then(async (result) => {
         if (result.get('resultStatus') === '9000') {
           ToastUtil.showToast('支付成功!');
@@ -1051,19 +1115,49 @@ export struct UserCenter {
   // 每次进入页面时刷新用户数据
   async fetchUserInfo() {
     // console.log('Heanup 刷新用户信息:'+token)
-    await UserUtil.fetchUserInfo().then((user_info)=>{
-      console.log("Heanup UserInfo:"+json.stringify(user_info))
-      this.isLogin = PreferencesUtil.getBooleanSync('isLogin', false);
-      this.userId = PreferencesUtil.getNumberSync('userId', 0);
-      this.userName = PreferencesUtil.getStringSync('userName', '未登录用户');
-      this.userAvatarUrl = PreferencesUtil.getStringSync('userAvatarUrl', '');
-      this.subscriptionName = PreferencesUtil.getStringSync('subscriptionName', '');
-      this.subscriptionEndDate = PreferencesUtil.getStringSync('subscriptionEndDate', '');
-      this.hasActiveSubscription = PreferencesUtil.getBooleanSync('hasActiveSubscription', false);
-      console.log('Heanup hasActiveSubscription:'+this.hasActiveSubscription)
-      // 新增:同步线上会员状态到本地,便于 Utility.isNoble 全局判断
-      PreferencesUtil.putSync('hasActiveSubscription', this.hasActiveSubscription);
-    });
+    await UserUtil.fetchUserInfo();
+    // console.log("Heanup UserInfo:" + json.stringify(user_info))
+    this.isLogin = PreferencesUtil.getBooleanSync('isLogin', false);
+    this.userId = PreferencesUtil.getNumberSync('userId', 0);
+    this.userName = PreferencesUtil.getStringSync('userName', '未登录用户');
+    this.userAvatarUrl = PreferencesUtil.getStringSync('userAvatarUrl', '');
+    this.subscriptionName = PreferencesUtil.getStringSync('subscriptionName', '');
+    this.subscriptionEndDate = PreferencesUtil.getStringSync('subscriptionEndDate', '');
+    this.hasActiveSubscription = PreferencesUtil.getBooleanSync('hasActiveSubscription', false);
+    // console.log('Heanup hasActiveSubscription:' + this.hasActiveSubscription)
+    // 新增:同步线上会员状态到本地,便于 Utility.isNoble 全局判断
+    PreferencesUtil.putSync('hasActiveSubscription', this.hasActiveSubscription);
   }
 
+  // 微信回调处理
+  private onWXResp: OnWXResp = (resp): void => {
+    if (resp.errCode === ErrCode.ERR_OK) {
+      // 判断回调类型
+      if (resp.type === wxopensdk.Command.kCommandSendAuth) {
+        // 微信登录成功回调
+        const authResp = resp as wxopensdk.SendAuthResp; // 转换为授权响应类型,以便访问code
+        this.getUserInfoByCode(resp?.['code'])
+        DialogHelper.closeDialog('loginDialog');
+        ToastUtil.showToast('登录成功!');
+      } else if (resp.type === wxopensdk.Command.kCommandPay) {
+        // 微信支付成功回调
+        ToastUtil.showToast('支付成功!');
+        // 可在此处刷新会员状态或其他支付成功后的业务逻辑
+        // this.fetchVipPlans(); // 刷新会员套餐信息
+        this.fetchUserInfo();
+      } else {
+        // 其他类型的成功回调
+        ToastUtil.showToast('操作成功!');
+      }
+    } else {
+      // 处理错误情况
+      if (resp.type === wxopensdk.Command.kCommandSendAuth) {
+        ToastUtil.showToast('微信登录失败!');
+      } else if (resp.type === wxopensdk.Command.kCommandPay) {
+        ToastUtil.showToast('支付失败!');
+      } else {
+        ToastUtil.showToast('操作失败!');
+      }
+    }
+  }
 }