Procházet zdrojové kódy

feat: 对设置页面下的UI和功能进行完善

YuJing před 1 měsícem
rodič
revize
a6360d17be

+ 2 - 2
commons/basic/src/main/ets/components/DiaLogComp/DiaLogControl.ets

@@ -19,7 +19,7 @@ export class DiaLogCompControl{
     })
   }
 
-  _onBackPress: (ans?: ESObject) => boolean = (ans: ESObject) => {
+  _onBackPress(ans?: ESObject) {
     if(this.isBack) return true
 
     this.isBack = true
@@ -27,7 +27,7 @@ export class DiaLogCompControl{
     this.conText.animateTo({ duration: 300 }, () => {
       this.opacity_ = 0
       setTimeout(() => {
-        yTRouter.pop(ans ?? 0, false)
+        yTRouter.pop(ans, false)
       }, 300)
     })
     return true

+ 112 - 183
features/user/src/main/ets/pages/SettingPage.ets

@@ -2,7 +2,6 @@ import {
   BasicType,
   DiaLogCompControl,
   IBestToast,
-  reviseImgHeaderBuilder,
   userInfo,
   UserInfo,
   YTAvoid,
@@ -25,34 +24,50 @@ function settingBuilder() {
 
 @Component
 struct SettingPage {
-  @State showReviseName: boolean = false
   @StorageProp(YTAvoid.SAFE_BOTTOM_KEY) private safeBottom: number = 0
   @StorageProp(UserInfo.KEY) private userInfo: UserInfo = userInfo
   @State private value: string = ''
   private yTPhotoHelper = new YTPhotoHelper()
+
   private reviseBuilderArr: Array<BasicType> = [
     {
-      text: '头像修改',
-      src: '头像',
+      text: '我的昵称', src: '名称',
+      click: () => {
+        this.openReviseNameBuilder()
+      }
+    }, {
+      text: '绑定手机号',
+      message: this.userInfo.getPhoneNumber() ?? '',
+      click: () => {
+        // this.openChangeBuilder()
+      }
+    }
+  ]
+
+  private reviseBuilderArr1: Array<BasicType> = [
+    { text: '宝贝头像', src: '头像',
       click: () => {
         this.openChangeBuilder()
       }
-    },
-    {
-      text: '昵称修改',
-      src: '名称',
+    }, {
+      text: '宝贝昵称', src: '名称',
       click: () => {
-        // this.showReviseName = true
-        this.openReviseNameBuilder()
+        // this.openReviseNameBuilder()
+      }
+    }, {
+      text: '性别',
+      click: () => {
+        // this.openReviseNameBuilder()
+      }
+    }, {
+      text: '生日',
+      click: () => {
+        // this.openReviseNameBuilder()
       }
     },
-  // {
-  //   text: '密码设置',
-  //   click: () => {
-  //     yTRouter.router2UpdatePasswordPage()
-  //   }
-  // }
   ]
+
+
   private options: BasicType[] = [
     {
       text: '拍照',
@@ -107,184 +122,98 @@ struct SettingPage {
 
   build() {
     Column() {
-      YTHeader({ defaultStyle: { title: '用户设置' } })
-      Column() {
-        ForEach(this.reviseBuilderArr, (item: BasicType, index) => {
-          this.reviseBuilder(item)
-          if (index < this.reviseBuilderArr.length - 1) {
-            Column() {
-              Text('')
-                .height(1)
-                .width('100%')
-                .backgroundColor('#1c1c1c1a')
-            }
-            .padding({ left: 12, right: 8 })
-          }
-        })
-        Blank()
-          .layoutWeight(1)
-
-        YTButton({
-          btContent: '注销用户',
-          btFontColor: '#991C1C1C',
-          btFontSize: 16,
-          btHeight: 48,
-          btBorderRadius: 40,
-          bgc: Color.White,
-          click: () => {
-            yTToast.doubleConfirm({
-              message: '注销后无法恢复,是否确定注销?', click: () => {
-                YTUserRequest.logout(() => {
-                  yTToast.hide()
-                  yTRouter.routerBack()
-                  setTimeout(() => {
-                    IBestToast.show('注销成功')
-                  }, 50)
-                })
-
-              }
-            })
-          }
-        })
-        YTButton({
-          btContent: '退出登录',
-          click: () => {
-            this.userInfo.logout()
-            yTRouter.routerBack()
-            IBestToast.show({ message: '退出登录成功' })
-          },
-          btFontSize: 16,
-          btHeight: 48,
-          btBorderRadius: 40,
-        })
-        Text()
-          .height(200)
-          .width('100%')
+      YTHeader({ defaultStyle: { title: '用户设置' }, bgc: Color.White })
+
+      Column({space: 16}) {
+        this.reviseBuilder(this.reviseBuilderArr)
+
+        this.reviseBuilder(this.reviseBuilderArr1)
+
+        // YTButton({
+        //   btContent: '注销用户',
+        //   btFontColor: '#991C1C1C',
+        //   btFontSize: 16,
+        //   btHeight: 48,
+        //   btBorderRadius: 40,
+        //   bgc: Color.White,
+        //   click: () => {
+        //     yTToast.doubleConfirm({
+        //       message: '注销后无法恢复,是否确定注销?', click: () => {
+        //         YTUserRequest.logout(() => {
+        //           yTToast.hide()
+        //           yTRouter.routerBack()
+        //           setTimeout(() => {
+        //             IBestToast.show('注销成功')
+        //           }, 50)
+        //         })
+        //
+        //       }
+        //     })
+        //   }
+        // })
+        // YTButton({
+        //   btContent: '退出登录',
+        //   click: () => {
+        //     this.userInfo.logout()
+        //     yTRouter.routerBack()
+        //     IBestToast.show({ message: '退出登录成功' })
+        //   },
+        //   btFontSize: 16,
+        //   btHeight: 48,
+        //   btBorderRadius: 40,
+        // })
 
       }
-      .bindSheet($$this.showReviseName, this.reviseNameBuilder, {
-        height: 275,
-        showClose: false,
-        backgroundColor: Color.White
-      })
-      .padding({
-        left: 16,
-        right: 16,
-
-      })
+      .padding({ left: 16, right: 16, top: 22 })
     }
+    .width('100%')
+    .height('100%')
+    .backgroundColor('#F7F9FA')
     .padding({ bottom: this.safeBottom })
-    // .bindSheet($$this.showHeaderImgRevise, this.changeBuilder, {
-    //   height: 204,
-    //   backgroundColor: Color.White,
-    //   showClose: false
-    // })
   }
 
   @Builder
-  reviseBuilder(item: BasicType) {
-    Row() {
-      Text(item.text)
-        .fontSize($r('[basic].float.page_text_font_size_12'))
-        .fontColor('#FF1C1C1C')
-        .fontWeight(500)
-        .fontSize(16)
-      Row() {
-        if (item.src == '头像') {
-          Image(this.userInfo.getHeadImg() ? this.userInfo.getHeadImg() : $r('app.media.default_img'))
-            .height(32)
-            .width(32)
-            .borderRadius(99)
-        } else if (item.src == '名称') {
-          Text(this.userInfo.getName() ?? this.userInfo.getPhoneNumber() ?? this.userInfo.getId()?.toString())
+  reviseBuilder(params: Array<BasicType>) {
+    Column(){
+      ForEach(params, (item: BasicType, index) => {
+        Row() {
+          Text(item.text)
+            .fontSize($r('[basic].float.page_text_font_size_12'))
+            .fontColor('#FF1C1C1C')
+            .fontWeight(500)
             .fontSize(16)
-            .fontColor('#E61C1C1C')
-        }
-        Image($r('app.media.right_arrow'))
-          .width(24)
-          .width(24)
-      }
-    }
-    .width('100%')
-    .justifyContent(FlexAlign.SpaceBetween)
-    .padding({ left: 12, right: 4 })
-    .height(56)
-    .onClick(item.click)
-  }
-
-  @Builder
-  reviseNameBuilder() {
-    Column() {
-
-      Text('昵称')
-        .width('100%')
-        .height(36)
-        .textAlign(TextAlign.Start)
-        .fontSize(12)
-
-      TextInput({ text: $$this.value, placeholder: '请输入昵称' })
-        .borderRadius(4)
-        .fontSize(12)
-        .placeholderFont({ size: 12 })
-        .placeholderColor('#14000000')
-        .height(36)
-        .width('100%')
-        .backgroundColor(Color.White)
-        .border({ width: 1, color: '#14000000' })
-        .margin({ bottom: 25 })
-        .maxLength(7)
-
-
-      Row({ space: 32 }) {
-        YTButton({
-          btContent: '取消',
-          btHeight: 25,
-          btWidth: 78,
-          btBorder: { width: 1, color: '#1A000000' },
-          btPadding: {
-            left: 26,
-            right: 26,
-            top: 4,
-            bottom: 4
-          },
-          bgc: Color.White,
-          btFontColor: $r('sys.color.mask_secondary'),
-          click: () => {
-            this.showReviseName = false
-            this.value = ''
-
-          }
-        })
-        YTButton({
-          btContent: '完成',
-          btHeight: 25,
-          btWidth: 78,
-          btPadding: {
-            left: 26,
-            right: 26,
-            top: 4,
-            bottom: 4
-          },
-          click: () => {
-            if (!this.value) {
-              IBestToast.show({
-                type: "warning",
-                message: "昵称不能为空"
-              })
-              return
+          Row() {
+            if (item.src == '头像') {
+              Image(this.userInfo.getHeadImg() ? this.userInfo.getHeadImg() : $r('app.media.default_img'))
+                .height(32)
+                .width(32)
+                .borderRadius(99)
+            } else if (item.src == '名称') {
+              Text(this.userInfo.getName() ?? this.userInfo.getPhoneNumber() ?? this.userInfo.getId()?.toString())
+                .fontSize(16)
+                .fontColor('#E61C1C1C')
+            } else {
+              Text(item.message)
+                .fontSize(16)
+                .fontColor('#E61C1C1C')
             }
-            YTUserRequest.changeNickname(this.value, () => {
-              IBestToast.show({ message: '名称修改成功' })
-              this.showReviseName = false
-            })
-
+            Image($r('app.media.right_arrow'))
+              .width(24)
+              .width(24)
           }
-        })
-      }
-      .justifyContent(FlexAlign.Center)
-      .width('100%')
+        }
+        .width('100%')
+        .onClick(item.click)
+        .justifyContent(FlexAlign.SpaceBetween)
 
+        if(index != params.length - 1) {
+          Divider().width('100%').height(1).backgroundColor('#FBFBFB')
+            .margin({top: 15, bottom: 15})
+        }
+      })
     }
-    .padding({ left: 22, right: 22, top: 8 })
+    .padding(15)
+    .borderRadius(8)
+    .backgroundColor(Color.White)
   }
 }