Просмотр исходного кода

feat: 完成支付页面的逻辑优化

YuJing 1 месяц назад
Родитель
Сommit
6e64f7be7f

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

@@ -205,8 +205,8 @@ class YTRouter extends NavPathStack {
   }
 
   // 进入发起支付页面
-  router2InitiatePayPage(fromText?: string){
-    this.pushPathByName('PrivacyPolicyPage', fromText)
+  router2InitiatePayPage(orderId: string){
+    this.pushPathByName('InitiatePayPage', orderId)
   }
 }
 

+ 21 - 1
features/feature/src/main/ets/model/EnumState.ets

@@ -37,7 +37,9 @@ export enum AddressAddPageState {
   ADD_AND_USE,
 }
 
-// 列表循环枚举
+/**
+ * 列表循环枚举
+ */
 export enum ForEachLoop {
   // 纯文本
   TEXT,
@@ -48,3 +50,21 @@ export enum ForEachLoop {
 }
 
 
+/**
+ * 页面状态枚举
+ */
+export enum PageState {
+  /**
+   * 加载中
+   */
+  LOADING,
+  /**
+   * 出错了
+   */
+  ERROR,
+  /**
+   * 加载完成
+   */
+  COMPLETED,
+}
+

+ 13 - 0
features/feature/src/main/ets/model/Query.ets

@@ -7,12 +7,14 @@ abstract class Query{
   /** 用户id */
   userId: string | null = userInfo.getId()
 
+  // 重新请求
   reload() {
     this.pageNum = 1
     this.pageSize = 16
     this.total = 1
   }
 
+  // 触底加载更多
   reachEnd(sourceLength: number): boolean {
     if(sourceLength < this.pageSize) {
       this.pageNum++
@@ -20,6 +22,17 @@ abstract class Query{
     }
     return false
   }
+
+  // 页数回滚
+  backPage() {
+    this.pageNum--
+  }
+
+  // 设置 total
+  setTotal(total?: string) {
+    if(!total) return
+    this.total = parseInt(total)
+  }
 }
 
 

+ 137 - 167
features/feature/src/main/ets/pages/PrivacyPolicyPage.ets → features/feature/src/main/ets/pages/Order/InitiatePayPage.ets

@@ -3,34 +3,27 @@ import { webview } from '@kit.ArkWeb'
 import { bundleManager, common } from '@kit.AbilityKit'
 import { BusinessError } from '@kit.BasicServicesKit'
 import { WebViewJavascriptBridge, WVJBResponseCallback } from '@yue/webview_javascript_bridge'
-import util from '@kit.ArkTS';
+import { YTAvoid, yTRouter } from 'basic'
+import { GetUnifiedPayInfoRequestData } from '../../model/OrderModelIndex'
+import { OrderApi } from '../../apis/OrderApi'
+import { PageState } from '../../model/EnumState'
 
 
 @Component
-struct PrivacyPolicyPage {
-  @Require fromText: string
+struct InitiatePayPage {
+  @Require orderId: string
 
+  @State safeTop: number = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
+  @State safeBottom: number = AppStorage.get(YTAvoid.SAFE_BOTTOM_KEY) as number
+  // 页面状态
+  @State pageState: PageState = PageState.LOADING
+  @State url: string = ''
 
-  @State targetUrl: string = ''
-  @State title: string = ''
-  // 是否有进度条
-  hasProgressBar: boolean = false
-  // 网络加载进度
-  @State progressNum: number = 0
-  // 网络是否在加载中
-  @State loading: boolean = true
   // 是否显示
   navBarShow: boolean = true
-  // 进入页面时,状态条颜色
-  onPageShowBarColor: StatusBarColor = StatusBarColor.Black
-  // 隐藏页面时,状态条颜色
-  onPageHideBarColor: StatusBarColor = StatusBarColor.Black
-  // 顶部安全高度
-  safeTop: number = AppStorage.get('safeTop') as number
-  // 底部安全高度
-  safeBottom: number = AppStorage.get('safeBottom') as number
   controller: webview.WebviewController = new webview.WebviewController()
   historyCurrIndex: number = 0
+
   // WebViewJavascriptBridge 桥接
   private bridge: WebViewJavascriptBridge | undefined;
   private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
@@ -42,8 +35,6 @@ struct PrivacyPolicyPage {
   private isWeixinPay = false;
   // 支付订单页url,如果成功拉起微信支付以后取消会回到app,此时需要跳到订单页
   private orderUrl: string = '';
-  // 监听网页加载是否出错
-  @State loadError: boolean = false;
   // 点击返回键需要直接退出web组件的url集合
   private excludedUrlList: string[] = [
     'https://app.sightcloud.cn/storage/#/package',
@@ -52,11 +43,90 @@ struct PrivacyPolicyPage {
   ];
 
   aboutToAppear(): void {
-    this.onPageShow()
+    this.getPaymentUrl(this.orderId)
+  }
+
+  build() {
+    NavDestination() {
+      Column() {
+        if(this.pageState == PageState.LOADING) {
+          Column() {
+            Text('加载支付中...')
+              .fontColor('#686868')
+              .fontSize(20)
+          }
+          .width('100%')
+          .height('100%')
+          .justifyContent(FlexAlign.Center)
+        } if (this.pageState == PageState.ERROR) {
+          Column() {
+            Text('出错啦!点击空白处刷新')
+              .fontColor('#686868')
+              .fontSize(20)
+          }
+          .width('100%')
+          .height('100%')
+          .justifyContent(FlexAlign.Center)
+          .onClick(() => {
+            this.pageState = PageState.COMPLETED
+          })
+        } else if (this.pageState == PageState.COMPLETED) {
+          Scroll() {
+            Web({
+              src: this.url,
+              controller: this.controller
+            })
+              .width('100%')
+              .height('100%')
+              .geolocationAccess(false)
+              .domStorageAccess(true)
+              .mixedMode(MixedMode.Compatible)
+              .fileAccess(true)
+              .multiWindowAccess(true)
+              .onControllerAttached(() => {
+                this.setupWebViewJavascriptBridge();
+              })
+              .onRefreshAccessedHistory((event) => {
+                //H5页面间的跳转
+                // if (this.controller.getTitle().length < 5) {
+                //   this.title = this.controller.getTitle()
+                // }
+                if (event) {
+                  const history = this.controller.getBackForwardEntries()
+                  this.historyCurrIndex = history.currentIndex
+                }
+              })
+              .onLoadIntercept((event) => {
+                const isPayment = this.handlePaymentIntercept(event)
+                return isPayment
+              })
+              .onPageEnd((event) => {
+                // this.controller.runJavaScript('document.forms[0].submit()')
+                if (this.orderUrl && event.url == this.orderUrl) {
+                  this.controller.clearHistory()
+                }
+              })
+              .onErrorReceive((event) => {
+                if (event.request.getRequestUrl() == this.controller.getUrl()) {
+                  console.error(`WebView load error: ${event.request.getRequestUrl()}, code: ${event.error.getErrorCode()}, message: ${event.error.getErrorInfo()}`);
+                  // 显示错误页面
+                  this.pageState = PageState.ERROR
+                }
+              })
+          }
+          .margin({ bottom: this.navBarShow ? this.safeBottom : 0 })
+        }
+      }
+      .width('100%')
+      .height('100%')
+      .padding({ top: this.navBarShow ? this.safeTop : 0, bottom: this.navBarShow ? this.safeBottom : 0 })
+    }
+    .hideTitleBar(true)
+    .onBackPressed(() => { return this.onBackPress() })
+    .onShown(() => { this.onPageShow() })
   }
 
   onPageShow(): void {
-    // this.statusBarColorSelect(this.onPageShowBarColor)
     // 判断是否安装支付宝
     try {
       this.canOpenAlipays = bundleManager.canOpenLink('alipays://');
@@ -72,147 +142,52 @@ struct PrivacyPolicyPage {
         // 清跳转订单页
         this.controller.loadUrl(this.orderUrl)
       } else {
-        this.backMethod()
+        this.onBackPress()
       }
     }
   }
 
-  onPageHide(): void {
-    this.statusBarColorSelect(this.onPageHideBarColor)
-  }
-
-  // 状态条颜色选取函数
-  statusBarColorSelect(color: StatusBarColor) {
-    switch (color) {
-      case StatusBarColor.White:
-        // themeManager.settingStatusBarWhite()
-        break
-      case StatusBarColor.Black:
-        // themeManager.settingStatusBarBlack()
-        break
-      default:
-        // themeManager.settingStatusBarBlack()
-        break
-    }
-  }
-
   // 页面自行处理返回逻辑,不进行页面路由
+  // todo 在返回之前查询订单是否完成, 根据结果跳转到对应的页面
   onBackPress() {
-    this.backMethod()
+    const url = this.controller.getUrl()
+    if (this.pageState == PageState.LOADING || this.pageState == PageState.ERROR){
+      yTRouter.pop()
+    } else if (this.excludedUrlList.some(item => url.startsWith(item))) {
+      yTRouter.pop()
+    } else if (this.historyCurrIndex == 0) {
+      yTRouter.pop()
+    }
     return true
   }
 
-  backMethod() {
-    if (this.loadError) {
-      router.back()
-      return
+  // 根据订单号获取支付链接
+  async getPaymentUrl(orderId: string): Promise<void> {
+    let payInfo: GetUnifiedPayInfoRequestData = {
+      orderId: orderId,
+      payWay: '2',
     }
-    const url = this.controller.getUrl()
-    if (this.excludedUrlList.some(item => url.startsWith(item))) {
-      router.back()
-      return
-    }
-    if (this.historyCurrIndex > 0) {
-      this.controller.backward()
-    } else {
-      router.back()
-    }
-  }
 
-  build() {
-    NavDestination() {
-      Column() {
-        if (this.navBarShow) {
-          // PrivacyPolicyPageTitle({ title: this.title })
-        }
+    this.url = await OrderApi.getPayInfo(payInfo)
+    this.pageState = PageState.COMPLETED
 
-        Stack({ alignContent: Alignment.Top }) {
-          if (this.hasProgressBar && this.loading && !this.loadError) {
-            this.progress()
-          }
-          if (this.loadError) {
-            Column() {
-              Text('出错啦!点击空白处刷新')
-                .fontColor('#686868')
-                .fontSize(20)
-            }
-            // .width(StyleConstants.FULL_PARENT)
-            // .height(StyleConstants.FULL_PARENT)
-            .justifyContent(FlexAlign.Center)
-            .onClick(() => {
-              this.loadError = false
-            })
-          } else {
-            Scroll() {
-              Web({
-                src: this.fromText,
-                controller: this.controller
-              })
-                .width('100%')
-                .height('100%')
-                .geolocationAccess(false)
-                .domStorageAccess(true)
-                .mixedMode(MixedMode.Compatible)
-                .fileAccess(true)
-                .multiWindowAccess(true)
-                .onControllerAttached(() => {
-                  this.setupWebViewJavascriptBridge();
-                })
-                .onProgressChange((date) => {
-                  if (date) {
-                    //记录加载进度
-                    this.progressNum = date.newProgress
-                    if (this.progressNum == 100) {
-                      //加载完成进度条消失
-                      animateTo({ duration: 800, delay: 300 }, () => {
-                        this.loading = false
-                      })
-                    }
-                  }
-                })
-                .onRefreshAccessedHistory((event) => {
-                  //H5页面间的跳转
-                  // if (this.controller.getTitle().length < 5) {
-                  //   this.title = this.controller.getTitle()
-                  // }
-                  if (event) {
-                    const history = this.controller.getBackForwardEntries()
-                    this.historyCurrIndex = history.currentIndex
-                  }
-                })
-                .onPageBegin((event) => {
-                  this.progressNum = 0
-                  this.loading = true
-                })
-                .onLoadIntercept((event) => {
-                  const isPayment = this.handlePaymentIntercept(event)
-                  return isPayment
-                })
-                .onPageEnd((event) => {
-                  // this.controller.runJavaScript('document.forms[0].submit()')
-                  if (this.orderUrl && event.url == this.orderUrl) {
-                    this.controller.clearHistory()
-                  }
-                })
-                .onErrorReceive((event) => {
-                  if (event.request.getRequestUrl() == this.controller.getUrl()) {
-                    console.error(`WebView load error: ${event.request.getRequestUrl()}, code: ${event.error.getErrorCode()}, message: ${event.error.getErrorInfo()}`);
-                    this.loadError = true; // 显示错误页面
-                  }
-                })
-            }
-            .margin({ bottom: this.navBarShow ? this.safeBottom : 0 })
-          }
-        }
-      }
-      .width('100%')
-      .height('100%')
-      .padding({ top: this.navBarShow ? this.safeTop : 0, bottom: this.navBarShow ? this.safeBottom : 0 })
-    }
-    .hideTitleBar(true)
+    console.log(`支付链接 = ${JSON.stringify(this.url)}`)
+  }
+
+  // todo 获取订单支付结果
+  async getPaymentResult(orderId: string): Promise<void> {
+    /**
+     * 前往借阅成功页面
+     */
+    // yTRouter.router2BorrowAnsPage()
   }
 
-  // 处理支付相关的拦截逻辑
+
+  /**
+   * 处理支付相关的拦截逻辑
+   * @param event
+   * @returns
+   */
   private handlePaymentIntercept(event: OnLoadInterceptEvent) {
     let data = event.data;
     let url = data.getRequestUrl();
@@ -276,7 +251,11 @@ struct PrivacyPolicyPage {
     return false
   }
 
-  // 从微信支付链接中提取 redirect_url 参数
+  /**
+   * 从微信支付链接中提取 redirect_url 参数
+   * @param url
+   * @returns
+   */
   private getRedirectUrlFromTenpay(url: string): string | null {
     try {
       // 使用正则提取 redirect_url 参数
@@ -292,13 +271,6 @@ struct PrivacyPolicyPage {
     return null;
   }
 
-  @Builder
-  progress() {
-    Progress({ value: this.progressNum, total: 100, type: ProgressType.Linear })
-      .color('#17ab19')
-      .zIndex(1)
-  }
-
   /**
    * 设置 jsBridge
    */
@@ -310,21 +282,19 @@ struct PrivacyPolicyPage {
     this.registerHandlers(this.bridge)
   }
 
-  // 注册原生处理函数 (这里需要知道H5端的方法名)
+  /**
+   * 注册原生处理函数 (这里需要知道H5端的方法名)
+   * @param bridge
+   */
   private registerHandlers(bridge: WebViewJavascriptBridge) {
     bridge.registerHandler('backToNative', (data: object, responseCallback: WVJBResponseCallback) => {
-      this.backMethod();
+      this.onBackPress();
       responseCallback(null);
     });
   }
 }
 
-export enum StatusBarColor {
-  White = 'White',
-  Black = 'Black',
-}
-
 @Builder
-function PrivacyPolicyBuilder(_: string, fromText: string) {
-  PrivacyPolicyPage({fromText})
+function InitiatePayPageBuilder(_: string, orderId: string) {
+  InitiatePayPage({orderId})
 }

+ 17 - 4
features/feature/src/main/ets/pages/Order/OrderManagementPage.ets

@@ -15,6 +15,8 @@ struct OrderManagementPage {
   @Param @Require targetIndex: number;
 
   vm: OrderManagementViewModel = new OrderManagementViewModel();
+
+
   aboutToAppear(): void {
     if(this.targetIndex != undefined) {
       this.vm.changeCategory(this.targetIndex)
@@ -114,14 +116,18 @@ struct OrderManagementPage {
                       .scrollBar(BarState.Off)
                       .edgeEffect(EdgeEffect.None)
                       .padding({left: 15, right: 15, bottom: this.vm.safeBottom})
-                      .onReachEnd(() => { this.vm.onReachEnd() })
+                      .onReachEnd(() => {
+                        if(this.vm.dataSource.length != 0) {
+                          this.vm.onReachEnd(this.vm.categoryIndex)
+                        }
+                      })
                     }
                   }
                 }
                 .padding(0)
                 .onRefreshing(() => {
                   this.vm.isRefresh = true
-                  this.vm.onRefreshing()
+                  this.vm.onRefreshing(this.vm.categoryIndex)
                 })
               }.padding(0)
             })
@@ -164,7 +170,6 @@ struct OrderItemComp{
     this.orderStatus = Number.parseInt(this.orderData.statusCode!)
   }
 
-
   getOrderStatusDes(status: OrderStatus): string {
     switch (status) {
     case OrderStatus.PENDING_PAYMENT:
@@ -211,7 +216,10 @@ struct OrderItemComp{
   }
 
   // 去支付
-  payPage(){}
+  // todo 选择支付方式
+  payPage(){
+    yTRouter.router2InitiatePayPage(this.orderData.id!)
+  }
 
   build() {
     Column(){
@@ -288,6 +296,7 @@ struct OrderItemComp{
   orderTitle(){
     Row(){
       // 待支付
+      // todo 待支付 - 待完成
       if(this.orderStatus == OrderStatus.PENDING_PAYMENT) {
         Text(){
           Span('剩余支付时间:')
@@ -295,6 +304,7 @@ struct OrderItemComp{
         }.attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF444444'}))
       }
       // 待取书
+      // todo 待取书 - 待完成
       else if(this.orderStatus == OrderStatus.PENDING_PICKUP) {
         Text(){
           Span('运输中,预计')
@@ -302,6 +312,7 @@ struct OrderItemComp{
         }.attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF444444'}))
       }
       // 借阅中 -- 已超时
+      // todo 借阅中 - 待完成
       else if(this.orderStatus == OrderStatus.BORROWING) {
         Text(){
           Span('已超时')
@@ -312,6 +323,7 @@ struct OrderItemComp{
         }.attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF444444'}))
       }
       // 待收书
+      // todo 待收书 - 待完成
       else if(this.orderStatus == OrderStatus.PENDING_RECEIPT) {
         Text('查看物流信息>>')
           .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF0051FF'}))
@@ -320,6 +332,7 @@ struct OrderItemComp{
           })
       }
       // 其他状态
+      // todo 其他状态 - 待完成
       else {
         Text(this.getOrderStatusTitle(this.orderStatus))
           .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF444444'}))

+ 1 - 0
features/feature/src/main/ets/pages/viewModel/BookItemDetailViewModel.ets

@@ -20,6 +20,7 @@ export class BookItemDetailViewModel{
   // 立刻借阅
   borrow() {
     // todo 逻辑相对比较复杂,在 view 中处理完成后再 copy 过来
+
   }
 
   // 加入书包

+ 82 - 0
features/feature/src/main/ets/pages/viewModel/InitiatePayViewModel.ets

@@ -0,0 +1,82 @@
+// import { YTAvoid, yTRouter } from "basic"
+// import { bundleManager } from "@kit.AbilityKit"
+//
+// @ObservedV2
+// export class InitiatePayViewModel{
+//
+//   // 是否显示
+//   navBarShow: boolean = true
+//   controller: webview.WebviewController = new webview.WebviewController()
+//   historyCurrIndex: number = 0
+//   // WebViewJavascriptBridge 桥接
+//   private bridge: WebViewJavascriptBridge | undefined;
+//   private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
+//   // 是否安装支付宝应用
+//   private canOpenAlipays = false;
+//   // 是否安装微信应用
+//   private canOpenWechat = false;
+//   // 是否已拉起微信支付
+//   private isWeixinPay = false;
+//   // 支付订单页url,如果成功拉起微信支付以后取消会回到app,此时需要跳到订单页
+//   private orderUrl: string = '';
+//   // 监听网页加载是否出错
+//   @State loadError: boolean = false;
+//   // 点击返回键需要直接退出web组件的url集合
+//   private excludedUrlList: string[] = [
+//     'https://app.sightcloud.cn/storage/#/package',
+//     'https://app.aikancloud.com/storage/#/packageOrder',
+//     'https://wx.88iot.net'
+//   ];
+//
+//
+//   constructor() {
+//
+//   }
+//
+//
+//   onPageShow(): void {
+//     // this.statusBarColorSelect(this.onPageShowBarColor)
+//     // 判断是否安装支付宝
+//     try {
+//       this.canOpenAlipays = bundleManager.canOpenLink('alipays://');
+//       this.canOpenWechat = bundleManager.canOpenLink('weixin://');
+//     } catch (err) {
+//       let message = (err as BusinessError).message;
+//       console.log('canOpenLink call error:', message);
+//     }
+//     // 判断是否是跳转到微信以后再返回app,若是,则跳转到订单页,若没有拿到订单url,直接返回上一页
+//     if (this.isWeixinPay) {
+//       this.isWeixinPay = false
+//       if (this.orderUrl) {
+//         // 清跳转订单页
+//         this.controller.loadUrl(this.orderUrl)
+//       } else {
+//         this.backMethod()
+//       }
+//     }
+//   }
+//
+//   // 页面自行处理返回逻辑,不进行页面路由
+//   onBackPress() {
+//     this.backMethod()
+//     return true
+//   }
+//
+//   backMethod() {
+//     if (this.loadError) {
+//       router.back()
+//       return
+//     }
+//     const url = this.controller.getUrl()
+//     if (this.excludedUrlList.some(item => url.startsWith(item))) {
+//       router.back()
+//       return
+//     }
+//     if (this.historyCurrIndex > 0) {
+//       this.controller.backward()
+//     } else {
+//       router.back()
+//     }
+//   }
+//
+// }

+ 1 - 12
features/feature/src/main/ets/pages/viewModel/OrderDetailViewModel.ets

@@ -90,24 +90,13 @@ export class OrderDetailViewModel{
       IBestToast.show('请填写收件人信息')
       return
     }
-    /**
-     * 前往借阅成功页面
-     */
-    // yTRouter.router2BorrowAnsPage()
-
     this.orderValidation.orderPrice = Number.parseFloat(this.totalPrice.toFixed(2))
     this.orderValidation.remark = this.remark
     let ans: OrderValidationData = await OrderApi.checkOrder(this.orderValidation)
     console.log(`借阅结果数据结构 ans = ${JSON.stringify(ans)}`)
 
-    let payInfo: GetUnifiedPayInfoRequestData = {
-      orderId: ans.id,
-      payWay: '2',
-    }
 
-    let res = await OrderApi.getPayInfo(payInfo)
-    console.log(`res = ${JSON.stringify(res)}`)
-    yTRouter.router2InitiatePayPage(res)
+    yTRouter.router2InitiatePayPage(ans.id!)
   }
 
   /** 前往联系客服 */

+ 60 - 28
features/feature/src/main/ets/pages/viewModel/OrderManagementViewModel.ets

@@ -20,24 +20,12 @@ export class OrderManagementViewModel{
   query: userOrderQuery = new userOrderQuery()
   // 订单状态对照
   orderStatus: number[] = [0, 2, 3, 7]
+  isLoading: boolean = false
 
-
-  tag = "OrderPage"
-
-  private debounceTimer: number | null = null
-  private readonly DEBOUNCE_DELAY: number = 0
-
-  constructor(index?: number) {
-    // todo 列表初次请求有问题 - 会被第一个if 拦截掉
-    // if(index != undefined) {
-    //   this.changeCategory(index)
-    // } else {
-    //   this.changeCategory(0)
-    // }
-  }
+  constructor() {}
 
   // 修改分类
-  changeCategory(index: number, isAppear: boolean = false) {
+  changeCategory(index: number) {
     if(this.categoryIndex == index) return
 
     this.categoryIndex = index
@@ -50,26 +38,70 @@ export class OrderManagementViewModel{
       this.query.statusCode = this.orderStatus[index-1]
     }
 
-    this.onRefreshing()
+    this.onRefreshing(index)
   }
 
-  onRefreshing(){
-    console.log(`刷新了 = ${JSON.stringify('刷新了')}`)
+  onRefreshing(index: number){
+    if(this.isLoading) return
+    this.isLoading = true
+
     this.query.reload()
-    this.getOrderList().finally(()=>{
-      this.isRefresh = false
-      this.isFirst =false
+    this.getOrderList()
+      .then((list: Array<OrderDetailData>) => {
+        if (this.categoryIndex == index) {
+          this.dataSource = list
+        }
+      })
+      .catch(() => {
+
+      })
+      .finally(()=>{
+        this.isRefresh = false
+        this.isFirst =false
+        this.isLoading = false
     })
   }
 
-  onReachEnd(){
-    console.log(`触底了 = ${JSON.stringify('触底了')}`)
+  onReachEnd(index: number){
+    if(this.isLoading) return
+    this.isLoading = true
+
+    if(this.query.reachEnd(this.dataSource.length)) {
+      this.getOrderList()
+        .then((list: Array<OrderDetailData>)=>{
+          if (this.categoryIndex == index) {
+            this.dataSource.push(...list)
+          }
+        })
+        .catch(()=>{
+          // 回滚页数
+          this.query.backPage()
+        })
+        .finally(()=>{
+          this.isLoading = false
+        })
+    }
   }
 
   // 获取订单列表
-  async getOrderList(){
-    let ans = await OrderApi.getUserOrderList(this.query)
-    console.log(`订单信息 ans = ${JSON.stringify(ans)}`)
-    this.dataSource = ans.records ?? []
-  }
+getOrderList(): Promise<OrderDetailData[]> {
+  return new Promise((resolve, reject) => {
+    OrderApi.getUserOrderList(this.query)
+      .then(ans => {
+        console.log(`返回的订单列表 = ${JSON.stringify(ans)}`);
+        this.query.setTotal(ans.total)
+
+        if (ans.records != undefined) {
+          resolve(ans.records);
+        } else {
+          resolve([])
+        }
+      })
+      .catch((error: Error) => {
+        console.error('获取订单列表失败:', error);
+        reject(error);
+      });
+  });
+}
+
 }

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

@@ -86,9 +86,9 @@
       "buildFunction": "CashPledgeRecordBuilder"
     },
     {
-      "name": "PrivacyPolicyPage",
-      "pageSourceFile": "src/main/ets/pages/PrivacyPolicyPage.ets",
-      "buildFunction": "PrivacyPolicyBuilder"
+      "name": "InitiatePayPage",
+      "pageSourceFile": "src/main/ets/pages/Order/InitiatePayPage.ets",
+      "buildFunction": "InitiatePayPageBuilder"
     }
   ]
 }