Prechádzať zdrojové kódy

增加了好评的通用性与注销用户的逻辑

wangcy 4 mesiacov pred
rodič
commit
22bee53835

+ 0 - 2
commons/basic/src/main/ets/utils/YTRequest.ets

@@ -125,10 +125,8 @@ class YtRequest {
                 setTimeout(() => {
                   IBestToast.show({ message: '登录成功' })
                 }, 100)
-
                 yTRouter.routerBack()
               })
-
             })
             .catch((err: Error) => {
               // AlertDialog.show({ message: JSON.stringify(err, null, 2) })

+ 9 - 6
features/user/src/main/ets/pages/SettingPage.ets

@@ -11,7 +11,8 @@ import {
   YTHeader,
   YTLog,
   yTRequest,
-  yTRouter
+  yTRouter,
+  yTToast
 } from 'basic'
 
 @Builder
@@ -117,11 +118,13 @@ struct SettingPage {
           btFontColor: Color.Red,
           bgc: Color.White,
           click: () => {
-            // yTToast.doubleConfirm({
-            //   text: '警告⚠', message: '确定要注销吗?\n注销后数据丢失无法恢复!', click: () => {
-            //     AlertDialog.show({ message: JSON.stringify('点击了确定', null, 2) })
-            //   }
-            // })
+            yTToast.doubleConfirm({
+              text: '警告⚠', message: '确定要注销吗?\n注销后数据丢失无法恢复!', click: () => {
+                userInfo.logout()
+                yTToast.hide()
+                yTRouter.pop()
+              }
+            })
           }
         })
       }

+ 16 - 3
products/entry/src/main/ets/views/Mine.ets

@@ -1,4 +1,7 @@
-import { BasicType, copyText, ShowBannerAd, UserInfo, userInfo, YtAvoid, yTRouter } from 'basic'
+import { BasicType, copyText, IBestToast, ShowBannerAd, UserInfo, userInfo, YtAvoid, YTLog, yTRouter } from 'basic'
+import { common, Want } from '@kit.AbilityKit'
+import { BusinessError } from '@kit.BasicServicesKit'
+import { BUNDLE_NAME } from 'BuildProfile'
 
 @Component
 export struct Mine {
@@ -21,7 +24,18 @@ export struct Mine {
     {
       text: '给个好评',
       click: () => {
-
+        const want: Want = {
+          uri: "store://appgallery.huawei.com/app/detail?id=" + BUNDLE_NAME
+        };
+        const context = getContext(this) as common.UIAbilityContext;
+        context.startAbility(want).then(() => {
+          //拉起成功
+          YTLog.info('跳转成功')
+        }).catch((err: BusinessError) => {
+          // 拉起失败
+          YTLog.error(err)
+          IBestToast.show('出现未知错误,请稍后再试')
+        });
       },
       src: $r('[user].media.right_arrow')
     },
@@ -126,7 +140,6 @@ export struct Mine {
       .margin({ top: 30 })
     }
     .padding({ top: this.safeTop + 22, left: 16, right: 16 })
-
     .height('100%')
   }
 }