Bladeren bron

联调支付

bayi 9 maanden geleden
bovenliggende
commit
fe31637e8a
4 gewijzigde bestanden met toevoegingen van 27 en 12 verwijderingen
  1. 2 0
      api/global.js
  2. 23 10
      components/donutBuy/index.js
  3. 1 1
      components/donutBuy/index.wxml
  4. 1 1
      components/popUp/index.js

File diff suppressed because it is too large
+ 2 - 0
api/global.js


+ 23 - 10
components/donutBuy/index.js

@@ -1,22 +1,23 @@
 import {
     createAndroidOrder,
-    payQrCode
+    payQrCode,
+    pollingOrder
 } from '~/api/global'
+let polling
 Component({
     properties: {
 
     },
     data: {
-        show: true,
         qrCode: '',
         product: {}
     },
     lifetimes: {
         attached() {
-         /*    this.selectComponent("#popUp").showModal()
-            this.getTabBar().setData({
-                show: false
-            }) */
+            /*    this.selectComponent("#popUp").showModal()
+               this.getTabBar().setData({
+                   show: false
+               }) */
         },
     },
     methods: {
@@ -33,17 +34,29 @@ Component({
                 show: false
             })
             this.setData({
-                show: true,
                 product,
                 qrCode
             })
             this.selectComponent("#popUp").showModal()
+            polling = setInterval(async () => {
+                let res = await pollingOrder(orderId)
+                if (res.payStatus == 'SUCCESS') {
+                    this.triggerEvent('paySuccess')
+                    this.close()
+                }
+            }, 2000);
         },
-        close() {
-            this.setData({
-                show: false,
+        closeEvent() {
+            this.getTabBar().setData({
+                show: true
             })
+            clearInterval(polling)
+        },
+        close() {
             this.selectComponent("#popUp").hideModal()
+            this.getTabBar().setData({
+                show: true
+            })
         }
     }
 })

+ 1 - 1
components/donutBuy/index.wxml

@@ -1,4 +1,4 @@
-<popUp id="popUp" wx:if="{{show}}">
+<popUp id="popUp" bind:close='closeEvent'>
     <view class="box">
         <view class="header">
             扫码支付

+ 1 - 1
components/popUp/index.js

@@ -19,7 +19,6 @@ Component({
     methods: {
         //底部弹出框
         showModal() {
-            console.log(111);
             // 背景遮罩层
             var animation = wx.createAnimation({
                 duration: 200,
@@ -51,6 +50,7 @@ Component({
             this.setData({
                 animationData: animation.export(),
             })
+            this.triggerEvent('close')
             setTimeout(function () {
                 animation.translateY(0).step()
                 this.setData({