|
|
@@ -22,6 +22,7 @@ import json from '@ohos.util.json';
|
|
|
import UserUtil, { VipFeature, VipPlanApi, VipPlanListApiResponse, WeChatPrepayId } from '../common/util/UserUtil';
|
|
|
import { Utility } from '../common/util/Utility';
|
|
|
import { pinyin4js } from '@ohos/pinyin4js';
|
|
|
+import { CustomContentDialog } from '@kit.ArkUI';
|
|
|
|
|
|
|
|
|
// 微信支付相关工具方法
|
|
|
@@ -196,9 +197,36 @@ export struct UserCenter {
|
|
|
@StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number =
|
|
|
ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
|
|
|
@State showWxLogin: boolean = false;
|
|
|
+ @State appIdentifier: string = '';
|
|
|
private wxApi = WXApi
|
|
|
private wxEventHandler = WXEventHandler
|
|
|
|
|
|
+ // 注销功能相关
|
|
|
+ deleteAccountDialogController: CustomDialogController = new CustomDialogController({
|
|
|
+ builder: CustomContentDialog({
|
|
|
+ primaryTitle: '注销账户',
|
|
|
+ contentBuilder: () => {
|
|
|
+ this.deleteAccountDialogContent();
|
|
|
+ },
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ value: '取消',
|
|
|
+ action: () => {
|
|
|
+ this.deleteAccountDialogController.close();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '确认注销',
|
|
|
+ action: () => {
|
|
|
+ this.handleDeleteAccount();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }),
|
|
|
+ autoCancel: true,
|
|
|
+ alignment: DialogAlignment.Center
|
|
|
+ })
|
|
|
+
|
|
|
constructor() {
|
|
|
super();
|
|
|
}
|
|
|
@@ -252,6 +280,7 @@ export struct UserCenter {
|
|
|
Utility.getAppName(getContext(this)).then((appName:string)=>{
|
|
|
this.appName = appName
|
|
|
})
|
|
|
+ this.getAppIdentifier(); // 获取应用标识符
|
|
|
this.topRectHeight = px2vp(AppUtil.getStatusBarHeight());
|
|
|
let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', CommonConstants.DEFAULT_THEME_COLOR);
|
|
|
this.isDarkMode = this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK
|
|
|
@@ -451,6 +480,11 @@ export struct UserCenter {
|
|
|
}
|
|
|
this.buildVipFeatures()
|
|
|
|
|
|
+ // 注销功能区域(仅在登录时显示)
|
|
|
+ if (this.isLogin) {
|
|
|
+ this.buildDeleteAccountSection()
|
|
|
+ }
|
|
|
+
|
|
|
// this.buildFunctionMenu()
|
|
|
}
|
|
|
.width('100%')
|
|
|
@@ -731,6 +765,74 @@ export struct UserCenter {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ // 注销功能区域
|
|
|
+ @Builder
|
|
|
+ buildDeleteAccountSection(): void {
|
|
|
+ Column() {
|
|
|
+ Row() {
|
|
|
+ SymbolGlyph($r('sys.symbol.exclamationmark_triangle_fill'))
|
|
|
+ .fontSize(24)
|
|
|
+ .fontColor([Color.Red])
|
|
|
+ .margin({ left: 16 })
|
|
|
+ Text('危险操作')
|
|
|
+ .fontSize(18)
|
|
|
+ .fontWeight(FontWeight.Bold)
|
|
|
+ .fontColor(Color.Red)
|
|
|
+ .margin({ left: 12 })
|
|
|
+ .layoutWeight(1)
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .margin({ bottom: 16 })
|
|
|
+
|
|
|
+ Button() {
|
|
|
+ Row() {
|
|
|
+ SymbolGlyph($r('sys.symbol.trash'))
|
|
|
+ .fontSize(20)
|
|
|
+ .fontColor([Color.Red])
|
|
|
+ .alignSelf(ItemAlign.Center)
|
|
|
+ .margin({ left: 12 })
|
|
|
+ Text('注销账户')
|
|
|
+ .margin({ left: 8 })
|
|
|
+ .fontSize(15)
|
|
|
+ .fontColor(Color.Red)
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .layoutWeight(1)
|
|
|
+ Image($r('app.media.arrow_right'))
|
|
|
+ .width(22)
|
|
|
+ .height(22)
|
|
|
+ .margin({ right: 16 })
|
|
|
+ .fillColor([Color.Red])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .backgroundColor(Color.Transparent)
|
|
|
+ .height(55)
|
|
|
+ .width('100%')
|
|
|
+ .clickEffect({ level: ClickEffectLevel.HEAVY })
|
|
|
+ .onClick(() => {
|
|
|
+ this.deleteAccountDialogController.open();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .backgroundColor($r('app.color.user_center_card_background'))
|
|
|
+ .borderRadius(24)
|
|
|
+ .margin({
|
|
|
+ left: 16,
|
|
|
+ right: 16,
|
|
|
+ top: 10,
|
|
|
+ bottom: 20
|
|
|
+ })
|
|
|
+ .padding({
|
|
|
+ top: 20,
|
|
|
+ bottom: 20
|
|
|
+ })
|
|
|
+ .shadow({
|
|
|
+ radius: 8,
|
|
|
+ color: 0x11000000,
|
|
|
+ offsetX: 0,
|
|
|
+ offsetY: 2
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
// 支付方式选择弹窗内容
|
|
|
@Builder
|
|
|
payDialogContentBuilder(): void {
|
|
|
@@ -1216,4 +1318,106 @@ export struct UserCenter {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 获取应用标识符
|
|
|
+ getAppIdentifier() {
|
|
|
+ let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
|
|
|
+ bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
|
|
|
+ try {
|
|
|
+ bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
|
|
|
+ hilog.info(0x0000, 'UserCenter', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
|
|
|
+ let inde = JSON.stringify(data)
|
|
|
+ this.appIdentifier = inde.substring(inde.indexOf('appIdentifier'),inde.indexOf('"certificate'))
|
|
|
+ hilog.info(0x0000, 'UserCenter', 'appIdentifier Data: %{public}s', this.appIdentifier);
|
|
|
+ }).catch((err: BusinessError) => {
|
|
|
+ hilog.error(0x0000, 'UserCenter', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
|
|
|
+ });
|
|
|
+ } catch (err) {
|
|
|
+ let message = (err as BusinessError).message;
|
|
|
+ hilog.error(0x0000, 'UserCenter', 'getBundleInfoForSelf failed: %{public}s', message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Builder
|
|
|
+ deleteAccountDialogContent() {
|
|
|
+ Column() {
|
|
|
+ Text('注销账户后将无法恢复,所有相关数据将被永久删除。')
|
|
|
+ .fontSize(16)
|
|
|
+ .fontColor(Color.Red)
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('100%')
|
|
|
+ .margin({ bottom: 20 })
|
|
|
+
|
|
|
+ // Text('包括但不限于:')
|
|
|
+ // .fontSize(14)
|
|
|
+ // .fontColor(Color.Gray)
|
|
|
+ // .textAlign(TextAlign.Start)
|
|
|
+ // .width('100%')
|
|
|
+ // .margin({ bottom: 10 })
|
|
|
+ //
|
|
|
+ // Text('• 个人信息和设置(含订阅套餐)')
|
|
|
+ // .fontSize(13)
|
|
|
+ // .fontColor(Color.Gray)
|
|
|
+ // .textAlign(TextAlign.Start)
|
|
|
+ // .width('100%')
|
|
|
+ // .margin({ left: 20, bottom: 5 })
|
|
|
+ //
|
|
|
+ // Text('• 收藏和播放列表')
|
|
|
+ // .fontSize(13)
|
|
|
+ // .fontColor(Color.Gray)
|
|
|
+ // .textAlign(TextAlign.Start)
|
|
|
+ // .width('100%')
|
|
|
+ // .margin({ left: 20, bottom: 5 })
|
|
|
+ //
|
|
|
+ // Text('• 播放历史记录')
|
|
|
+ // .fontSize(13)
|
|
|
+ // .fontColor(Color.Gray)
|
|
|
+ // .textAlign(TextAlign.Start)
|
|
|
+ // .width('100%')
|
|
|
+ // .margin({ left: 20, bottom: 15 })
|
|
|
+
|
|
|
+ Text('请确认您已了解此操作的后果。')
|
|
|
+ .fontSize(14)
|
|
|
+ .fontColor($r('app.color.text_color'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('100%')
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .padding(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ async handleDeleteAccount() {
|
|
|
+ try {
|
|
|
+
|
|
|
+ // 显示加载提示
|
|
|
+ ToastUtil.showToast('正在处理注销请求...');
|
|
|
+
|
|
|
+ // 调用注销API
|
|
|
+ const success = await UserUtil.deleteAccount();
|
|
|
+
|
|
|
+ if (success) {
|
|
|
+ // 更新页面状态
|
|
|
+ this.isLogin = false
|
|
|
+ this.userName = '未登录用户'
|
|
|
+ this.userAvatar = $r('app.media.icon_person2')
|
|
|
+ this.userAvatarUrl = ''
|
|
|
+ this.isVip = false
|
|
|
+ this.vipExpire = ''
|
|
|
+ this.hasActiveSubscription = false;
|
|
|
+ this.subscriptionName = '';
|
|
|
+ this.subscriptionEndDate = '';
|
|
|
+ this.isForever=false;
|
|
|
+
|
|
|
+
|
|
|
+ ToastUtil.showToast('账户已成功注销');
|
|
|
+ this.deleteAccountDialogController.close();
|
|
|
+
|
|
|
+ // 发送用户状态变更事件
|
|
|
+ emitter.emit({ eventId: EventConstants.EVENT_USER_STATE_CHANGE }, {})
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ hilog.error(0x0000, 'UserCenter', '注销账户失败: %{public}s', error);
|
|
|
+ ToastUtil.showToast('注销失败,请稍后重试');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|