Selaa lähdekoodia

9块9年卡对接微信小程序支付

huangxiaojing 2 vuotta sitten
vanhempi
commit
300262380e
1 muutettua tiedostoa jossa 21 lisäystä ja 4 poistoa
  1. 21 4
      pages/activity/lottery/index.vue

+ 21 - 4
pages/activity/lottery/index.vue

@@ -174,7 +174,6 @@ export default {
     this.getLuckDrawActivity()
     this.getMealInfo()
     this.getCarouselList()
-    console.log(this.$userAgent.isMobile);
   },
   methods: {
     async getCarouselList() {
@@ -210,15 +209,33 @@ export default {
             orderNum: res.data.myOrderNum,
             actualPrice: this.actualPrice
           });
+        } else if (this.$userAgent.isMiniProgram) {
+          if (this.payType === 'aliPay') {
+            Toast({
+              message: '微信小程序不支持支付宝支付',
+              position: 'top'
+            });
+            return false
+          }
+          this.$wx.miniProgram.postMessage({
+            data: {
+              action: 'updateAppMessageShareData',
+              params: {
+                payType: this.payType === 'aliPay' ? 3 : 2,
+                orderNum: res.data.myOrderNum,
+                buyType: 1,
+                price: this.actualPrice
+              },
+            },
+          });
         } else {
-          console.log(511);
           // 使用postMessage 方法可以发送消息到应用, 消息内容需要在data 对象中,否则webview无法接收到
-          console.log(webUni.webView.postMessage);
           webUni.webView.postMessage({
             data: {
               payType: this.payType === 'aliPay' ? 3 : 2,
               orderNum: res.data.myOrderNum,
-              buyType: 1
+              buyType: 1,
+              price: this.actualPrice
             }
           })
         }