shish 3 лет назад
Родитель
Сommit
e3d768e716
2 измененных файлов с 32 добавлено и 6 удалено
  1. 4 0
      hdApp/src/api/admin/index.js
  2. 28 6
      hdApp/src/pagesPurchase/wechatPay.vue

+ 4 - 0
hdApp/src/api/admin/index.js

@@ -1,5 +1,9 @@
 import https from '@/plugins/luch-request_0.0.7/request'
 
+export const updateMiniOpenId = data => {
+	return https.get("/admin/update-mini-open-id", data);
+};
+
 export const adminSetPayPassword = data => {
 	return https.get('/admin/set-pay-password', data)
 }

+ 28 - 6
hdApp/src/pagesPurchase/wechatPay.vue

@@ -42,12 +42,13 @@
 
 <script>
 import { purchaseBalancePay, purchaseDebtPay, purchaseWxPay,getDetail } from "@/api/purchase";
-import { getCgPayWay } from "@/api/shop/index";
 import keyboardModule from './components/keyboard'
 import { mapGetters } from "vuex";
 import wexinPay from "@/utils/pay/wxPay";
+import { postWxCode } from '@/api/mini'
+import { updateMiniOpenId } from '@/api/admin'
 export default {
-  name: "callback",
+  name: "wechatPay",
   components: {
     keyboardModule
   },
@@ -132,15 +133,36 @@ export default {
       
     },
     wxPayFn () {
+      let that = this
       uni.showLoading({title: '加载中',mask:true})
       purchaseWxPay({ orderSn: this.orderSn }).then(res => {
         uni.hideLoading()
         if(res.code == 1){
-          this.pageId = res.data.id
-          wexinPay(res.data, this.getSuccess, this.getError)
+          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)
+          }
         }
-      }).catch(err => {
-
       })
     },
     getSuccess () {