|
@@ -5,7 +5,7 @@
|
|
<span class="info-text">需支付金额</span>
|
|
<span class="info-text">需支付金额</span>
|
|
<span class="price-count">
|
|
<span class="price-count">
|
|
<span class="pc-l">¥</span>
|
|
<span class="pc-l">¥</span>
|
|
- <span class="pc-r">{{ orderInfo.price }}</span>
|
|
|
|
|
|
+ <span class="pc-r">{{ orderInfo.payMoney }}</span>
|
|
</span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<van-radio-group v-model="payWay">
|
|
<van-radio-group v-model="payWay">
|
|
@@ -61,7 +61,7 @@ export default class Pay extends Vue {
|
|
|
|
|
|
orderInfo = {
|
|
orderInfo = {
|
|
ordercode: '',
|
|
ordercode: '',
|
|
- paymoney: ''
|
|
|
|
|
|
+ payMoney: ''
|
|
}
|
|
}
|
|
|
|
|
|
// 将原型的全局变量提出来
|
|
// 将原型的全局变量提出来
|
|
@@ -92,7 +92,8 @@ export default class Pay extends Vue {
|
|
payWay = this.payPlatFormWayMap[this.env.platform][0].type
|
|
payWay = this.payPlatFormWayMap[this.env.platform][0].type
|
|
|
|
|
|
created () {
|
|
created () {
|
|
- this.orderInfo.ordercode = this.$route.params.ordercode
|
|
|
|
|
|
+ const query: any = this.$route.query
|
|
|
|
+ this.orderInfo.ordercode = query.ordercode
|
|
}
|
|
}
|
|
|
|
|
|
mounted () {
|
|
mounted () {
|
|
@@ -113,8 +114,8 @@ export default class Pay extends Vue {
|
|
this.getOrderDetail({ ordercode: this.orderInfo.ordercode }).then(res => {
|
|
this.getOrderDetail({ ordercode: this.orderInfo.ordercode }).then(res => {
|
|
toast.clear()
|
|
toast.clear()
|
|
if (res.error_code === 0) {
|
|
if (res.error_code === 0) {
|
|
- if (res.data.status === 1) {
|
|
|
|
- this.orderInfo.paymoney = res.data.paymoney
|
|
|
|
|
|
+ if (res.data && Object.keys(res.data).length !== 0) {
|
|
|
|
+ this.orderInfo.payMoney = res.data.payMoney
|
|
} else {
|
|
} else {
|
|
this.$toast(res.error_msg || '查询订单信息失败')
|
|
this.$toast(res.error_msg || '查询订单信息失败')
|
|
}
|
|
}
|
|
@@ -124,37 +125,38 @@ export default class Pay extends Vue {
|
|
|
|
|
|
// 确认支付
|
|
// 确认支付
|
|
confirmPay () {
|
|
confirmPay () {
|
|
- this.wxPayCallBack('')
|
|
|
|
- // this.$toast.loading({
|
|
|
|
- // message: '加载中...',
|
|
|
|
- // forbidClick: true,
|
|
|
|
- // duration: 0
|
|
|
|
- // })
|
|
|
|
- // const data = {
|
|
|
|
- // payway: this.payWay,
|
|
|
|
- // ordercode: this.orderInfo.ordercode
|
|
|
|
- // }
|
|
|
|
- // this.getPaySign(data).then(res => {
|
|
|
|
- // if (res.error_code === 0) {
|
|
|
|
- // this.$toast.clear()
|
|
|
|
- // if (res.status === 1) {
|
|
|
|
- // // 获取参数成功,判断是微信h5还是非微信h5
|
|
|
|
- // if (this.env.isWeiXinBrowser) {
|
|
|
|
- // this.wxPayCallBack(res.data.payStr)
|
|
|
|
- // } else {
|
|
|
|
- // this.appPayCallBack(res.data.payStr)
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // this.$toast(res.error_msg || '获取支付信息失败')
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
|
|
+ this.$toast.loading({
|
|
|
|
+ message: '加载中...',
|
|
|
|
+ forbidClick: true,
|
|
|
|
+ duration: 0
|
|
|
|
+ })
|
|
|
|
+ const data = {
|
|
|
|
+ payway: this.payWay,
|
|
|
|
+ ordercode: this.orderInfo.ordercode
|
|
|
|
+ }
|
|
|
|
+ this.getPaySign(data).then(res => {
|
|
|
|
+ if (res.error_code === 0) {
|
|
|
|
+ this.$toast.clear()
|
|
|
|
+ if (res.data && Object.keys(res.data).length !== 0) {
|
|
|
|
+ // 获取参数成功,判断是微信h5还是非微信h5
|
|
|
|
+ if (this.env.isWeiXinBrowser) {
|
|
|
|
+ this.wxPayCallBack(res.data.payStr)
|
|
|
|
+ } else {
|
|
|
|
+ this.appPayCallBack(res.data.payStr)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.$toast(res.error_msg || '获取支付信息失败')
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // https://web-jydev-ws.jianyu360.cn/weixin/pay/datareport/131659488644
|
|
// 微信h5支付逻辑
|
|
// 微信h5支付逻辑
|
|
- wxPayCallBack (paySign) {
|
|
|
|
- console.log('wxPay')
|
|
|
|
- console.log(paySign)
|
|
|
|
|
|
+ wxPayCallBack (paySign: string) {
|
|
|
|
+ const sign = paySign ? JSON.parse(paySign) : {}
|
|
|
|
+ console.log(this.$wxSdk)
|
|
|
|
+ console.log('sign---------------', sign)
|
|
if (!this.$wxSdk) {
|
|
if (!this.$wxSdk) {
|
|
return this.$toast({
|
|
return this.$toast({
|
|
message: '微信Sdk初始化失败',
|
|
message: '微信Sdk初始化失败',
|
|
@@ -162,34 +164,25 @@ export default class Pay extends Vue {
|
|
duration: 1000
|
|
duration: 1000
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- const sign = {
|
|
|
|
- timestamp: '',
|
|
|
|
- nonceStr: '',
|
|
|
|
- package: '',
|
|
|
|
- signType: '',
|
|
|
|
- paySign: '',
|
|
|
|
- appId: ''
|
|
|
|
- }
|
|
|
|
// 进行支付
|
|
// 进行支付
|
|
console.log(this.$wxSdk)
|
|
console.log(this.$wxSdk)
|
|
- this.$wxSdk.chooseWXPay({
|
|
|
|
|
|
+ this.$wxSdk.chooseWXPayForWeiXinJSBridge({
|
|
config: {
|
|
config: {
|
|
timestamp: sign.timestamp,
|
|
timestamp: sign.timestamp,
|
|
nonceStr: sign.nonceStr,
|
|
nonceStr: sign.nonceStr,
|
|
- package: sign.package,
|
|
|
|
signType: sign.signType,
|
|
signType: sign.signType,
|
|
- paySign: sign.paySign,
|
|
|
|
|
|
+ package: sign.prepayId,
|
|
|
|
+ paySign: sign.sign,
|
|
appId: sign.appId
|
|
appId: sign.appId
|
|
},
|
|
},
|
|
success: () => {
|
|
success: () => {
|
|
- console.log(123)
|
|
|
|
|
|
+ this.$router.replace(`/pay-success/${this.orderInfo.ordercode}`)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
// app支付逻辑
|
|
// app支付逻辑
|
|
- appPayCallBack (paySign) {
|
|
|
|
- console.log('appPay')
|
|
|
|
|
|
+ appPayCallBack (paySign: string) {
|
|
if (this.payWay === 'wx_app') {
|
|
if (this.payWay === 'wx_app') {
|
|
// 调微信支付
|
|
// 调微信支付
|
|
try {
|
|
try {
|