Explorar o código

会员支付接口调整

yuwenjun1997 %!s(int64=3) %!d(string=hai) anos
pai
achega
da2b9e979b

+ 4 - 1
src/views/components/payment/pay-alipay.vue

@@ -31,7 +31,7 @@ export default {
     this.init()
   },
   beforeDestroy() {
-    clearInterval(this.timer)
+    this.stopPayCheck()
   },
   methods: {
     init() {
@@ -71,6 +71,9 @@ export default {
           this.isLoading = false
         })
     },
+    stopPayCheck() {
+      clearInterval(this.timer)
+    },
     // 验证确认支付
     checkedPayConfirm() {
       this.timer = setInterval(() => {

+ 15 - 6
src/views/components/payment/pay-wechat.vue

@@ -1,6 +1,8 @@
 <template>
   <div class="pay-code">
-    <div class="paymount">扫码付款:<span class="exp">¥</span><span class="price">{{ data.payAmount | formatPrice }}</span></div>
+    <div class="paymount">
+      扫码付款:<span class="exp">¥</span><span class="price">{{ data.payAmount | formatPrice }}</span>
+    </div>
     <el-image v-loading="isLoading" :src="payUrl" class="qrcode" />
     <div class="pay-tip">
       <i class="icon-wechat" />
@@ -29,24 +31,31 @@ export default {
     this.drawQrcode()
   },
   beforeDestroy() {
-    clearInterval(this.timer)
+    this.stopPayCheck()
   },
   methods: {
     // 绘制支付二维码
     drawQrcode() {
-      const wxPayUri = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx91c4152b60ca91a3&redirect_uri=https://www.caimei365.com/pay/wechatpay.html&response_type=code&scope=snsapi_base&state=${JSON.stringify(this.data)}#wechat_redirect`
+      // const wxPayUri = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx91c4152b60ca91a3&redirect_uri=${process.env.VUE_APP_BASE_SERVER}/pay/wechatpay.html&response_type=code&scope=snsapi_base&state=${JSON.stringify(this.data)}#wechat_redirect`
+      const wxPayUri = `https://www-b.caimei365.com/wxcode.html?orderInfo=${encodeURIComponent(
+        JSON.stringify(this.data)
+      )}`
       qrcode
         .toDataURL(wxPayUri, { width: 180, margin: 0, errorCorrectionLevel: 'H', type: 'image/jpeg', scale: 1 })
-        .then(url => {
+        .then((url) => {
           this.payUrl = url
           this.checkedPayConfirm()
         })
-        .catch(err => {
+        .catch((err) => {
           console.error(err)
-        }).finally(() => {
+        })
+        .finally(() => {
           this.isLoading = false
         })
     },
+    stopPayCheck() {
+      clearInterval(this.timer)
+    },
     // 验证确认支付
     checkedPayConfirm() {
       this.timer = setInterval(() => {

+ 2 - 0
src/views/normal/vip/buy.vue

@@ -50,6 +50,7 @@
       <!-- 阿里云支付 -->
       <pay-alipay
         v-if="checkedPayWay === 1"
+        ref="aliPay"
         class="pay-code"
         :data="orderInfo"
         :pay-way="checkedPayWay"
@@ -59,6 +60,7 @@
       <!-- 微信支付 -->
       <pay-wechat
         v-if="checkedPayWay === 2"
+        ref="wechatPay"
         class="pay-code"
         :data="orderInfo"
         :pay-way="checkedPayWay"