// 支付
pay(e) {
if (this.falg === true) {
this.$tip.error('支付状态查询中')
return
}
const payType = e.currentTarget.dataset.id
let that = this;
that.$http.post(`/med/pay/qr/code?payType=${payType}&fee=${this.instrunctionFee}&orderId=${this.taskNo}`).then(res => {
if (res.data.success) {
let icfsignurl = res.data.result;
that.$refs.signQrcodePopul.autograph(icfsignurl);
that.yanZheng()
} else {
that.$tip.error(res.data.message)
}
}).catch(err => {
uni.showToast({
title: err,
icon: "none"
})
}).finally(() => {
uni.hideLoading();
})
},
// 查询支付订单状态
yanZheng() {
this.falg = true
const that = this
that.minute = setInterval(function() { //倒计时
that.nums = that.nums - 20
that.$http.post(`/med/pay/upcpPayQuery/?taskNo=${that.taskNo}`).then(res => {
if (res.data.success) {
that.$tip.success(res.data.result)
that.loadData()
that.resets()
} else {
that.$tip.error(res.data.message)
}
}).catch(err => {
uni.showToast({
title: err,
icon: "none"
})
}).finally(() => {
uni.hideLoading();
})
if (that.nums === 0) {
that.resets()
return
}
}, 20000) //一秒执行一次
},
resets() {
const that = this
clearInterval(that.minute);
that.nums = 60
that.falg = false
that.minute = null
that.$refs.signQrcodePopul.cancel();
},
- 注意一般支付订单时间60s,过了订单超时,无法支付。2. 注意用户在第二次轮询之后去支付,因此在第60s订单关闭之前去轮询一次状态,达到闭环。3 . 注意一分钟之内不能再去创建订单,支付成功之后才可以创建订单
版权声明:本文为gxdzi原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。