Bläddra i källkod

会员支付接口修改

yuwenjun1997 3 år sedan
förälder
incheckning
78a5991d5d

+ 6 - 6
.env.development

@@ -4,19 +4,19 @@ NODE_ENV = development
 ENV = 'development'
 
 # 测试地址 API接口
-VUE_APP_BASE_API = 'https://zplma-b.caimei365.com'
-# VUE_APP_BASE_API = 'http://192.168.2.68:8012'
+# VUE_APP_BASE_API = 'https://zplma-b.caimei365.com'
+VUE_APP_BASE_API = 'http://192.168.2.68:8012'
 
 # 文件上传 API接口地址
-VUE_APP_UPLOAD_API='https://zplma-b.caimei365.com'
-# VUE_APP_UPLOAD_API='http://192.168.2.68:8012'
+# VUE_APP_UPLOAD_API='https://zplma-b.caimei365.com'
+VUE_APP_UPLOAD_API='http://192.168.2.68:8012'
 
 # 二维码生成链接location
 VUE_APP_BASE_SERVER = 'https://www-b.caimei365.com'
 
 # 消息接口地址 WebSocket
-VUE_APP_SOCKET_SERVER = 'wss://zplma-b.caimei365.com/websocket?sessionSource=zplm_admin'
-# VUE_APP_SOCKET_SERVER = 'ws://192.168.2.68:8012/websocket?sessionSource=zplm_admin'
+# VUE_APP_SOCKET_SERVER = 'wss://zplma-b.caimei365.com/websocket?sessionSource=zplm_admin'
+VUE_APP_SOCKET_SERVER = 'ws://192.168.2.68:8012/websocket?sessionSource=zplm_admin'
 
 # 网站地址
 # VUE_APP_LOCAL = 'http://192.168.2.81:9527'

+ 8 - 3
src/views/components/payment/pay-alipay.vue

@@ -36,6 +36,7 @@ export default {
   methods: {
     init() {
       const params = {
+        payType: 'ZFBEWM',
         bankCode: 'ALIPAY',
         returnUrl: 'https://www.caimei365.com/',
         vipRecordId: this.data.vipRecordId
@@ -43,8 +44,12 @@ export default {
       this.isLoading = true
       payVipWithAlipay(params).then(res => {
         const result = JSON.parse(res.data)
-        if (result.code === '000000') {
-          this.payData = result.data
+        console.log(result)
+        if (result.rt2_retCode === '0000') {
+          this.payData = {
+            mbOrderId: result.rt5_orderId,
+            qrcodeUrl: result.rt8_qrcode
+          }
           this.drawQrcode()
         } else {
           this.$message.error('支付系统遇到点小问题,请稍后重试')
@@ -55,7 +60,7 @@ export default {
     // 绘制支付二维码
     drawQrcode() {
       qrcode
-        .toDataURL(this.payData.payUrl, { width: 180, margin: 0, errorCorrectionLevel: 'H', type: 'image/jpeg', scale: 4 })
+        .toDataURL(this.payData.qrcodeUrl, { width: 180, margin: 0, errorCorrectionLevel: 'H', type: 'image/jpeg', scale: 4 })
         .then(url => {
           this.payUrl = url
           this.checkedPayConfirm()

+ 29 - 20
src/views/components/payment/pay-bank.vue

@@ -30,6 +30,7 @@
         <el-button type="danger" size="mini" @click="handleConfirmPay">确 定</el-button>
       </span>
     </el-dialog>
+    <div class="iframe" style="display: none" v-html="iframe" />
   </div>
 </template>
 
@@ -74,12 +75,13 @@ export default {
       payData: {},
       confirmVisiable: false,
       userType: '',
-      payUrl: ''
+      payUrl: '',
+      iframe: ''
     }
   },
   computed: {
     bankCode() {
-      return this.bankList.find(item => item.id === this.checkedBank)
+      return this.bankList.find((item) => item.id === this.checkedBank)
     }
   },
   watch: {
@@ -96,7 +98,7 @@ export default {
   methods: {
     // 获取网银支付列表
     fetchBankcodeList() {
-      fetchBankcodeList().then(res => {
+      fetchBankcodeList().then((res) => {
         const result = JSON.parse(res.data)
         this.bankList = result.list
       })
@@ -132,8 +134,17 @@ export default {
     },
     // 提交
     onSubmit() {
+      if (!this.iframe) {
+        this.$message.warning('请选择付款银行')
+        return
+      }
       this.confirmVisiable = true
-      window.open(this.payData.payUrl, '_blank')
+      this.$nextTick(() => {
+        const onlineForm = document.getElementById('onlineForm')
+        this.payData = { mbOrderId: onlineForm.P2_orderId.value }
+        onlineForm.setAttribute('target', '_blank')
+        onlineForm.submit()
+      })
     },
     // 提交支付
     handlePay() {
@@ -148,28 +159,26 @@ export default {
       }
       const params = {
         bankCode: code,
+        payType: 'YL',
         returnUrl: 'https://www.caimei365.com',
         userType: this.userType,
         vipRecordId: this.data.vipRecordId
       }
       // 提交支付信息生成支付链接
       payVipWithUnion(params)
-        .then(res => {
-          const result = JSON.parse(res.data)
-          if (result.code === '000000') {
-            this.payData = result.data
-            // 触发事件
-            this.$emit('change', {
-              type: this.userType,
-              data: {
-                ...this.payData,
-                ...this.data
-              }
-            })
-          } else {
-            this.$message.error('支付系统遇到点小问题,请稍后重试')
-            this.isLoading = false
-          }
+        .then((res) => {
+          this.iframe = res.data
+          // 触发事件
+          this.$emit('change', {
+            type: this.userType,
+            data: {
+              ...this.data
+            }
+          })
+        })
+        .catch(() => {
+          this.$message.error('支付系统遇到点小问题,请稍后重试')
+          this.isLoading = false
         })
         .finally(() => {
           this.isLoading = false

+ 1 - 1
src/views/components/payment/pay-wechat.vue

@@ -36,7 +36,7 @@ export default {
     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`
       qrcode
-        .toDataURL(wxPayUri, { width: 180, margin: 0, errorCorrectionLevel: 'H', type: 'image/jpeg', scale: 4 })
+        .toDataURL(wxPayUri, { width: 180, margin: 0, errorCorrectionLevel: 'H', type: 'image/jpeg', scale: 1 })
         .then(url => {
           this.payUrl = url
           this.checkedPayConfirm()

+ 35 - 11
src/views/normal/vip/buy.vue

@@ -163,7 +163,7 @@ export default {
     // 获取套餐 服务配置列表
     fetchConfigureList() {
       fetchConfigureList()
-        .then(res => {
+        .then((res) => {
           this.packageList = res.data.packageList
           this.serviceList = res.data.serviceList
           // 设置初始值
@@ -177,7 +177,7 @@ export default {
     },
     // 设置订单信息(这个假订单)
     setOrderInfo() {
-      const findOne = this.packageList.find(item => item.id === this.checkedPackage)
+      const findOne = this.packageList.find((item) => item.id === this.checkedPackage)
       if (findOne) {
         this.orderInfo.payAmount = findOne.price
         this.orderInfo.vipId = findOne.id
@@ -202,13 +202,13 @@ export default {
         authUserId: this.$store.getters.authUserId,
         packageId: this.checkedPackage,
         services: this.checkedServiceList.join(',')
-      }).then(res => {
+      }).then((res) => {
         this.orderInfo.vipRecordId = res.data
       })
     },
     // 在线支付开关检测
     payOnlineChecked() {
-      payOnlineChecked().then(res => {
+      payOnlineChecked().then((res) => {
         if (res.data === '1') {
           this.paySwitch = true
         } else {
@@ -223,25 +223,25 @@ export default {
       }
       this.payType = e.type
       if (e.type === 'WEIXIN') {
-        this.checkedWinxinPaySuccess({ vipRecordId: e.data.vipRecordId })
+        this.checkedWinxinPaySuccess({ vipRecordId: e.data.vipRecordId, orderFlag: 0 })
       } else {
-        this.checkedOtherPaySuccess({ mbOrderId: e.data.mbOrderId })
+        this.checkedOtherPaySuccess({ mbOrderId: e.data.mbOrderId, orderFlag: 0 })
       }
     },
     // 查询是否成功(微信支付专用)
     checkedWinxinPaySuccess(params) {
-      checkedWinxinPaySuccess(params).then(res => {
-        this.handlePayResult(res)
+      checkedWinxinPaySuccess(params).then((res) => {
+        this.handleWixinPayResult(res)
       })
     },
     // 查询支付是否成功 (支付宝 银联)
     checkedOtherPaySuccess(params) {
-      checkedOtherPaySuccess(params).then(res => {
+      checkedOtherPaySuccess(params).then((res) => {
         this.handlePayResult(res)
       })
     },
-    // 处理支付查询结果
-    handlePayResult(result) {
+    // 处理微信支付查询结果
+    handleWixinPayResult(result) {
       result = JSON.parse(result.data)
       if (result.data.status === '1') {
         this.$store.dispatch('user/fetchUserVipInfo')
@@ -258,6 +258,30 @@ export default {
         })
       }
     },
+    // 处理网银支付宝支付查询结果
+    handlePayResult(result) {
+      result = JSON.parse(result.data)
+      console.log(result)
+      if (result.rt7_orderStatus === 'SUCCESS') {
+        this.$store.dispatch('user/fetchUserVipInfo')
+        this.$router.push({
+          path: '/pay/success',
+          query: this.redirectUrlQuery
+        })
+      } else if (result.rt7_orderStatus === 'DOING') {
+        this.diffScanOverTime(60 * 5, () => {
+          this.$router.push({
+            path: '/pay/faild',
+            query: this.redirectUrlQuery
+          })
+        })
+      } else {
+        this.$router.push({
+          path: '/pay/faild',
+          query: this.redirectUrlQuery
+        })
+      }
+    },
     // 扫码支付开始
     handleScanPayStart() {
       const h = this.$createElement