pay.js
2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import WxConfig from '@u/WxConfig'
import {commodity} from "@r/api";
const WX = new WxConfig(['chooseWXPay']);
// import { commodity } from '@r/api.js'
export default {
data() {
return {
}
},
mounted() {
},
methods: {
async chooseWXPay() {
if(this.appearance == 2 && !/^[a-zA-Z0-9]+$/.test(this.rechargeNumber)){
this.showToast('请输入正确的充值账号')
return
}
this.orderPay();
// let message;
// if(this.appearance === 1) {
// message = `是否确认为${this.mobile}进行充值`
// }
// this.dialog({
// title: '提示',
// message: message,
// })
// .then(() => {
// WX.chooseWXPay().then(res => {
// console.log(res)
// })
// })
// .catch(() => {
// this.showToast('取消成功')
// });
},
async orderPay() {
this.showLoading();
let {sessionId} = JSON.parse(sessionStorage.getItem('GL_EQUITY_USER_INFO'));
let orderCode = await commodity.getOrderCode({
sessionId,
supplier: this.supplier,
brandId: this.brandId
}).then(res => {
let { code, data, message } = res
if (code == 0) {
return data;
} else {
this.showToast(message)
}
})
let para = {
orderCode,
goodsId: this.selectData?this.selectData.id:this.denomination.id,
goodsQuality: 1,
rechargeNumber: this.rechargeNumber,
payMannerId: 11,
sessionId,
}
let payData = await commodity.payOrder(para).then(res => {
this.hideLoading()
let { code, data, message } = res
if (code == 0) {
return data;
} else {
this.showToast(message)
}
})
const { timeStamp,nonceStr, packages, signType, paySign } = payData;
WX.chooseWXPay(timeStamp,nonceStr, packages, signType, paySign).then(res => {
console.log(res)
if(this.appearance == 2){
let productName = this.businessList[this.typeSno].productName + this.denomination.denomination
window.vm.$router.replace({ name: 'cardRoll.process',query: {
rechargeNumber: this.rechargeNumber,
productName
}
})
}else {
window.vm.$router.replace({ name: 'cardRoll.success',query:{price: this.denomination.salesPrice} })
}
})
}
},
}