lex-xin пре 7 месеци
родитељ
комит
7edfbd3879
2 измењених фајлова са 36 додато и 35 уклоњено
  1. 34 34
      miniprogram/pages/index/index.ts
  2. 2 1
      miniprogram/pages/order-webview/order-webview.ts

+ 34 - 34
miniprogram/pages/index/index.ts

@@ -174,48 +174,48 @@ Page({
       title: "加载中...",
     });
     try {
-      // const { salePrice, shopId, name, id, orderNo } = goodsInfo
-      // const { data } = await api_executeOrder({
-      //   "orderType": "WECHAT_MINI",
-      //   "paymentType": this.data.paymentType,
-      //   "paymentCashAmount": salePrice,
-      //   "paymentCouponAmount": 0,
-      //   "shopId": shopId,
-      //   "openId": app.globalData.userInfo?.liteOpenid,
-      //   "goodsInfos": [{
-      //     "goodsId": id,
-      //     "goodsNum": 1,
-      //     "goodsType": "ACTIVATION_CODE",
-      //     "paymentCashAmount": salePrice,
-      //     "paymentCouponAmount": 0
-      //   }],
-      //   "orderName": name,
-      //   "orderDesc": name
-      // })
-      // if (data.code === 200) {
-        // const { paymentConfig, paymentType, orderNo } = data.data
+      const { salePrice, shopId, name, id, orderNo } = goodsInfo
+      const { data } = await api_executeOrder({
+        "orderType": "WECHAT_MINI",
+        "paymentType": this.data.paymentType,
+        "paymentCashAmount": salePrice,
+        "paymentCouponAmount": 0,
+        "shopId": shopId,
+        "openId": app.globalData.userInfo?.liteOpenid,
+        "goodsInfos": [{
+          "goodsId": id,
+          "goodsNum": 1,
+          "goodsType": "ACTIVATION_CODE",
+          "paymentCashAmount": salePrice,
+          "paymentCouponAmount": 0
+        }],
+        "orderName": name,
+        "orderDesc": name
+      })
+      if (data.code === 200) {
+        const { paymentConfig, paymentType, orderNo } = data.data
         // 测试h5页面支付流程
         const params = {
-          // paymentType: paymentType, //'adapay-cooleshow-6560',
-          // pay_channel: 'wx_pub',
-          // wxAppId: paymentConfig.wxAppId, //'wxbde13f59d40cb4f2',
-          // body: paymentConfig.body, //'aaa',
-          // price: paymentConfig.price, // '0.01',
-          // orderNo: paymentConfig.merOrderNo,
-          // userId: paymentConfig.userId
+          paymentType: paymentType, //'adapay-cooleshow-6560',
+          pay_channel: 'wx_pub',
+          wxAppId: paymentConfig.wxAppId, //'wxbde13f59d40cb4f2',
+          body: paymentConfig.body, //'aaa',
+          price: paymentConfig.price, // '0.01',
+          orderNo: paymentConfig.merOrderNo,
+          userId: paymentConfig.userId
         }
         wx.navigateTo({
           url: '../order-webview/order-webview?orderInfo=' + encodeURIComponent(JSON.stringify(params))
         })
 
         wx.hideLoading()
-      // } else {
-      //   wx.hideLoading()
-      //   wx.showToast({
-      //     title: '购买失败',
-      //     icon: 'none'
-      //   })
-      // }
+      } else {
+        wx.hideLoading()
+        wx.showToast({
+          title: '购买失败',
+          icon: 'none'
+        })
+      }
     } catch {
       wx.hideLoading()
     }

+ 2 - 1
miniprogram/pages/order-webview/order-webview.ts

@@ -15,7 +15,8 @@ Page({
   onLoad(options: any) {
     if(options.orderInfo) {
       const orderInfo = JSON.parse(decodeURIComponent(options.orderInfo));
-      const url = app.globalData.baseUrl + `/classroom-app/?code=1#/payResultWechat?paymentType=${orderInfo.paymentType}&pay_channel=${orderInfo.pay_channel}&wxAppId=${orderInfo.wxAppId}&body=${orderInfo.body}&price=${orderInfo.price}&orderNo=${orderInfo.orderNo}&userId=${orderInfo.userId}`
+      const url = app.globalData.baseUrl + `/classroom-app/#/payResultWechat?paymentType=${orderInfo.paymentType}&pay_channel=${orderInfo.pay_channel}&wxAppId=${orderInfo.wxAppId}&body=${orderInfo.body}&price=${orderInfo.price}&orderNo=${orderInfo.orderNo}&userId=${orderInfo.userId}`
+      console.log(url, 'url')
       this.setData({
         src: url
       })