|
|
@@ -1,20 +1,308 @@
|
|
|
-// 订单详情页面
|
|
|
+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'
|
|
|
+import { OrderDetailViewModel } from '../viewModel/OrderDetailViewModel'
|
|
|
+
|
|
|
+/**
|
|
|
+ * 订单详情
|
|
|
+ */
|
|
|
@ComponentV2
|
|
|
struct OrderDetailPage {
|
|
|
- // @Local vm: OrderDetailPageViewModel = new OrderDetailPageViewModel();
|
|
|
+ @Param @Require param: OrderDetailModel
|
|
|
+
|
|
|
+ // 勿改
|
|
|
+ vm: OrderDetailViewModel = {} as ESObject
|
|
|
+
|
|
|
+ aboutToAppear(): void {
|
|
|
+ this.vm = new OrderDetailViewModel(this.param)
|
|
|
+ }
|
|
|
|
|
|
build() {
|
|
|
NavDestination() {
|
|
|
Column() {
|
|
|
+ YTHeader({ defaultStyle: {title:'订单确认'}, bgc: Color.White })
|
|
|
+
|
|
|
+ Column(){
|
|
|
+ List({space: 16}){
|
|
|
+ ListItem()
|
|
|
+ /**
|
|
|
+ * 订单状态
|
|
|
+ */
|
|
|
+ this.OrderStatusBuilder()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 租借的图书
|
|
|
+ * */
|
|
|
+ this.OrderListBuilder()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单价格
|
|
|
+ */
|
|
|
+ if(!this.vm.isExpand) {
|
|
|
+ this.OrderPayBuilder()
|
|
|
+ } else {
|
|
|
+ this.OrderInfoBuilder()
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 地址栏
|
|
|
+ * */
|
|
|
+ this.AddressBuilder()
|
|
|
+
|
|
|
+ // 根据是否完成支付显示不同的表单
|
|
|
+ if(this.vm.status == OrderStatus.PENDING_PAYMENT) {
|
|
|
+ /**
|
|
|
+ * 支付方式
|
|
|
+ * */
|
|
|
+ this.PayMethodBuilder()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单信息
|
|
|
+ * */
|
|
|
+ this.OrderInfoBuilder(false)
|
|
|
+ ListItem()
|
|
|
+ }.width('100%').height('100%')
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .padding({left: 15, right: 15})
|
|
|
+ }.width('100%').layoutWeight(1)
|
|
|
+
|
|
|
+ // todo 不同订单下的按钮显示不同的
|
|
|
+ Row(){
|
|
|
+ buttonComp('联系客服', '100%', 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)
|
|
|
- // .padding({ top: this.vm.safeTop })
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /** 地址栏 */
|
|
|
+ @Builder
|
|
|
+ AddressBuilder() {
|
|
|
+ ListItem(){
|
|
|
+ // todo 订单地址校验
|
|
|
+ if(this.vm.address?.phone) {
|
|
|
+ AddressItemComp({type: 0, address: this.vm.address})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 订单状态信息 */
|
|
|
+ @Builder
|
|
|
+ OrderStatusBuilder() {
|
|
|
+ ListItem(){
|
|
|
+ Column({space: 5}){
|
|
|
+ Text(this.vm.getOrderStatusText(this.vm.status).text)
|
|
|
+ .attributeModifier(new CustomTextStyle({ size: 16, weight: 500, color: '#FF000000' }))
|
|
|
+
|
|
|
+ Text(this.vm.getOrderStatusText(this.vm.status).message)
|
|
|
+ .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(needSubtotal ? this.vm.forEach1 : this.vm.forEach2, (item: BasicType, index) => {
|
|
|
+ Row(){
|
|
|
+ Text(item.text)
|
|
|
+ .attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF666666' }))
|
|
|
+
|
|
|
+ if(item.type == 'Copy') {
|
|
|
+ Row({space: 15}){
|
|
|
+ Text(item.message)
|
|
|
+ .attributeModifier(new CustomTextStyle({size: 14, weight: 500, color: '#FF333333'}))
|
|
|
+
|
|
|
+ Text('复制')
|
|
|
+ .padding({left: 9})
|
|
|
+ .border({width: {left: 1}, color: '#C1C1C1'})
|
|
|
+ .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF333333'}))
|
|
|
+ .onClick(() => { this.vm.onCopyOrderNumber(item.message!) })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ 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}`)
|
|
|
+ .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
|
|
|
+ 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})
|
|
|
+ .onClick(() => {
|
|
|
+ this.vm.isExpand = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .borderRadius(8)
|
|
|
+ .border({width: 2})
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Builder
|
|
|
-function OrderDetailPageBuilder() {
|
|
|
- OrderDetailPage()
|
|
|
-}
|
|
|
+function OrderDetailBuilder(_: string, param: OrderDetailModel) {
|
|
|
+ OrderDetailPage({ param })
|
|
|
+}
|