Эх сурвалжийг харах

feat: 完善订单详情 和 地址选择弹窗

YuJing 1 сар өмнө
parent
commit
2e425684ff

+ 5 - 6
commons/basic/src/main/ets/components/DiaLogComp/DiaLogComp.ets

@@ -44,9 +44,9 @@ export struct DiaLogComp {
 
   @Builder
   containerComp(){
-    if (this.controller?.diaLogType == 'ReviseName') {
-      ReviseName(this.param, this.control)
-    } else {
+    // if (this.controller?.diaLogType == 'ReviseName') {
+      // ReviseName(this.param, this.control)
+    // } else {
       Column() {
         Text(this.param.text ?? '一个弹窗')
           .fontColor(Color.Black)
@@ -84,12 +84,11 @@ export struct DiaLogComp {
       .borderRadius(8)
       .backgroundColor(Color.White)
       .padding({ top: 28, left: 32, right: 32, bottom: 20 })
-    }
-
+    // }
   }
 }
 
 @Builder
 export function DiaLogCompBuilder(_: string, param: NavDiaLogModel){
-  DiaLogComp({ param: param.param, controller: param.control })
+  DiaLogComp({ param: param.param, controller: param.control, container: param.builder })
 }

+ 3 - 3
commons/basic/src/main/ets/components/DiaLogComp/DiaLogSheetComp.ets

@@ -6,7 +6,7 @@ export struct DiaLogSheetComp {
   @Param controller?: DiaLogSheetControl = undefined
   @Param params: Array<BasicType> = []
 
-  @BuilderParam container: (_: () => void) => void = this.containerComp
+  @BuilderParam container: () => void = this.containerComp
 
   control: DiaLogSheetControl = new DiaLogSheetControl(this.getUIContext())
 
@@ -29,7 +29,7 @@ export struct DiaLogSheetComp {
 
         Column() {
           Column(){
-            this.containerComp()
+            this.container()
           }
           .onAreaChange((o, n) => {
             this.control.containerH = n.height as number
@@ -102,5 +102,5 @@ export struct DiaLogSheetComp {
 
 @Builder
 export function DiaLogSheetCompBuilder(_: string, params: NavDiaLogModel){
-  DiaLogSheetComp({ params: params.params, controller: params?.control as DiaLogSheetControl })
+  DiaLogSheetComp({ params: params.params, controller: params?.control as DiaLogSheetControl, container: params.builder })
 }

+ 1 - 0
commons/basic/src/main/ets/models/NavDiaLogModel.ets

@@ -4,4 +4,5 @@ export interface NavDiaLogModel {
   param?: BasicType,
   params?: Array<BasicType>,
   control?: DiaLogCompControl | DiaLogSheetControl
+  builder?: () => void;
 }

+ 0 - 20
commons/basic/src/main/ets/pages/Index.ets

@@ -1,20 +0,0 @@
-@Entry
-@Component
-struct Index {
-  @State message: string = 'Hello World';
-
-  build() {
-    Row() {
-      Column() {
-        Text(this.message)
-          .fontSize(10)
-          .fontWeight(FontWeight.Bold)
-          .onClick(() => {
-            this.message = 'Welcome';
-          })
-      }
-      .width('100%')
-    }
-    .height('100%')
-  }
-}

+ 2 - 2
commons/basic/src/main/ets/utils/arkts/utils/YTRouter.ets

@@ -113,12 +113,12 @@ class YTRouter extends NavPathStack {
   }
 
   // 中心弹窗
-  router2CenterDialog(param: NavDiaLogModel, callBack: Callback<PopInfo>) {
+  router2CenterDialog(param: NavDiaLogModel, callBack?: Callback<PopInfo>) {
     this.pushPathByName('DiaLogComp', param, callBack, false)
   }
 
   // 底部弹窗
-  router2BottomDialog(param: NavDiaLogModel, callBack: Callback<PopInfo>) {
+  router2BottomDialog(param: NavDiaLogModel, callBack?: Callback<PopInfo>) {
     this.pushPathByName('DiaLogSheetComp', param, callBack, false)
   }
 }

+ 0 - 1
commons/basic/src/main/module.json5

@@ -8,6 +8,5 @@
       "phone"
     ],
     "deliveryWithInstall": true,
-    "pages": "$profile:main_pages"
   }
 }

+ 0 - 5
commons/basic/src/main/resources/base/profile/main_pages.json

@@ -1,5 +0,0 @@
-{
-  "src": [
-    "pages/Index"
-  ]
-}

+ 121 - 0
features/feature/src/main/ets/components/AddressComp.ets

@@ -0,0 +1,121 @@
+import { DiaLogSheetControl, YTAvoid } from 'basic';
+import { CustomTextStyle } from '../style/CustomTextStyle';
+import { buttonComp } from './BuilderIndex';
+
+
+@ComponentV2
+export struct AddressComp{
+  // @Param @Require param: BasicType
+  @Param @Require control: DiaLogSheetControl
+
+  @Local safeBottom: number = AppStorage.get(YTAvoid.SAFE_BOTTOM_KEY) as number
+  @Local selectIndex: number = 0
+
+  build() {
+    Column(){
+      Row(){
+        Text('选择地址')
+          .fontSize(16)
+          .fontWeight(500)
+          .fontColor('#FF000000')
+
+        Image($r('[basic].media.icon_close'))
+          .width(22).aspectRatio(1)
+          .onClick(() => { this.control._onBackPress() })
+      }.width('100%')
+      .backgroundColor(Color.White)
+      .justifyContent(FlexAlign.SpaceBetween)
+      .borderRadius({topLeft: 12, topRight: 12})
+      .padding({left: 18, right: 18, top: 14, bottom: 14})
+
+      Column({space: 18}){
+        ForEach(new Array(3).fill(''), (item: string, index) => {
+          this.addressItem(index)
+        })
+      }.width('100%')
+      .backgroundColor('#F7F9FA')
+      .padding({top: 18, bottom: 18, left: 15, right: 15})
+
+      Row(){
+        buttonComp(
+          '添加收件地址',
+          '100%',
+          10,
+          new CustomTextStyle({size: 18, weight: 400}),
+          () => {}
+        )
+      }.width('100%')
+      .backgroundColor(Color.White)
+      .padding({ bottom: this.safeBottom, top: 10, left: 16, right: 16 })
+    }
+    .width('100%')
+    .backgroundColor(Color.Transparent)
+  }
+
+  @Builder
+  addressItem(index: number){
+    RelativeContainer(){
+      Row(){
+        Image($r('[basic].media.icon_location')).width(24).aspectRatio(1)
+
+        Column({space: 2}){
+          Text('福建省厦门市火炬园高新区火炬园路321号韩菲诗.诚享大厦304室内')
+            .fontSize(14)
+            .fontWeight(400)
+            .fontColor('#FF000000')
+
+          Row(){
+            Text('占三峰')
+              .fontSize(14)
+              .fontWeight(500)
+              .fontColor('#FF000000')
+            Text('13598728343')
+              .fontSize(14)
+              .fontWeight(500)
+              .fontColor('#FF000000')
+          }
+        }
+        .layoutWeight(1)
+        .margin({left: 11, right: 19})
+        .alignItems(HorizontalAlign.Start)
+
+        if(this.selectIndex == index) {
+          Image($r('[basic].media.icon_select'))
+            .width(15).aspectRatio(1)
+        } else {
+          Row()
+            .borderRadius(15)
+            .border({width: 1})
+            .width(15).aspectRatio(1)
+        }
+      }.width('100%').height('100%')
+      .borderRadius(16)
+      .alignItems(VerticalAlign.Center)
+      .padding({left: 16, right: 16, top: 18, bottom: 18})
+      .alignRules({
+        left: {anchor: '__container__', align: HorizontalAlign.Start},
+        top: {anchor: '__container__', align: VerticalAlign.Top}
+      })
+
+      if(0 == index){
+        Text('默认')
+        .fontSize(12)
+        .fontWeight(500)
+        .fontColor(Color.White)
+        .backgroundColor('#FFFFC500')
+        .padding({left: 11, top: 4, right: 11, bottom: 4})
+        .borderRadius({bottomLeft: 0, topLeft: 16, topRight: 0, bottomRight: 16})
+        .alignRules({
+          right: {anchor: '__container__', align: HorizontalAlign.End},
+          bottom: {anchor: '__container__', align: VerticalAlign.Bottom}
+        })
+
+      }
+    }.width('100%')
+    .height(100)
+    .borderRadius(16)
+    .backgroundColor(Color.White)
+    .onClick(() => { this.selectIndex = index })
+    .border({width: 1, color: 0 == index ? '#FFFECF2F' : '#FF000000'})
+  }
+}

+ 23 - 2
features/feature/src/main/ets/pages/OrderDetailPage.ets

@@ -1,4 +1,5 @@
-import { RouterPage, YTAvoid, YTHeader, YTRequest, yTRouter } from 'basic'
+import { DiaLogSheetControl, RouterPage, YTAvoid, YTHeader, yTRouter } from 'basic'
+import { AddressComp } from '../components/AddressComp'
 import { buttonComp } from '../components/BuilderIndex'
 import { CustomTextStyle } from '../style/CustomTextStyle'
 
@@ -7,6 +8,15 @@ import { CustomTextStyle } from '../style/CustomTextStyle'
 struct OrderDetailPage {
   safeBottom: number = AppStorage.get(YTAvoid.SAFE_BOTTOM_KEY) as number
 
+  // 打开选择地址弹窗
+  openAddressDialog() {
+    let control: DiaLogSheetControl = new DiaLogSheetControl(this.getUIContext())
+    yTRouter.router2BottomDialog({
+      control: control,
+      builder: () => { this.AddressSelection(control) },
+    })
+  }
+
   build() {
     NavDestination() {
       Column() {
@@ -42,7 +52,9 @@ struct OrderDetailPage {
               .padding({left: 16, right: 16, top: 18, bottom: 18})
             }
             .borderRadius(8)
+            .border({width: 2})
             .backgroundColor(Color.White)
+            .onClick(() => { this.openAddressDialog() })
 
             // 租借的图书
             ListItem(){
@@ -74,6 +86,7 @@ struct OrderDetailPage {
               .padding({left: 16, right: 16, top: 9, bottom: 9})
             }
             .borderRadius(8)
+            .border({width: 2})
             .backgroundColor(Color.White)
 
             // 订单信息
@@ -102,6 +115,7 @@ struct OrderDetailPage {
               .padding({left: 16, right: 16, top: 13, bottom: 13})
             }
             .borderRadius(8)
+            .border({width: 2})
             .backgroundColor(Color.White)
 
             // 备注
@@ -121,6 +135,7 @@ struct OrderDetailPage {
               .padding(16)
             }
             .borderRadius(8)
+            .border({width: 2})
             .backgroundColor(Color.White)
           }.width('100%').height('100%')
           .scrollBar(BarState.Off)
@@ -142,6 +157,7 @@ struct OrderDetailPage {
         .backgroundColor(Color.White)
         .alignItems(VerticalAlign.Center)
         .justifyContent(FlexAlign.SpaceBetween)
+        .shadow({radius: 5, offsetY: 5})
         .padding({bottom: this.safeBottom, top: 10, left: 15, right: 15})
       }
       .width('100%')
@@ -150,9 +166,14 @@ struct OrderDetailPage {
     }
     .hideTitleBar(true)
   }
-}
 
 
+  @Builder
+  AddressSelection(control: DiaLogSheetControl) {
+    AddressComp({control: control})
+  }
+}
+
 @Builder
 function OrderDetailBuilder() {
   OrderDetailPage()

+ 57 - 4
features/user/src/main/ets/pages/SettingPage.ets

@@ -5,12 +5,10 @@ import {
   userInfo,
   UserInfo,
   YTAvoid,
-  YTButton,
   YTHeader,
   YTLog,
   YTPhotoHelper,
   yTRouter,
-  yTToast,
   YTUserRequest
 } from 'basic'
 
@@ -108,10 +106,12 @@ struct SettingPage {
   // 打开名称修改弹窗
   openReviseNameBuilder() {
     let control = new DiaLogCompControl(this.getUIContext())
-    control.diaLogType = 'ReviseName'
     yTRouter.router2CenterDialog({
       param: { text: this.userInfo.getName() ?? this.userInfo.getPhoneNumber() ?? this.userInfo.getId()?.toString() },
-      control: control
+      control: control,
+      builder: () => {
+        this.ReviseName({ text: this.userInfo.getName() ?? this.userInfo.getPhoneNumber() ?? this.userInfo.getId()?.toString() }, control)
+      }
     }, (info: PopInfo) => {
       let ans = info.result as string
       YTUserRequest.changeNickname(ans, () => {
@@ -216,4 +216,57 @@ struct SettingPage {
     .borderRadius(8)
     .backgroundColor(Color.White)
   }
+
+  @Builder
+  ReviseName(param: BasicType, control: DiaLogCompControl){
+  Column(){
+    Text('宝贝昵称')
+      .fontSize(16)
+      .fontWeight(600)
+      .fontColor('#FF000000')
+
+    TextInput({text: param.text})
+      .padding(10)
+      .borderRadius(7)
+      .backgroundColor('#F5F7F5')
+      .onChange((text) => {
+        param.text = text
+      })
+      .margin({top: 17})
+
+    Row({space: 42}){
+      Text('取消')
+        .borderRadius(22)
+        .fontColor('#FF000000')
+        .backgroundColor('#FFF5F7F5')
+        .padding({top: 10, left: 36, right: 36, bottom: 10})
+        .onClick(() => {
+          control._onBackPress()
+        })
+
+      Text('保存')
+        .borderRadius(22)
+        .fontColor('#FF000000')
+        .backgroundColor('#FFFECF2F')
+        .padding({top: 10, left: 36, right: 36, bottom: 10})
+        .onClick(() => {
+          if (!param.text) {
+            IBestToast.show({
+              type: "warning",
+              message: "昵称不能为空"
+            })
+            return
+          }
+          control._onBackPress(param.text)
+        })
+    }
+    .margin({top: 12})
+  }
+  .width(312)
+  .height(158)
+  .borderRadius(12)
+  .backgroundColor(Color.White)
+  .alignItems(HorizontalAlign.Center)
+  .padding({left: 32, right: 32, top: 16, bottom: 8})
+}
 }