1.支付按钮,定义支付事件
<u-button text="立即抢购" @click="payTap" shape="circle" color="#E10000">u-button>
2.支付事件
let data = {
openId: this.openId,
courseId: this.detailsObj.id,
promoterId: this.promoterShareId ? this.promoterShareId : '',
receiveCouponId: this.detailsObj.receiveCouponId ? this.detailsObj.receiveCouponId : ''
}
wxCreateOrder(data).then(res => {
payment({
orderNumber: res.data.orderId,
openId: this.openId,
}).then(res1 => {
let twoData = res1.data.data
console.log(twoData, '返回密钥')
uni.requestPayment({
appId: twoData.appId,
timeStamp:twoData.timeStamp ? (twoData.timeStamp).toString() : '',
nonceStr: twoData.nonceStr,
package: twoData.packageStr,
signType: twoData.signType,
paySign: twoData.paySign,
success(result) {
console.log(result, '调起支付')
if (result.errMsg == "requestPayment:ok") {
uni.showLoading({
title: '获取订单状态..',
mask: true,
})
setOrderIsHaveData(_this.orderNum).then(data => {
uni.hideLoading()
_this.requestDataAll()
})
_this.paySuccess()
} else {
uni.showModal({
title: '',
content: '支付失败',
showCancel: false,
icon: 'none',
success(res) {}
})
}
},
fail(result) {
console.log(result)
uni.showModal({
title: '',
content: '支付失败',
showCancel: false,
icon: 'none',
success(res) {}
})
},
})
})
})

- 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