Browse Source

feat: 完成确认订单页面的相关校验

YuJing 1 month ago
parent
commit
5a6a6bbb4a

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

@@ -177,9 +177,8 @@ class YTRouter extends NavPathStack {
   }
 
   // 进入订单详情确认页
-  // @param params OrderDetailModel
-  router2OrderDetailPage(params: ESObject){
-    this.pushPathByName('OrderDetailPage', params)
+  router2OrderOrderConfirmPage(params: ESObject){
+    this.pushPathByName('OrderConfirmPage', params)
   }
 
   // 进入搜索结果页

+ 341 - 0
features/feature/src/main/ets/pages/Order/OrderConfirmPage.ets

@@ -0,0 +1,341 @@
+import { BasicType, BookItem, DiaLogSheetControl, YTHeader, yTRouter } from 'basic'
+import { AddressComp } from '../../components/AddressComp'
+import { AddressItemComp } from '../../components/AddressItemComp'
+import { buttonComp } from '../../components/BuilderIndex'
+import { Address } from '../../model/Address'
+import { AddressAddPageState, OrderStatus } from '../../model/EnumState'
+import { OrderDetailModel } from '../../model/RouterModel'
+import { CustomTextStyle } from '../../style/CustomTextStyle'
+import { OrderConfirmViewModel } from '../viewModel/OrderConfirmViewModel'
+
+/**
+ * 订单详情 - 订单校验页面
+ */
+// OrderDetailPage
+@ComponentV2
+struct OrderConfirmPage {
+  @Param @Require param: OrderDetailModel
+
+  // 勿改
+  vm: OrderConfirmViewModel = {} as ESObject
+
+  // 打开选择地址弹窗
+  openAddressDialog() {
+    let control: DiaLogSheetControl = new DiaLogSheetControl(this.getUIContext(), false, false)
+    yTRouter.router2BottomDialog({
+      control: control,
+      builder: () => { this.AddressSelection(control, this.vm.address.id!) },
+    }, (info) => {
+      let ans: Address = info.result as Address
+
+      this.vm.setAddress(ans)
+
+      console.log(`ans = ${JSON.stringify(ans)}`)
+    })
+  }
+
+  aboutToAppear(): void {
+    this.vm = new OrderConfirmViewModel(this.param)
+  }
+
+  build() {
+    NavDestination() {
+      Column() {
+        YTHeader({ defaultStyle: {title:'订单详情'}, bgc: Color.White })
+
+        Column(){
+          List({space: 16}){
+            ListItem()
+
+            if(this.vm.orderStatus == OrderStatus.UNCONFIRMED) {
+              /** 地址栏 */
+              this.AddressBuilder()
+
+              /** 租借的图书 */
+              this.OrderListBuilder()
+
+              /** 订单信息 */
+              this.OrderInfoBuilder()
+
+              /** 支付方式 */
+              this.PayMethodBuilder()
+
+              /** 备注 */
+              this.RemarkBuilder()
+            } else {
+              /** 订单状态信息 */
+              this.OrderStatusBuilder()
+
+              /** 订单信息 */
+              this.OrderPayBuilder()
+            }
+
+            ListItem()
+          }.width('100%').height('100%')
+          .scrollBar(BarState.Off)
+          .padding({left: 15, right: 15})
+        }.width('100%').layoutWeight(1)
+
+        Row(){
+          if(this.vm.orderStatus == OrderStatus.UNCONFIRMED) {
+            Text(){
+              Span('应付:')
+              Span(`¥${this.vm.totalPrice.toFixed(2)}`).fontColor('#FFFF0000').fontSize(20)
+            }
+            .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF000000' }))
+
+            buttonComp('提交订单', 143, 10, new CustomTextStyle({size: 18}), () => {
+              this.vm.submitOrder()
+            })
+          } else {
+            buttonComp('联系客服', 143, 10, new CustomTextStyle({size: 18}), () => {
+              this.vm.gotoCustomerService()
+            })
+          }
+        }
+        .width('100%')
+        .backgroundColor(Color.White)
+        .alignItems(VerticalAlign.Center)
+        .justifyContent(FlexAlign.SpaceBetween)
+        .shadow({radius: 5, offsetY: 5})
+        .padding({bottom: this.vm.safeBottom, top: 10, left: 15, right: 15})
+      }
+      .width('100%')
+      .height('100%')
+      .backgroundColor('#F7F9FA')
+    }
+    .hideTitleBar(true)
+  }
+
+
+  /** 地址栏 */
+  @Builder
+  AddressBuilder() {
+    ListItem(){
+      // todo 订单地址校验
+      if(this.vm.address?.phone) {
+        AddressItemComp({type: 0, address: this.vm.address, click: () => { this.openAddressDialog() }})
+      } else {
+        Row(){
+          Text('+ 添加收件人信息')
+            .attributeModifier(new CustomTextStyle({ size: 16, weight: 500 }))
+        }.width('100%')
+        .borderRadius(8)
+        .border({width: 2})
+        .padding({top: 30, bottom: 30})
+        .justifyContent(FlexAlign.Center)
+        .onClick(() => { this.vm.gotoAddAddressPage() })
+      }
+    }
+    .backgroundColor(Color.White)
+  }
+
+  /** 订单状态信息 */
+  @Builder
+  OrderStatusBuilder() {
+    ListItem(){
+      Column({space: 5}){
+        Text('待支付')
+          .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#FF000000' }))
+
+        Text('图书正在检测消毒,尽快发货~')
+          .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF444444' }))
+      }.width('100%')
+      .alignItems(HorizontalAlign.Start)
+      .padding({left: 16, right: 16, top: 18, bottom: 18})
+    }
+    .borderRadius(8)
+    .border({width: 2})
+    .backgroundColor(Color.White)
+  }
+
+  /** 租借图书列表 */
+  @Builder
+  OrderListBuilder() {
+    ListItem(){
+      Column({space: 10}){
+        Row({space: 10}){
+          Text('租借图书')
+            .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#FF000000' }))
+
+          Text(`共${this.vm.bookList.length}件`)
+            .attributeModifier(new CustomTextStyle({ size: 12, weight: 500, color: '#80000000' }))
+        }
+
+        List({space: 15}){
+          ForEach(this.vm.bookList, (item: BookItem, index) => {
+            ListItem(){
+              Image(item.coverUrl)
+                .width(63)
+                .height(81)
+                .borderRadius(6)
+                .backgroundColor('#FFFECF2F')
+                .alt($r('[basic].media.png_defaultBook'))
+            }
+          })
+        }.width("100%").height(81)
+        .scrollBar(BarState.Off)
+        .listDirection(Axis.Horizontal)
+      }
+      .width('100%')
+      .alignItems(HorizontalAlign.Start)
+      .padding({left: 16, right: 16, top: 9, bottom: 9})
+    }
+    .borderRadius(8)
+    .border({width: 2})
+    .backgroundColor(Color.White)
+  }
+
+  /** 订单信息栏 */
+  @Builder
+  OrderInfoBuilder(needSubtotal: boolean = true) {
+    ListItem(){
+      Column({space: 16}){
+        ForEach(this.vm.forEach, (item: BasicType, index) => {
+          Row(){
+            Text(item.text)
+              .attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF666666' }))
+
+            Text(item.message)
+              .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF333333' }))
+          }.width('100%').justifyContent(FlexAlign.SpaceBetween)
+        })
+
+
+        if(needSubtotal){
+          Divider().height(1).width('100%').backgroundColor('#FF666666')
+
+          Row(){
+            Text('小计')
+              .attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF666666' }))
+
+            Text(`¥${this.vm.totalPrice.toFixed(2)}`)
+              .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF333333' }))
+          }.width('100%').justifyContent(FlexAlign.SpaceBetween)
+        }
+      }
+      .padding({left: 16, right: 16, top: 13, bottom: 13})
+    }
+    .borderRadius(8)
+    .border({width: 2})
+    .backgroundColor(Color.White)
+  }
+
+  /** 支付方法栏 */
+  @Builder
+  PayMethodBuilder() {
+    ListItem(){
+      Column({space: 16}){
+        Text('支付方式')
+          .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#000000' }))
+
+        Divider().height(1).width('100%').backgroundColor('#FF666666')
+
+        Column({space: 16}){
+          ForEach(this.vm.payWayList, (item: BasicType, index) => {
+            Row(){
+              Row({space: 5}){
+                Image(item.src)
+                  .width(20)
+                  .aspectRatio(1)
+
+                Text(item.text)
+                  .attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#666666' }))
+              }
+
+              Row(){
+                if(this.vm.payWay == index){
+                  Image($r('[basic].media.icon_selectSvg'))
+                    .fillColor(item.color)
+                }
+              }
+              .width(14)
+              .aspectRatio(1)
+              .borderRadius(14)
+              .border({width: this.vm.payWay == index ? 0 : 1})
+            }
+            .width('100%')
+            .justifyContent(FlexAlign.SpaceBetween)
+            .onClick(() => { this.vm.changePayWay(index) })
+          })
+        }.width('100%')
+      }
+      .justifyContent(FlexAlign.Start)
+      .alignItems(HorizontalAlign.Start)
+      .padding({left: 16, right: 16, top: 9, bottom: 9})
+    }
+    .borderRadius(8)
+    .border({width: 2})
+    .backgroundColor(Color.White)
+  }
+
+  /** 备注栏 */
+  @Builder
+  RemarkBuilder() {
+    ListItem(){
+      Row({space: 20}){
+        Text('备注')
+          .attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF666666' }))
+
+        TextInput({placeholder: '请输入您的留言', text: $$this.vm.remark})
+          .padding(0)
+          .borderRadius(0)
+          .layoutWeight(1)
+          .border({width: 0})
+          .textAlign(TextAlign.End)
+          .backgroundColor(Color.Transparent)
+      }.width('100%').justifyContent(FlexAlign.SpaceBetween)
+      .padding(16)
+    }
+    .borderRadius(8)
+    .border({width: 2})
+    .backgroundColor(Color.White)
+  }
+
+  // 订单实付
+  @Builder
+  OrderPayBuilder() {
+    ListItem(){
+      Column({space: 15}){
+        Row(){
+          Text('租借时间')
+            .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF444444' }))
+
+          Text('2024-01-05至20225-01-04')
+            .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF444444' }))
+        }.width('100%')
+        .justifyContent(FlexAlign.SpaceBetween)
+
+        Row(){
+          Text('实付')
+            .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#FF000000' }))
+
+          Text('¥219.80')
+            .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#FF000000' }))
+        }.width('100%')
+        .justifyContent(FlexAlign.SpaceBetween)
+
+        Image($r('[basic].media.ic_public_arrow_left'))
+          .rotate({angle: 270})
+          .fillColor('#ff585757')
+          .width(24).aspectRatio(1)
+      }.width('100%')
+      .alignItems(HorizontalAlign.Center)
+      .padding({left: 19, top: 12, right: 19, bottom: 12})
+    }
+    .borderRadius(8)
+    .border({width: 2})
+    .backgroundColor(Color.White)
+  }
+
+  /** 地址选择弹窗 */
+  @Builder
+  AddressSelection(control: DiaLogSheetControl, addressId: string) {
+    AddressComp({control: control, addressId: addressId})
+  }
+}
+
+@Builder
+function OrderConfirmBuilder(_: string, param: OrderDetailModel) {
+  OrderConfirmPage({ param })
+}

+ 6 - 332
features/feature/src/main/ets/pages/Order/OrderDetailPage.ets

@@ -1,346 +1,20 @@
-import { BasicType, BookItem, DiaLogSheetControl, YTHeader, yTRouter } from 'basic'
-import { AddressComp } from '../../components/AddressComp'
-import { AddressItemComp } from '../../components/AddressItemComp'
-import { buttonComp } from '../../components/BuilderIndex'
-import { Address } from '../../model/Address'
-import { AddressAddPageState, OrderStatus } from '../../model/EnumState'
-import { OrderDetailModel } from '../../model/RouterModel'
-import { CustomTextStyle } from '../../style/CustomTextStyle'
-import { OrderDetailViewModel } from '../viewModel/OrderDetailViewModel'
-
-/**
- * 订单详情 - 订单校验页面
- */
+// 订单详情页面
 @ComponentV2
 struct OrderDetailPage {
-  @Param @Require vm: OrderDetailViewModel
-
-  // 打开选择地址弹窗
-  openAddressDialog() {
-    let control: DiaLogSheetControl = new DiaLogSheetControl(this.getUIContext(), false, false)
-    yTRouter.router2BottomDialog({
-      control: control,
-      builder: () => { this.AddressSelection(control, this.vm.address.id!) },
-    }, (info) => {
-      let ans: Address = info.result as Address
-
-      this.vm.address = ans
-
-      console.log(`ans = ${JSON.stringify(ans)}`)
-    })
-  }
-
-  // 前往地址添加页
-  gotoAddAddressPage() {
-    yTRouter.router2IncreaseAddressPage(AddressAddPageState.ADD_AND_USE, (info) => {
-      let ans = info.result as Address
-      this.vm.address = ans
-      console.log(`ans = ${JSON.stringify(ans)}`)
-    })
-  }
-
-  aboutToAppear(): void {
-
-  }
+  // @Local vm: OrderDetailPageViewModel = new OrderDetailPageViewModel();
 
   build() {
     NavDestination() {
       Column() {
-        YTHeader({ defaultStyle: {title:'订单详情'}, bgc: Color.White })
-
-        Column(){
-          List({space: 16}){
-            ListItem()
-
-            if(this.vm.orderStatus == OrderStatus.UNCONFIRMED) {
-              /** 地址栏 */
-              this.AddressBuilder()
-
-              /** 租借的图书 */
-              this.OrderListBuilder()
-
-              /** 订单信息 */
-              this.OrderInfoBuilder()
-
-              /** 支付方式 */
-              this.PayMethodBuilder()
-
-              /** 备注 */
-              this.RemarkBuilder()
-            } else {
-              /** 订单状态信息 */
-              this.OrderStatusBuilder()
-
-              /** 订单信息 */
-              this.OrderPayBuilder()
-            }
 
-            ListItem()
-          }.width('100%').height('100%')
-          .scrollBar(BarState.Off)
-          .padding({left: 15, right: 15})
-        }.width('100%').layoutWeight(1)
-
-        Row(){
-          if(this.vm.orderStatus == OrderStatus.UNCONFIRMED) {
-            Text(){
-              Span('应付:')
-              Span(`¥${this.vm.totalPrice.toFixed(2)}`).fontColor('#FFFF0000').fontSize(20)
-            }
-            .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF000000' }))
-
-            buttonComp('提交订单', 143, 10, new CustomTextStyle({size: 18}), () => {
-              this.vm.submitOrder()
-            })
-          } else {
-            buttonComp('联系客服', 143, 10, new CustomTextStyle({size: 18}), () => {
-              this.vm.gotoCustomerService()
-            })
-          }
-        }
-        .width('100%')
-        .backgroundColor(Color.White)
-        .alignItems(VerticalAlign.Center)
-        .justifyContent(FlexAlign.SpaceBetween)
-        .shadow({radius: 5, offsetY: 5})
-        .padding({bottom: this.vm.safeBottom, top: 10, left: 15, right: 15})
       }
-      .width('100%')
-      .height('100%')
-      .backgroundColor('#F7F9FA')
     }
     .hideTitleBar(true)
-  }
-
-
-  /** 地址栏 */
-  @Builder
-  AddressBuilder() {
-    ListItem(){
-      // todo 订单地址校验
-      if(this.vm.address?.phone) {
-        AddressItemComp({type: 0, address: this.vm.address, click: () => { this.openAddressDialog() }})
-      } else {
-        Row(){
-          Text('+ 添加收件人信息')
-            .attributeModifier(new CustomTextStyle({ size: 16, weight: 500 }))
-        }.width('100%')
-        .borderRadius(8)
-        .border({width: 2})
-        .padding({top: 30, bottom: 30})
-        .justifyContent(FlexAlign.Center)
-        .onClick(() => { this.gotoAddAddressPage() })
-      }
-    }
-    .backgroundColor(Color.White)
-  }
-
-  /** 订单状态信息 */
-  @Builder
-  OrderStatusBuilder() {
-    ListItem(){
-      Column({space: 5}){
-        Text('待支付')
-          .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#FF000000' }))
-
-        Text('图书正在检测消毒,尽快发货~')
-          .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF444444' }))
-      }.width('100%')
-      .alignItems(HorizontalAlign.Start)
-      .padding({left: 16, right: 16, top: 18, bottom: 18})
-    }
-    .borderRadius(8)
-    .border({width: 2})
-    .backgroundColor(Color.White)
-  }
-
-  /** 租借图书列表 */
-  @Builder
-  OrderListBuilder() {
-    ListItem(){
-      Column({space: 10}){
-        Row({space: 10}){
-          Text('租借图书')
-            .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#FF000000' }))
-
-          Text(`共${this.vm.bookList.length}件`)
-            .attributeModifier(new CustomTextStyle({ size: 12, weight: 500, color: '#80000000' }))
-        }
-
-        List({space: 15}){
-          ForEach(this.vm.bookList, (item: BookItem, index) => {
-            ListItem(){
-              Image(item.coverUrl)
-                .width(63)
-                .height(81)
-                .borderRadius(6)
-                .backgroundColor('#FFFECF2F')
-                .alt($r('[basic].media.png_defaultBook'))
-            }
-          })
-        }.width("100%").height(81)
-        .scrollBar(BarState.Off)
-        .listDirection(Axis.Horizontal)
-      }
-      .width('100%')
-      .alignItems(HorizontalAlign.Start)
-      .padding({left: 16, right: 16, top: 9, bottom: 9})
-    }
-    .borderRadius(8)
-    .border({width: 2})
-    .backgroundColor(Color.White)
-  }
-
-  /** 订单信息栏 */
-  @Builder
-  OrderInfoBuilder(needSubtotal: boolean = true) {
-    ListItem(){
-      Column({space: 16}){
-        ForEach(this.vm.forEach, (item: BasicType, index) => {
-          Row(){
-            Text(item.text)
-              .attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF666666' }))
-
-            Text(item.message)
-              .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF333333' }))
-          }.width('100%').justifyContent(FlexAlign.SpaceBetween)
-        })
-
-
-        if(needSubtotal){
-          Divider().height(1).width('100%').backgroundColor('#FF666666')
-
-          Row(){
-            Text('小计')
-              .attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF666666' }))
-
-            Text(`¥${this.vm.totalPrice.toFixed(2)}`)
-              .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF333333' }))
-          }.width('100%').justifyContent(FlexAlign.SpaceBetween)
-        }
-      }
-      .padding({left: 16, right: 16, top: 13, bottom: 13})
-    }
-    .borderRadius(8)
-    .border({width: 2})
-    .backgroundColor(Color.White)
-  }
-
-  /** 支付方法栏 */
-  @Builder
-  PayMethodBuilder() {
-    ListItem(){
-      Column({space: 16}){
-        Text('支付方式')
-          .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#000000' }))
-
-        Divider().height(1).width('100%').backgroundColor('#FF666666')
-
-        Column({space: 16}){
-          ForEach(this.vm.payWayList, (item: BasicType, index) => {
-            Row(){
-              Row({space: 5}){
-                Image(item.src)
-                  .width(20)
-                  .aspectRatio(1)
-
-                Text(item.text)
-                  .attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#666666' }))
-              }
-
-              Row(){
-                if(this.vm.payWay == index){
-                  Image($r('[basic].media.icon_selectSvg'))
-                    .fillColor(item.color)
-                }
-              }
-              .width(14)
-              .aspectRatio(1)
-              .borderRadius(14)
-              .border({width: this.vm.payWay == index ? 0 : 1})
-            }
-            .width('100%')
-            .justifyContent(FlexAlign.SpaceBetween)
-            .onClick(() => { this.vm.changePayWay(index) })
-          })
-        }.width('100%')
-      }
-      .justifyContent(FlexAlign.Start)
-      .alignItems(HorizontalAlign.Start)
-      .padding({left: 16, right: 16, top: 9, bottom: 9})
-    }
-    .borderRadius(8)
-    .border({width: 2})
-    .backgroundColor(Color.White)
-  }
-
-  /** 备注栏 */
-  @Builder
-  RemarkBuilder() {
-    ListItem(){
-      Row({space: 20}){
-        Text('备注')
-          .attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF666666' }))
-
-        TextInput({placeholder: '请输入您的留言', text: $$this.vm.remark})
-          .padding(0)
-          .borderRadius(0)
-          .layoutWeight(1)
-          .border({width: 0})
-          .textAlign(TextAlign.End)
-          .backgroundColor(Color.Transparent)
-      }.width('100%').justifyContent(FlexAlign.SpaceBetween)
-      .padding(16)
-    }
-    .borderRadius(8)
-    .border({width: 2})
-    .backgroundColor(Color.White)
-  }
-
-  // 订单实付
-  @Builder
-  OrderPayBuilder() {
-    ListItem(){
-      Column({space: 15}){
-        Row(){
-          Text('租借时间')
-            .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF444444' }))
-
-          Text('2024-01-05至20225-01-04')
-            .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF444444' }))
-        }.width('100%')
-        .justifyContent(FlexAlign.SpaceBetween)
-
-        Row(){
-          Text('实付')
-            .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#FF000000' }))
-
-          Text('¥219.80')
-            .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#FF000000' }))
-        }.width('100%')
-        .justifyContent(FlexAlign.SpaceBetween)
-
-        Image($r('[basic].media.ic_public_arrow_left'))
-          .rotate({angle: 270})
-          .fillColor('#ff585757')
-          .width(24).aspectRatio(1)
-      }.width('100%')
-      .alignItems(HorizontalAlign.Center)
-      .padding({left: 19, top: 12, right: 19, bottom: 12})
-    }
-    .borderRadius(8)
-    .border({width: 2})
-    .backgroundColor(Color.White)
-  }
-
-  /** 地址选择弹窗 */
-  @Builder
-  AddressSelection(control: DiaLogSheetControl, addressId: string) {
-    AddressComp({control: control, addressId: addressId})
+    // .padding({ top: this.vm.safeTop })
   }
 }
 
 @Builder
-function OrderDetailBuilder(_: string, param: OrderDetailModel) {
-  OrderDetailPage({ vm: new OrderDetailViewModel(param)})
-}
+function OrderDetailPageBuilder() {
+  OrderDetailPage()
+}

+ 34 - 18
features/feature/src/main/ets/pages/viewModel/OrderDetailViewModel.ets → features/feature/src/main/ets/pages/viewModel/OrderConfirmViewModel.ets

@@ -1,14 +1,14 @@
-import { BasicType, BookItem, IBestToast, userInfo, YTAvoid, yTRouter } from 'basic'
+import { BasicType, BookItem, IBestToast, YTAvoid, yTRouter } from 'basic'
 import { OrderApi } from '../../apis/OrderApi'
 import { Address } from '../../model/Address'
 import { OrderStatus } from '../../model/EnumState'
-import { GetUnifiedPayInfoRequestData, OrderValidationData } from '../../model/OrderModelIndex'
+import { OrderValidationData } from '../../model/OrderModelIndex'
 import { OrderDetailModel } from '../../model/RouterModel'
 import { UserAddressStorage } from '../../model/Storage'
 import { AppStorageV2 } from '@kit.ArkUI'
 
 @ObservedV2
-export class OrderDetailViewModel{
+export class OrderConfirmViewModel{
   @Trace safeBottom: number = AppStorage.get(YTAvoid.SAFE_BOTTOM_KEY) as number
   // 订单状态
   @Trace orderStatus: OrderStatus
@@ -34,10 +34,6 @@ export class OrderDetailViewModel{
     deposit: 0,
     payWay: 2,
     postFee: 9.99,
-    userName: '占三峰',
-    phone: '13598728343',
-    address: '高新区火炬园路321号韩菲诗.诚享大厦304室内',
-    region: '福建-厦门-火炬园',
   }
 
   // 支付方式遍历
@@ -49,12 +45,18 @@ export class OrderDetailViewModel{
   constructor(param: OrderDetailModel) {
     this.orderStatus = param.status
 
-    if(param.status === OrderStatus.UNCONFIRMED) {
-      this.bookList = param.bookList
-      this.generateOrderDetail()
-    }
+    this.bookList = param.bookList
+    this.generateOrderDetail()
+  }
+
+  // 设置地址信息
+  setAddress(address: Address) {
+    this.address = address
 
-    this.address = this.addressConnect.addressList[0]
+    this.orderValidation.userName = address.userName
+    this.orderValidation.phone = address.phone
+    this.orderValidation.address = address.address
+    this.orderValidation.region = address.region
   }
 
   // 切换支付方式
@@ -62,9 +64,18 @@ export class OrderDetailViewModel{
     this.payWay = index
   }
 
+  // 前往地址添加页
+  gotoAddAddressPage() {
+    yTRouter.router2IncreaseAddressPage(undefined, (info) => {
+      let ans = info.result as Address
+      console.log(`ans = ${JSON.stringify(ans)}`)
+      this.setAddress(ans)
+    })
+  }
+
   /** 生成订单明细信息 */
-  generateOrderDetail() {
-    // 书本价格计算
+  async generateOrderDetail() {
+    // 1. 书本价格计算
     let total: number = 0.00
     this.bookList.forEach((item: BookItem, index) => {
       if(item.rentPerDay) {
@@ -73,7 +84,7 @@ export class OrderDetailViewModel{
       this.orderValidation.bookIds?.push(item.id!)
     })
 
-    // 生成明细
+    // 2. 生成明细 - UI 渲染数据
     this.forEach = [
       { text: '租借期限', message: '30天' },
       { text: '租借时间', message: '快递签收日起30天' },
@@ -82,11 +93,17 @@ export class OrderDetailViewModel{
       { text: '租借期限', message: '30天' },
     ]
 
-    // todo 在有地址列表 或 默认地址的情况下添加地址信息
 
-    // todo 订单校验数据结构整合
+    // 3. 订单校验数据结构整合
     this.totalPrice += total
     this.orderValidation.bookPrice = total
+
+
+    // 4. 初始化地址信息
+    if(this.addressConnect.addressList.length == 0){
+      await this.addressConnect.getUserAddressList()
+    }
+    this.setAddress(this.addressConnect.addressList[0])
   }
 
   /** 生成订单明细信息 */
@@ -100,7 +117,6 @@ export class OrderDetailViewModel{
     let ans: OrderValidationData = await OrderApi.checkOrder(this.orderValidation)
     console.log(`借阅结果数据结构 ans = ${JSON.stringify(ans)}`)
 
-
     yTRouter.router2InitiatePayPage(ans.id!)
   }
 

+ 6 - 31
features/feature/src/main/ets/view/MainView.ets

@@ -1,10 +1,9 @@
-import { AliPay, BasicType, BookItem, yTRouter } from "basic"
-import { tagItemComp } from "../components/BuilderIndex"
-import { DeerSearch } from "../components/DeerSearch"
-import { ytBuildComp } from "../components/ytComp/ytBuildComp"
-import { CustomTextStyle } from "../style/CustomTextStyle"
-import { MainViModel } from "./viewModel/MainViewModel"
-import common from "@ohos.app.ability.common"
+import { BasicType, BookItem, yTRouter } from 'basic'
+import { tagItemComp } from '../components/BuilderIndex'
+import { DeerSearch } from '../components/DeerSearch'
+import { ytBuildComp } from '../components/ytComp/ytBuildComp'
+import { CustomTextStyle } from '../style/CustomTextStyle'
+import { MainViModel } from './viewModel/MainViewModel'
 
 @ComponentV2
 export struct MainView {
@@ -14,30 +13,6 @@ export struct MainView {
     ytBuildComp(){
       RelativeContainer(){
         List(){
-          ListItem(){
-            Row({space: 20}){
-
-              Column(){
-                // Web({src: $rawfile('index.html'),controller: this.web})
-                //   .onRefreshAccessedHistory((event)=>{
-                //     console.log(`111111111 = ${JSON.stringify(111111111)}`)
-                //   })
-                Text('asdfasdf')
-                  .onClick(()=>{
-                    // yTRouter.pushPathByName
-                    (getContext(this) as common.UIAbilityContext).openLink('alipays://platformapi/startApp?appId=20000125&orderSuffix=h5_route_token%3D%22RZ54gBmd2erDuYtF1qBXxKZRBhBCyHmobilecashierRZ54%22%26is_h5_route%3D%22true%22%26h5_route_senior%3D%22true%22%26h5_route_date%3D%221762939090909%22%26h5_route_sign%3D%22cxKWtd2vsn5T%2Ftjj3VJlnvuJg%2BdhGCLdmvhhc4qCkRmElo7DF3TeLaQ1I95PqMGGEoVq%2B%2B%2FTxl%2FFXW2ej9XA1Vqj%2BO7oQsOkrXg%2BL26Q9hIBum0ieqBM6XLaOtZRwSmnlGP00bALeZx7bNLKjBke475areLjP%2FPPbk8yukL467DIi6uLDc88VpnaZlQvBEFNiPVVEdjrKqIZhPM6EK1BKvYDFNvgqxiYJc8prydf5VX%2FbgZQiQxQnp0Cl6UydZuvbQmhA2Lvr%2BlMv%2F3Mo6iarn6HIDe425vqib9f7Fs1wbzwV%2BttyxNoq58W%2F1n%2B92ZKyGvyOM1XyPAmlUvD%2FbtYQ97wo1SEubIqBypcYKLmDI4q5hE1Hrf31wMJKt%2FtGvbkvqGP1uvl2c8OKsf8WGnDgI5ZROzv%2ByedAV7qwRsRtV2EkNlG093iAzMt9S6spIU4lxgWzCpk3%2BrhWeciRK6sP9BGjpOArUvpDCN%2FCBQKXb%2BAy4WKUXrh719CcjsA5WsxRDCIrzkg5O40AwoFxpX%2Fuyu3rV4hgyAqx2%2Bp%2F%2F%2F%2Bd0Sr%2FSxwDSzy7cjQu0GnivwFys5X%2BA3uIUZ9NmF5sRDMxPP7c1V89ajLlqbIk62UshA5BcPjRK812Zsm8qtIuSxBZRoMqNA2K7YUtm1NtfQtTBcmahGx3zsmV2uy%2BC0oqRE%3D%22\n')
-                  })
-              }
-
-              Text('AliPay.launchPay')
-                .onClick(()=>{
-                  AliPay.launchPay('appId=20000125&orderSuffix=h5_route_token%3D%22RZ42h6OZuwA4DRMmT9dtuiCXi1z773mobilecashierRZ42%22%26is_h5_route%3D%22true%22%26h5_route_senior%3D%22true%22%26h5_route_date%3D%221762939818010%22%26h5_route_sign%3D%22LvtJ9OjEmMiS6I1FOCUms1MQz7HdQxlRU8g7R9ck92zBlcPQS0%2F4AHT%2BlGR1Yt8JDJqvCwys1ZAink5xU4lEwThTTyxjVu%2FIi%2FAOXjfhdHlHyXc8SOGBpmSue8%2BG2zJTyr8LHCeyBtGjRvhaXymDBav6%2FeIKyAAaUeeYbBeuBVgnUJQY4WPNXC5Mzh94v4gVjFqK%2Fdz%2BJlJ26jSwE6gOy9MSTwJNXiiEsHx1MVUWIbnIAEupjEiOd04kaClnpPwgu7BixGzoyB5loxeOk3JaqRiQ%2B%2FEVbgSKjxDcWznHQmKDVnWAOzdTDKn%2FoaPw3LfDTsDvwMeVXr27ZgdeWhURk7kvVzKOt6LyM6tZQ8bSrr3BtWEmP5v1IFpAiOSowg8%2Bm3Q1GIT%2BhhR7JTxlNEmzAzs7rARlto1871b5knz9fEOMR%2BLS%2B9WhYxF7oxirN94LnaITgB5lywGZ%2FQxqKImFMUftlhqJTsmU8GuQXza5bS0yMjFJGHa7si3tS41IPjje%2FpCMerwXyu%2BhTVXcNt75riP%2BwvXoECQ8MOQik36O%2FCpjOmITrBX2Gd1fLwKxr0PZ%2BVYIGJ%2FpMlNzKK0SHiAdGPHi4QBBiDaxkl7KFTwr3GT8cfEO7wnfMR8hgaGksiSCLg3GGWKnPGIgNPZ9FOOkj115AJ621VJ7Eh0cfZP6WuQ%3D%22')
-                })
-            }
-          }
-          .padding({top: 200})
-
-
           // logo
           ListItem(){
             Row({space: 14}){

+ 1 - 1
features/feature/src/main/ets/view/viewModel/ThirdViewModel.ets

@@ -99,7 +99,7 @@ export class ThirdViewModel{
 
     let param: OrderDetailModel = new OrderDetailModel()
     param.bookList = list
-    yTRouter.router2OrderDetailPage(param)
+    yTRouter.router2OrderOrderConfirmPage(param)
   }
 
 

+ 3 - 3
features/feature/src/main/resources/base/profile/router_map.json

@@ -36,9 +36,9 @@
       "buildFunction": "OrderManagementBuilder"
     },
     {
-      "name": "OrderDetailPage",
-      "pageSourceFile": "src/main/ets/pages/Order/OrderDetailPage.ets",
-      "buildFunction": "OrderDetailBuilder"
+      "name": "OrderConfirmPage",
+      "pageSourceFile": "src/main/ets/pages/Order/OrderConfirmPage.ets",
+      "buildFunction": "OrderConfirmBuilder"
     },
     {
       "name": "BorrowAnsPage",