shish пре 2 година
родитељ
комит
72d1c55004

+ 47 - 7
hdApp/src/pagesPurchase/gatherPay.vue

@@ -20,8 +20,13 @@
         </block>
         </block>
         <block>
         <block>
           <div class="call-one-btn">
           <div class="call-one-btn">
-            <button class="button-com green pay-wx" v-if="orderTime>0" @click="wxPayFn" >微信支付</button>
-            <button class="button-com disable pay-wx" v-else>微信支付</button>
+            <block v-if="orderTime>0">
+              <button v-if="getPayType == 1" class="button-com green pay-wx" @click="wxPayFn(1)" >微信支付</button>
+              <button v-else class="button-com green pay-wx" @click="wxPayFn(0)" >微信支付</button>
+            </block>
+            <block v-else>
+              <button class="button-com disable pay-wx">微信支付</button>
+            </block>
           </div>
           </div>
         </block>
         </block>
       </div>
       </div>
@@ -44,12 +49,14 @@ export default {
       },
       },
       psdKey: '',
       psdKey: '',
       orderSn: '',
       orderSn: '',
-      actPrice: ''
+      actPrice: '',
+      getPayType:1
     };
     };
   },
   },
   onLoad (options) {
   onLoad (options) {
     this.orderSn = options.orderSn
     this.orderSn = options.orderSn
     this.actPrice = options.actPrice
     this.actPrice = options.actPrice
+    this.getPayType = options.getPayType
     this.orderTime = options.remainSecond - 10 > 0 ? (options.remainSecond - 10) : 0
     this.orderTime = options.remainSecond - 10 > 0 ? (options.remainSecond - 10) : 0
     this.orderTimeFun();
     this.orderTimeFun();
   },
   },
@@ -69,16 +76,18 @@ export default {
         this.orderTimeFun();
         this.orderTimeFun();
       },1000)
       },1000)
     },
     },
-    wxPayFn(){
+    wxPayFn(type){
       let that = this
       let that = this
-
       // #ifdef APP-PLUS
       // #ifdef APP-PLUS
       this.$msg('请用小程序打开,再支付')
       this.$msg('请用小程序打开,再支付')
       return false
       return false
       // #endif
       // #endif
-
       that.$util.confirmModal({content:'确认收到花材且无需售后?结清后订单不能再申请售后'},() => {
       that.$util.confirmModal({content:'确认收到花材且无需售后?结清后订单不能再申请售后'},() => {
-        that.confirmWxPayFn()
+        if(type == 1){
+          that.confirmWxPayFn()
+        }else{
+          that.confirmWxPayFnOld()
+        }
       })
       })
     },
     },
     confirmWxPayFn () {
     confirmWxPayFn () {
@@ -105,6 +114,37 @@ export default {
         wexinPay(res.data, this.getSuccess, this.getError)
         wexinPay(res.data, this.getSuccess, this.getError)
       })
       })
     },
     },
+    confirmWxPayFnOld() {
+      let currentMiniOpenId = uni.getStorageSync('currentMiniOpenId')
+      let that = this
+      if(!this.$util.isEmpty(currentMiniOpenId)){
+        that.weixinPayOld()
+      }else{
+        //没有miniOpenId补miniOpenId
+        uni.showLoading({mask:true})
+        uni.login({
+          provider: 'weixin',
+          success: res => {
+            postWxCode({ code: res.code }).then(subRes => {
+              uni.hideLoading()
+              if(subRes.data.currentMiniOpenId){
+                let thisMiniOpenId = subRes.data.currentMiniOpenId
+                uni.setStorageSync('currentMiniOpenId',thisMiniOpenId)
+                that.weixinPayOld()
+              }
+            })
+          }
+        })
+      }
+    },
+    weixinPayOld(){
+      let that = this
+      let currentMiniOpenId = uni.getStorageSync('currentMiniOpenId')
+      purchaseClearWxPay({ orderSn: this.orderSn,currentMiniOpenId:currentMiniOpenId }).then(res => {
+        that.orderSn = res.data.orderSn
+        wexinPay(res.data, this.getSuccess, this.getError)
+      })
+    },
     getSuccess () {
     getSuccess () {
       let that = this
       let that = this
       that.pageTo({ url: '/pagesPurchase/gatherResult', type: 2 })
       that.pageTo({ url: '/pagesPurchase/gatherResult', type: 2 })

+ 1 - 1
hdApp/src/pagesPurchase/gathering.vue

@@ -195,7 +195,7 @@ export default {
                 that.pageTo({ url: '/admin/clear/list', type: 2})
                 that.pageTo({ url: '/admin/clear/list', type: 2})
               })              
               })              
             }else{
             }else{
-              that.pageTo({ url: '/pagesPurchase/gatherPay?orderSn=' + res.data.orderSn + '&actPrice=' + res.data.actPrice+'&remainSecond='+res.data.remainSecond, type: 2 })
+              that.pageTo({ url: '/pagesPurchase/gatherPay?orderSn=' + res.data.orderSn + '&actPrice=' + res.data.actPrice+'&remainSecond='+res.data.remainSecond+'&getPayType='+res.data.getPayType, type: 2 })
             } 
             } 
           }
           }
         })
         })

+ 40 - 4
hdApp/src/pagesPurchase/wechatPay.vue

@@ -22,10 +22,12 @@
 <!-- #ifdef MP-WEIXIN -->
 <!-- #ifdef MP-WEIXIN -->
           <div class="call-one-btn">
           <div class="call-one-btn">
             <view v-if="Number(balance) >= Number(realPrice)">
             <view v-if="Number(balance) >= Number(realPrice)">
-              <button class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="wxPayFn">微信支付</button>
+              <button v-if="getPayType == 1" class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="wxPayFn">微信支付</button>
+              <button v-else class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="wxPayFnOld">微信支付</button>
             </view>
             </view>
             <view v-else>
             <view v-else>
-              <button class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="wxPayFn">微信支付</button>
+              <button v-if="getPayType == 1" class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="wxPayFn">微信支付</button>
+              <button v-else class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="wxPayFnOld">微信支付</button>
             </view>
             </view>
             <button class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="debtPay" v-if="hasDebtPay === '1'">赊账</button>
             <button class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="debtPay" v-if="hasDebtPay === '1'">赊账</button>
           </div>
           </div>
@@ -75,7 +77,8 @@ export default {
       pageId: '',
       pageId: '',
       remainPayTime:120,
       remainPayTime:120,
       hasDebtPay:0,
       hasDebtPay:0,
-      balance:0
+      balance:0,
+      getPayType:1
     };
     };
   },
   },
   onLoad (options) {
   onLoad (options) {
@@ -94,7 +97,7 @@ export default {
         if(res.code == 1){
         if(res.code == 1){
           this.realPrice = res.data.realPrice ? parseFloat(res.data.realPrice) : ''
           this.realPrice = res.data.realPrice ? parseFloat(res.data.realPrice) : ''
           this.orderSn = res.data.orderSn
           this.orderSn = res.data.orderSn
-
+          this.getPayType = res.data.getPayType
           that.hasDebtPay = res.data.hasDebtPay
           that.hasDebtPay = res.data.hasDebtPay
           that.balance = res.data.balance
           that.balance = res.data.balance
 
 
@@ -152,6 +155,39 @@ export default {
         }
         }
       })
       })
     },
     },
+    wxPayFnOld () {
+      let that = this
+      uni.showLoading({title: '加载中',mask:true})
+      purchaseWxPay({ orderSn: this.orderSn }).then(res => {
+        uni.hideLoading()
+        if(res.code == 1){
+          if(res.data.hasNoMiniOpenId && res.data.hasNoMiniOpenId == 1){
+              //没有miniOpenId,补miniOpenId
+              uni.login({
+                provider: 'weixin',
+                success: res => {
+                  uni.setStorageSync('code', res.code)
+                  postWxCode({ code: res.code }).then(subRes => {
+                    if(subRes.data.currentMiniOpenId){
+                      let currentMiniOpenId = subRes.data.currentMiniOpenId
+                      updateMiniOpenId({miniOpenId:currentMiniOpenId}).then(subRes=>{
+                        if(subRes.code == 1){
+                            that.$util.confirmModal({content:'网络开小差了,请继续',okText:'确认',singer:true},() => {
+                              that.wxPayFn()
+                            })
+                        }
+                      })
+                    }
+                  })
+                }
+              })
+          }else{
+            this.pageId = res.data.id
+            wexinPay(res.data, this.getSuccess, this.getError)
+          }
+        }
+      })
+    },
     getSuccess () {
     getSuccess () {
       let that = this
       let that = this
       that.pageTo({ url: '/pagesPurchase/particulars?id=' + that.pageId, type: 2 })
       that.pageTo({ url: '/pagesPurchase/particulars?id=' + that.pageId, type: 2 })

+ 13 - 2
mallApp/src/pages/callback/index.vue

@@ -32,7 +32,8 @@
         <block v-if="pageStatus == 1 || pageStatus == 2">
         <block v-if="pageStatus == 1 || pageStatus == 2">
           <div class="call-one-btn">
           <div class="call-one-btn">
             <button v-if="isYeBtnShow" class="button-com red pay-ye" @click="balancePayFn">余额支付</button>
             <button v-if="isYeBtnShow" class="button-com red pay-ye" @click="balancePayFn">余额支付</button>
-            <button class="button-com green pay-wx" @click="wxPayFn">微信支付</button>
+            <button v-if="getPayType == 1" class="button-com green pay-wx" @click="wxPayFn">微信支付</button>
+            <button v-else class="button-com green pay-wx" @click="wxPayFnOld">微信支付</button>
           </div>
           </div>
         </block>
         </block>
         <block v-else-if="pageStatus == 3 || pageStatus == 4 || pageStatus == 5">
         <block v-else-if="pageStatus == 3 || pageStatus == 4 || pageStatus == 5">
@@ -96,7 +97,8 @@ export default {
       payCallData: {},
       payCallData: {},
       setPassModal: false,
       setPassModal: false,
       totalPrice:0,
       totalPrice:0,
-      orderSn:''
+      orderSn:'',
+      getPayType:1
     };
     };
   },
   },
   computed: {
   computed: {
@@ -112,6 +114,7 @@ export default {
     },
     },
     init() {
     init() {
       this.orderSn = this.option.orderSn ? this.option.orderSn : ''
       this.orderSn = this.option.orderSn ? this.option.orderSn : ''
+      this.getPayType = this.option.getPayType
       if(this.option.totalPrice){
       if(this.option.totalPrice){
         this.totalPrice = parseFloat(Number(this.option.totalPrice))
         this.totalPrice = parseFloat(Number(this.option.totalPrice))
       }
       }
@@ -157,6 +160,14 @@ export default {
         }
         }
       })
       })
     },
     },
+    wxPayFnOld() {
+      let miniOpenId = uni.getStorageSync('miniOpenId')
+      wxPay({ orderSn: this.orderSn, couponId: this.option.couponId,miniOpenId:miniOpenId }).then(res => {
+        this.payCallData = res.data
+        wexinPay(res.data, this.paySuccess, this.payFail)
+        this.orderSn = res.data.orderSn ? res.data.orderSn : ''
+      })
+    },
     paySuccess() {
     paySuccess() {
       this.$util.pageTo({
       this.$util.pageTo({
         url: "/pages/callback/index",
         url: "/pages/callback/index",