Commit 525d682d authored by mengcuiguang's avatar mengcuiguang

添加虚拟支付

parent 3c628534
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
<script> <script>
import common from '@/mixins/common'; import common from '@/mixins/common';
import { message } from '@/utils/fun';
export default { export default {
name: 'coinPopup', name: 'coinPopup',
mixins: [common], mixins: [common],
...@@ -153,7 +154,7 @@ ...@@ -153,7 +154,7 @@
let vipBean = this.vipList[this.selectedIndex]; let vipBean = this.vipList[this.selectedIndex];
this.post({ this.post({
url: '/vip/getVipPayParams', url: '/vip/getVipPayParams/xpay',
data: { data: {
vedioId: that.point <= 0 ? null : that.vedioId, vedioId: that.point <= 0 ? null : that.vedioId,
pid: vipBean.pid, pid: vipBean.pid,
...@@ -163,7 +164,7 @@ ...@@ -163,7 +164,7 @@
success: ({ success: ({
data data
}) => { }) => {
that.wxPay(data, vipBean.largeType); that.wxVirtuallyPay(data, vipBean.largeType);
} }
}); });
}, },
...@@ -182,6 +183,70 @@ ...@@ -182,6 +183,70 @@
}, },
fail(res) {} fail(res) {}
}) })
},
wxVirtuallyPay(wxData, largeType) {
// 虚拟支付
let wxParams = wxData.params;
let signDataParams = wxData.params.sigData;
let that = this;
const SDKVersion = wx.getSystemInfoSync().SDKVersion;
if (this.compareVersion(SDKVersion, '2.19.2') >= 0 || wx.canIUse('requestVirtualPayment')) {
wx.requestVirtualPayment({
signData: JSON.stringify({
offerId: signDataParams.offerId,
buyQuantity: signDataParams.buyQuantity,
env: signDataParams.env,
currencyType: signDataParams.currencyType,
platform: signDataParams.platform,
productId: signDataParams.productId,
goodsPrice: signDataParams.goodsPrice,
outTradeNo: signDataParams.outTradeNo,
attach: signDataParams.attach,
}),
paySig: wxParams.paySign,
signature: wxParams.signature,
mode: wxParams.mode,
success(res) {
that.paySuccess(largeType);
},
fail({
errMsg,
errCode
}) {
message.notify(errMsg);
console.log('虚拟支付异常:errMsg='+errMsg+' errCode='+errCode);
},
})
} else {
message.notify('当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。');
}
},
compareVersion(_v1, _v2) {
if (typeof _v1 !== 'string' || typeof _v2 !== 'string') return 0
const v1 = _v1.split('.')
const v2 = _v2.split('.')
const len = Math.max(v1.length, v2.length)
while (v1.length < len) {
v1.push('0')
}
while (v2.length < len) {
v2.push('0')
}
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1[i], 10)
const num2 = parseInt(v2[i], 10)
if (num1 > num2) {
return 1
} else if (num1 < num2) {
return -1
}
}
return 0
} }
}, },
watch: { watch: {
......
...@@ -171,38 +171,38 @@ ...@@ -171,38 +171,38 @@
}, },
handlePhone() { handlePhone() {
// 联系我们 // 联系我们
// this.post({ this.post({
// url: '/vedio/customerServiceNumbers', url: '/vedio/customerServiceNumbers',
// showLoading: false, showLoading: false,
// success: ({ success: ({
// data data
// }) => { }) => {
// let datas = data.customerServiceNumbers.split(',') let datas = data.customerServiceNumbers.split(',')
// let corpid = datas[0] let corpid = datas[0]
// let curl = datas[1] let curl = datas[1]
// wx.openCustomerServiceChat({
// extInfo: {
// url: curl
// },
// corpId: corpid,
// success(res) {},
// fail(e) {
// console.log(e)
// }
// })
// }
// });
wx.makePhoneCall({ wx.openCustomerServiceChat({
phoneNumber: '4000969950', extInfo: {
success: function(res) { url: curl
console.log('拨打电话成功!');
}, },
fail: function(res) { corpId: corpid,
console.log('拨打电话失败!'); success(res) {},
fail(e) {
console.log(e)
} }
}) })
}
});
// wx.makePhoneCall({
// phoneNumber: '4000969950',
// success: function(res) {
// console.log('拨打电话成功!');
// },
// fail: function(res) {
// console.log('拨打电话失败!');
// }
// })
}, },
paySuccess(largeType) { paySuccess(largeType) {
// largeType=vip 开通vip // largeType=vip 开通vip
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment