Commit 525d682d authored by mengcuiguang's avatar mengcuiguang

添加虚拟支付

parent 3c628534
......@@ -72,6 +72,7 @@
<script>
import common from '@/mixins/common';
import { message } from '@/utils/fun';
export default {
name: 'coinPopup',
mixins: [common],
......@@ -153,7 +154,7 @@
let vipBean = this.vipList[this.selectedIndex];
this.post({
url: '/vip/getVipPayParams',
url: '/vip/getVipPayParams/xpay',
data: {
vedioId: that.point <= 0 ? null : that.vedioId,
pid: vipBean.pid,
......@@ -163,7 +164,7 @@
success: ({
data
}) => {
that.wxPay(data, vipBean.largeType);
that.wxVirtuallyPay(data, vipBean.largeType);
}
});
},
......@@ -182,6 +183,70 @@
},
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: {
......
......@@ -171,38 +171,38 @@
},
handlePhone() {
// 联系我们
// this.post({
// url: '/vedio/customerServiceNumbers',
// showLoading: false,
// success: ({
// data
// }) => {
// let datas = data.customerServiceNumbers.split(',')
// let corpid = datas[0]
// let curl = datas[1]
// wx.openCustomerServiceChat({
// extInfo: {
// url: curl
// },
// corpId: corpid,
// success(res) {},
// fail(e) {
// console.log(e)
// }
// })
// }
// });
this.post({
url: '/vedio/customerServiceNumbers',
showLoading: false,
success: ({
data
}) => {
let datas = data.customerServiceNumbers.split(',')
let corpid = datas[0]
let curl = datas[1]
wx.makePhoneCall({
phoneNumber: '4000969950',
success: function(res) {
console.log('拨打电话成功!');
wx.openCustomerServiceChat({
extInfo: {
url: curl
},
fail: function(res) {
console.log('拨打电话失败!');
corpId: corpid,
success(res) {},
fail(e) {
console.log(e)
}
})
}
});
// wx.makePhoneCall({
// phoneNumber: '4000969950',
// success: function(res) {
// console.log('拨打电话成功!');
// },
// fail: function(res) {
// console.log('拨打电话失败!');
// }
// })
},
paySuccess(largeType) {
// 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