aXin-0810 9 ماه پیش
والد
کامیت
b161da9a49
2فایلهای تغییر یافته به همراه95 افزوده شده و 51 حذف شده
  1. 1 1
      src/packageMaterial/pages/apply/order.vue
  2. 94 50
      src/packageMaterial/pages/apply/pay.vue

+ 1 - 1
src/packageMaterial/pages/apply/order.vue

@@ -155,7 +155,7 @@ export default {
         websitBuyGoods: this.goodsList,
       }).then(res => {
         this.$navToPage({
-          url: `/packageMaterial/pages/apply/pay?orderId=${res.data}`
+          url: `/packageMaterial/pages/apply/pay?orderId=${res.data}&websitId=${this.websitId}&goodsType=${this.type}`
         })
       })
     },

+ 94 - 50
src/packageMaterial/pages/apply/pay.vue

@@ -42,18 +42,18 @@
 
         <view class="pay-container card mt30">
           <view class="top">支付信息</view>
-          <view class="item" v-for="(item, index) in 3" :key="index" @click="payNo = index">
+          <view class="item" v-for="(item, index) in payNoList" :key="index" @click="payNo = item.id">
             <view class="left">
               <text
                 :class="{
                   iconfont: true,
                   'icon-danxuan2': true,
-                  active: payNo === index
+                  active: payNo === item.id
                 }"
               ></text>
             </view>
             <view class="right">
-              <text class="text">微信支付</text>
+              <text class="text">{{ item.name }}</text>
             </view>
           </view>
         </view>
@@ -80,13 +80,26 @@ export default {
       errorText: '',
       detail: null,
       canScanCode: 0,
-      payNo: ''
+      payNoList: [],
+      payNo: '',
+      websitId: '',
+      goodsType: ''
     }
   },
 
-  onLoad({ orderId }) {
+  onLoad({ orderId, websitId, goodsType }) {
     this.orderId = orderId
+    this.websitId = websitId
+    this.goodsType = goodsType
     this.getDetail()
+    this.$api
+      .post('/material/salses/get/pay/config', {
+        goodsType: this.goodsType,
+        websitId: this.websitId
+      })
+      .then(res => {
+        this.payNoList = res.data
+      })
   },
 
   methods: {
@@ -133,56 +146,87 @@ export default {
 
     // 下单
     submitData() {
-      if (this.canScanCode > 0) return this.$toast(`请等待${this.canScanCode}秒后重试`)
-      mini_env(bool => {
-        this.$api
-          .post('/material/salses/pay', {
-            salesId: this.orderId,
-            ...(() => {
-              if (bool) {
-                return {
-                  miniPay: true,
-                  openId: this.$store.state.user.miniOpenId
-                }
-              }
-              return {}
-            })()
-          })
-          .then(res => {
-            if (!res.data.isPay) {
-              this.paySuccess()
-            } else {
-              if (bool) {
+      if (this.payNo) {
+        mini_env(bool => {
+          if (bool) {
+            this.$api
+              .post('/material/salses/save/pay/order', {
+                salesId: this.orderId,
+                payConfigId: this.payNo,
+                miniPay: true,
+                openId: this.$store.state.user.miniOpenId
+              })
+              .then(res => {
                 uniWebview.navigateTo({
-                  url: `/pages/pay/pay?${Object.entries({
-                    ...res.data,
-                    payPackage: res.data.payPackage.split('=')[0] || '',
-                    payPackageVal: res.data.payPackage.split('=')[1] || ''
+                  url: `/pages/pay/otherPay?${Object.entries({
+                    appOrderId: res.data.appOrderId,
+                    appid: res.data.appid
                   })
                     .map(item => item.join('='))
                     .join('&')}`
                 })
-              } else {
-                weixinPay(res.data, function (res) {
-                  that.paySuccess()
-                })
-              }
-            }
-          })
-          .catch(res => {
-            this.$tips(res.message)
-          })
-          .finally(() => {
-            this.canScanCode = 15
-            let time = setInterval(() => {
-              if (this.canScanCode > 0) {
-                this.canScanCode = this.canScanCode - 1
-              } else {
-                clearInterval(time)
-              }
-            }, 1000)
-          })
-      })
+              })
+          } else {
+            // 公众号支付
+            // weixinPay(res.data, function (res) {
+            //   that.paySuccess()
+            // })
+          }
+        })
+      } else {
+        this.$toast(`请选择支付商户`)
+      }
+      // if (this.canScanCode > 0) return this.$toast(`请等待${this.canScanCode}秒后重试`)
+      // mini_env(bool => {
+      // /material/salses/get/pay/config
+      // this.$api
+      //   .post('/material/salses/pay', {
+      //     salesId: this.orderId,
+      //     ...(() => {
+      //       if (bool) {
+      //         return {
+      //           miniPay: true,
+      //           openId: this.$store.state.user.miniOpenId
+      //         }
+      //       }
+      //       return {}
+      //     })()
+      //   })
+      //   .then(res => {
+      //     if (!res.data.isPay) {
+      //       this.paySuccess()
+      //     } else {
+      //       if (bool) {
+      //         uniWebview.navigateTo({
+      //           url: `/pages/pay/pay?${Object.entries({
+      //             ...res.data,
+      //             payPackage: res.data.payPackage.split('=')[0] || '',
+      //             payPackageVal: res.data.payPackage.split('=')[1] || ''
+      //           })
+      //             .map(item => item.join('='))
+      //             .join('&')}`
+      //         })
+      //       } else {
+      //         weixinPay(res.data, function (res) {
+      //           that.paySuccess()
+      //         })
+      //       }
+      //     }
+      //   })
+      //   .catch(res => {
+      //     this.$tips(res.message)
+      //   })
+      //   .finally(() => {
+      //     this.canScanCode = 15
+      //     let time = setInterval(() => {
+      //       if (this.canScanCode > 0) {
+      //         this.canScanCode = this.canScanCode - 1
+      //       } else {
+      //         clearInterval(time)
+      //       }
+      //     }, 1000)
+      //   })
+      // })
     },
 
     paySuccess() {