|
|
@@ -0,0 +1,315 @@
|
|
|
+import { RouterPage, YTHeader } from 'basic';
|
|
|
+import { buttonComp } from '../components/BuilderIndex';
|
|
|
+import { OrderStatus } from '../model/OrderStatus';
|
|
|
+import { CustomTextStyle } from '../style/CustomTextStyle';
|
|
|
+import { OrderManagementViewModel } from './viewModel/OrderManagementViewModel';
|
|
|
+
|
|
|
+@ComponentV2
|
|
|
+@RouterPage
|
|
|
+struct OrderManagementPage {
|
|
|
+ @Local vm: OrderManagementViewModel = new OrderManagementViewModel();
|
|
|
+
|
|
|
+ aboutToAppear(): void {
|
|
|
+ this.vm.changeCategory(0)
|
|
|
+ }
|
|
|
+
|
|
|
+ build() {
|
|
|
+ NavDestination() {
|
|
|
+ Column() {
|
|
|
+ YTHeader({
|
|
|
+ defaultStyle: {title: '我的借阅'},
|
|
|
+ bgc: Color.White,
|
|
|
+ })
|
|
|
+
|
|
|
+ List({space: 22}){
|
|
|
+ ForEach(this.vm.categoryList, (item: string, index) => {
|
|
|
+ ListItem(){
|
|
|
+ Column(){
|
|
|
+ Text(item)
|
|
|
+ .zIndex(99)
|
|
|
+ .width(50)
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .onClick(() => { this.vm.changeCategory(index) })
|
|
|
+ .fontSize(16)
|
|
|
+ .fontWeight(600)
|
|
|
+ .fontColor(this.vm.categoryIndex == index ? '#FF111111' : '#FF777777')
|
|
|
+
|
|
|
+ if(this.vm.categoryIndex == index){
|
|
|
+ Image($r('[basic].media.icon_SelectBg'))
|
|
|
+ .width(45)
|
|
|
+ .height(16)
|
|
|
+ .margin({top:-10})
|
|
|
+ .transition(TransitionEffect.asymmetric(TransitionEffect.move(TransitionEdge.TOP), TransitionEffect.move(TransitionEdge.TOP)).animation({ duration: 100, curve: Curve.Smooth }))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .alignItems(HorizontalAlign.Center)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .height(50)
|
|
|
+ .width("100%")
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+ .listDirection(Axis.Horizontal)
|
|
|
+ .borderRadius({bottomLeft: 16, bottomRight: 16})
|
|
|
+ .padding({top: 10, left: 16, right: 16, bottom: 10})
|
|
|
+
|
|
|
+ Column(){
|
|
|
+ Tabs({controller: this.vm.tabControl, index: this.vm.categoryIndex}){
|
|
|
+ ForEach(this.vm.categoryList, (item: string, index) => {
|
|
|
+ TabContent(){
|
|
|
+ Refresh({refreshing: this.vm.isRefresh}){
|
|
|
+ if((this.vm.isRefresh && this.vm.isFirst) || this.vm.categoryIndex != index) {
|
|
|
+ Column({space: 16}){
|
|
|
+ ForEach(['', '', ''], (item: string, index) => {
|
|
|
+ ListItem(){
|
|
|
+ SkeletonComp()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }.width('100%').height('100%')
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
+ .padding({left: 15, right: 15, top: 14})
|
|
|
+ } else {
|
|
|
+ List({space: 16}){
|
|
|
+ ListItem()
|
|
|
+
|
|
|
+ ForEach(this.vm.dataSource, (item: string, index) => {
|
|
|
+ ListItem(){
|
|
|
+ OrderItemComp({orderStatus: index})
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .height('100%')
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .padding({left: 15, right: 15, bottom: this.vm.safeBottom})
|
|
|
+ .onReachEnd(() => { this.vm.onReachEnd() })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .padding(0)
|
|
|
+ .onRefreshing(() => {
|
|
|
+ this.vm.isRefresh = true
|
|
|
+ this.vm.onRefreshing()
|
|
|
+ })
|
|
|
+ }.padding(0)
|
|
|
+ })
|
|
|
+ }.barHeight(0)
|
|
|
+ .onChange((index: number) => {
|
|
|
+ this.vm.changeCategory(index)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .layoutWeight(1)
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .height('100%')
|
|
|
+ .backgroundColor('#F7F9FA')
|
|
|
+ }
|
|
|
+ .hideTitleBar(true)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Builder
|
|
|
+function OrderManagementBuilder() {
|
|
|
+ OrderManagementPage()
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@ComponentV2
|
|
|
+struct OrderItemComp{
|
|
|
+ @Param orderStatus: OrderStatus = OrderStatus.PENDING_PAYMENT;
|
|
|
+
|
|
|
+ getOrderStatusDes(status: OrderStatus): string {
|
|
|
+ switch (status) {
|
|
|
+ case OrderStatus.PENDING_PAYMENT:
|
|
|
+ return '待支付';
|
|
|
+ case OrderStatus.BORROWING:
|
|
|
+ return '借阅中';
|
|
|
+ case OrderStatus.PENDING_OUTBOUND:
|
|
|
+ return '待出库';
|
|
|
+ case OrderStatus.PENDING_PICKUP:
|
|
|
+ return '待取书';
|
|
|
+ case OrderStatus.CLOSED:
|
|
|
+ return '已关闭';
|
|
|
+ case OrderStatus.BORROWING_COMPLETED:
|
|
|
+ return '借阅完成';
|
|
|
+ case OrderStatus.PENDING_ACCEPTANCE:
|
|
|
+ return '待验收';
|
|
|
+ case OrderStatus.PENDING_RECEIPT:
|
|
|
+ return '待收书';
|
|
|
+ default:
|
|
|
+ return '未知状态';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ getOrderStatusTitle(status: OrderStatus): string {
|
|
|
+ switch (status) {
|
|
|
+ case OrderStatus.BORROWING:
|
|
|
+ return '敬请享受阅读的快乐!阅读完成,请预约快递上门取书';
|
|
|
+ case OrderStatus.PENDING_OUTBOUND:
|
|
|
+ return '图书正在检测消毒,尽快发货~';
|
|
|
+ case OrderStatus.CLOSED:
|
|
|
+ return '期待您的下一次借阅!';
|
|
|
+ case OrderStatus.BORROWING_COMPLETED:
|
|
|
+ return '期待您的下一次借阅!';
|
|
|
+ case OrderStatus.PENDING_ACCEPTANCE:
|
|
|
+ return '收到书后,工作人员将尽快验收入库';
|
|
|
+ default :
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ build() {
|
|
|
+ Column(){
|
|
|
+ Row(){
|
|
|
+ Text(this.getOrderStatusDes(this.orderStatus))
|
|
|
+ .attributeModifier(new CustomTextStyle({size: 16, weight: 500}))
|
|
|
+
|
|
|
+ Text('直租')
|
|
|
+ .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF777777'}))
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .margin({bottom: 6})
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+
|
|
|
+ this.orderTitle()
|
|
|
+
|
|
|
+ Divider().width("100%").height(1).backgroundColor('#FFE0E0E0')
|
|
|
+ .margin({top: 14, bottom: 16})
|
|
|
+
|
|
|
+ List({space: 15}){
|
|
|
+ ForEach(new Array(8).fill(''), (item: string, index) => {
|
|
|
+ ListItem(){
|
|
|
+ Image($r('[basic].media.png_defaultBook'))
|
|
|
+ .width(63)
|
|
|
+ .height(81)
|
|
|
+ .borderRadius(6)
|
|
|
+ .backgroundColor('#FFFECF2F')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }.width("100%").height(81)
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .listDirection(Axis.Horizontal)
|
|
|
+
|
|
|
+ Row(){
|
|
|
+ Text('租借时间')
|
|
|
+ .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF444444'}))
|
|
|
+
|
|
|
+ Text(this.orderStatus == OrderStatus.PENDING_PICKUP ? `快递签收起30天` : `2024-01-05至2025-01-04`)
|
|
|
+ .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF333333'}))
|
|
|
+ }.width("100%").margin({top: 17})
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+
|
|
|
+ if(this.orderStatus == OrderStatus.BORROWING) {
|
|
|
+ Row(){
|
|
|
+ buttonComp(
|
|
|
+ '预约还书', 143, 10,
|
|
|
+ new CustomTextStyle({size: 18, weight: 400, color: '#FF000000'}),
|
|
|
+ () => { }
|
|
|
+ )
|
|
|
+ }.width("100%")
|
|
|
+ .padding({top: 12})
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+ } else if(this.orderStatus == OrderStatus.PENDING_PAYMENT) {
|
|
|
+ Row(){
|
|
|
+ buttonComp(
|
|
|
+ '去支付', 143, 10,
|
|
|
+ new CustomTextStyle({size: 18, weight: 400, color: '#FF000000'}),
|
|
|
+ () => { }
|
|
|
+ )
|
|
|
+ }.width("100%")
|
|
|
+ .padding({top: 12})
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .padding(16)
|
|
|
+ .width("100%")
|
|
|
+ .borderRadius(8)
|
|
|
+ .border({width: 2})
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+ }
|
|
|
+
|
|
|
+ @Builder
|
|
|
+ orderTitle(){
|
|
|
+ Row(){
|
|
|
+ // 待支付
|
|
|
+ if(this.orderStatus == OrderStatus.PENDING_PAYMENT) {
|
|
|
+ Text(){
|
|
|
+ Span('剩余支付时间:')
|
|
|
+ Span(`28分23秒`).fontColor('#FFFECF2F')
|
|
|
+ }.attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF444444'}))
|
|
|
+ }
|
|
|
+ // 待取书
|
|
|
+ else if(this.orderStatus == OrderStatus.PENDING_PICKUP) {
|
|
|
+ Text(){
|
|
|
+ Span('运输中,预计')
|
|
|
+ Span(`明天送达>>`).fontColor('#FFFECF2F')
|
|
|
+ }.attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF444444'}))
|
|
|
+ }
|
|
|
+ // 借阅中 -- 已超时
|
|
|
+ else if(this.orderStatus == OrderStatus.BORROWING) {
|
|
|
+ Text(){
|
|
|
+ Span('已超时')
|
|
|
+ Span(`2`).fontColor('#FFFECF2F')
|
|
|
+ Span('天,逾期费')
|
|
|
+ Span(`2.5`).fontColor('#FFFECF2F')
|
|
|
+ Span('元,请尽快还书。')
|
|
|
+ }.attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF444444'}))
|
|
|
+ }
|
|
|
+ // 待收书
|
|
|
+ else if(this.orderStatus == OrderStatus.PENDING_RECEIPT) {
|
|
|
+ Text('查看物流信息>>')
|
|
|
+ .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF0051FF'}))
|
|
|
+ }
|
|
|
+ // 其他状态
|
|
|
+ else {
|
|
|
+ Text(this.getOrderStatusTitle(this.orderStatus))
|
|
|
+ .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF444444'}))
|
|
|
+ }
|
|
|
+ }.width("100%")
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//骨架
|
|
|
+@ComponentV2
|
|
|
+struct SkeletonComp{
|
|
|
+ build() {
|
|
|
+ Column(){
|
|
|
+ Row(){
|
|
|
+ Row().width(50).height(21).backgroundColor('#F7F9FA')
|
|
|
+
|
|
|
+ Row().width(30).height(20).backgroundColor('#F7F9FA')
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .margin({bottom: 6})
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+
|
|
|
+ Row().width(160).height(20).backgroundColor('#F7F9FA')
|
|
|
+
|
|
|
+ Divider().width("100%").height(1).backgroundColor('#FFE0E0E0')
|
|
|
+ .margin({top: 14, bottom: 16})
|
|
|
+
|
|
|
+ Row({space: 15}){
|
|
|
+ ForEach(new Array(5).fill(''), (item: string, index) => {
|
|
|
+ Row().width(63).height(81).backgroundColor('#F7F9FA')
|
|
|
+ })
|
|
|
+ }.width("100%").height(81)
|
|
|
+
|
|
|
+ Row(){
|
|
|
+ Row().width(56).height(20).backgroundColor('#F7F9FA')
|
|
|
+
|
|
|
+ Row().width(56).height(20).backgroundColor('#F7F9FA')
|
|
|
+ }.width("100%").margin({top: 17})
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+ }
|
|
|
+ .padding(16)
|
|
|
+ .width("100%")
|
|
|
+ .borderRadius(8)
|
|
|
+ .border({width: 2, color: '#ffaeaeae'})
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+ .alignItems(HorizontalAlign.Start)
|
|
|
+ }
|
|
|
+
|
|
|
+}
|