uniapp 安卓app轮询订单处理

87 篇文章 1 订阅
31 篇文章 0 订阅
			// 支付
			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();
			},
  1. 注意一般支付订单时间60s,过了订单超时,无法支付。2. 注意用户在第二次轮询之后去支付,因此在第60s订单关闭之前去轮询一次状态,达到闭环。3 . 注意一分钟之内不能再去创建订单,支付成功之后才可以创建订单
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值