lex-xin 4 miesięcy temu
rodzic
commit
3756e2e24a

+ 2 - 2
miniprogram/pages/index/index.less

@@ -93,10 +93,10 @@ page {
     color: #AAAAAA;
     line-height: 44rpx;
     text-decoration: line-through;
-    padding-top: 14rpx;
+    padding-bottom: 14rpx;
   }
   .right {
-    padding-bottom: 14rpx;
+    padding-top: 14rpx;
     font-weight: 400;
     font-size: 28rpx;
     color: #777777;

+ 26 - 4
miniprogram/pages/orders/order-result.ts

@@ -36,6 +36,8 @@ Page({
         content: '您的退款已成功处理,感谢您的理解和支持'
       }
     },
+    timerCount: 0,
+    timer: null as any,
     goodsInfo: {} as any,
     orderNo: "" as string,
     showCanvas: false, // 是否显示二维码
@@ -47,15 +49,14 @@ Page({
    */
   onLoad(options: any) {
     if (options.orderNo) {
-      console.log(options, 'options')
       this.setData({
         orderNo: options.orderNo
       }, () => {
-        this.getDetail()
+        this.getDetail(this.onTimeout)
       });
     }
   },
-  async getDetail() {
+  async getDetail(callback?: any) {
     try {
       const { data } = await api_userPaymentOrderDetail(this.data.orderNo);
       if (data.code == 200) {
@@ -89,8 +90,10 @@ Page({
         this.setData({
           goodsInfo,
           status: result.wechatStatus
+        }, () => {
+          callback && typeof callback === 'function' && callback()
         })
-        if(result.wechatStatus != 'CLOSED') {
+        if(result.wechatStatus != 'CLOSED' || result.wechatStatus != 'WAIT_PAY') {
           const firstGoods = tempGoods[0]
           if(firstGoods?.shortUrl) {
             this.createQrCode(firstGoods?.shortUrl, 'canvasCode')
@@ -171,4 +174,23 @@ Page({
       },
     });
   },
+  onTimeout() {
+    // 轮询10次查询订单状态
+    const { goodsInfo, timerCount, timer } = this.data
+    if(goodsInfo.wechatStatus === 'WAIT_PAY' && timerCount <= 10) {
+      let count = timerCount
+      const tempT = setTimeout(async () => {
+        count += 1
+        await this.getDetail()
+        this.setData({
+          timer: tempT,
+          timerCount: count
+        }, () => {
+          this.onTimeout()
+        })
+      }, 3000);
+    } else {
+      clearTimeout(timer)
+    }
+  }
 })

+ 1 - 1
miniprogram/pages/orders/orders.ts

@@ -71,7 +71,7 @@ Page({
     try {
       // @ApiModelProperty("订单状态 WAIT_PAY:待付款,WAIT_USE:待使用,SUCCESS:已完成,CLOSE:已取消")
       const { data } = await api_studentOrderPage({
-        opneId: app.globalData.userInfo?.liteOpenid,
+        openId: app.globalData.userInfo?.liteOpenid,
         page: currentPage,
         rows: this.data.rows,
         wechatOrderStatus: tabIdx == 0 ? "" : tabIdx == 1 ? "WAIT_PAY" : tabIdx == 2 ? "WAIT_USE" : tabIdx == 3 ? "PAID" : tabIdx == 4 ? "CLOSED" : "",