|
@@ -184,6 +184,22 @@
|
|
|
|
|
|
|
|
// },
|
|
// },
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ // 防抖函数
|
|
|
|
|
+ debounce(func, wait = 1000) {
|
|
|
|
|
+ return (...args) => {
|
|
|
|
|
+ // 清除之前的定时器
|
|
|
|
|
+ if (this.payDebounceTimer) {
|
|
|
|
|
+ clearTimeout(this.payDebounceTimer);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置新的定时器
|
|
|
|
|
+ this.payDebounceTimer = setTimeout(() => {
|
|
|
|
|
+ func.apply(this, args);
|
|
|
|
|
+ this.payDebounceTimer = null;
|
|
|
|
|
+ }, wait);
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
orderBindUser(orderId) {
|
|
orderBindUser(orderId) {
|
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
|
title: '加载中...'
|
|
title: '加载中...'
|
|
@@ -289,6 +305,7 @@
|
|
|
var data = {orderId:this.orderId,payType:payType};
|
|
var data = {orderId:this.orderId,payType:payType};
|
|
|
var that=this;
|
|
var that=this;
|
|
|
uni.showLoading();
|
|
uni.showLoading();
|
|
|
|
|
+
|
|
|
editPayType(data).then(
|
|
editPayType(data).then(
|
|
|
res => {
|
|
res => {
|
|
|
if(res.code==200){
|
|
if(res.code==200){
|
|
@@ -314,12 +331,28 @@
|
|
|
url: '/pages_user/user/otherPaymentOrder?orderId='+this.orderId
|
|
url: '/pages_user/user/otherPaymentOrder?orderId='+this.orderId
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- payOrder(){
|
|
|
|
|
|
|
+ // 防抖后的支付方法
|
|
|
|
|
+ payOrder: function() {
|
|
|
|
|
+ // 创建防抖函数实例
|
|
|
|
|
+ const debouncedPay = this.debounce(function() {
|
|
|
|
|
+ this.executePay();
|
|
|
|
|
+ }, 1000); // 1秒防抖时间,可以根据需要调整
|
|
|
|
|
+
|
|
|
|
|
+ // 执行防抖函数
|
|
|
|
|
+ debouncedPay();
|
|
|
|
|
+ },// 实际的支付执行逻辑
|
|
|
|
|
+ executePay() {
|
|
|
var data = {orderId:this.order.id,payType:this.order.payType};
|
|
var data = {orderId:this.order.id,payType:this.order.payType};
|
|
|
var that=this;
|
|
var that=this;
|
|
|
|
|
+
|
|
|
|
|
+ // 防止重复点击,可以添加加载状态
|
|
|
|
|
+ if (this.isPaying) return;
|
|
|
|
|
+ this.isPaying = true;
|
|
|
|
|
+
|
|
|
uni.showLoading();
|
|
uni.showLoading();
|
|
|
pay(data).then(
|
|
pay(data).then(
|
|
|
res => {
|
|
res => {
|
|
|
|
|
+ this.isPaying = false;
|
|
|
if(res.code==200){
|
|
if(res.code==200){
|
|
|
console.log(res);
|
|
console.log(res);
|
|
|
if(res.payType==1||res.payType==2||res.payType==3){
|
|
if(res.payType==1||res.payType==2||res.payType==3){
|
|
@@ -340,7 +373,7 @@
|
|
|
fail: function(err) {
|
|
fail: function(err) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
icon:'none',
|
|
icon:'none',
|
|
|
- title:'fail:' + JSON.stringify(err),
|
|
|
|
|
|
|
+ title:'支付失败',
|
|
|
});
|
|
});
|
|
|
console.log('fail:' + JSON.stringify(err));
|
|
console.log('fail:' + JSON.stringify(err));
|
|
|
uni.hideLoading();
|
|
uni.hideLoading();
|
|
@@ -350,22 +383,6 @@
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- // else if(res.payType==3){
|
|
|
|
|
- // uni.hideLoading();
|
|
|
|
|
- // if(that.order.isPrescribe){
|
|
|
|
|
- // //如果是处方订单开处方
|
|
|
|
|
- // uni.redirectTo({
|
|
|
|
|
- // url:"prescribe?orderId="+that.order.id
|
|
|
|
|
- // })
|
|
|
|
|
- // }
|
|
|
|
|
- // else{
|
|
|
|
|
- // //如果是普通订单
|
|
|
|
|
- // uni.redirectTo({
|
|
|
|
|
- // url:"success?order="+JSON.stringify(that.order)
|
|
|
|
|
- // })
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
}else{
|
|
}else{
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
icon:'none',
|
|
icon:'none',
|
|
@@ -373,10 +390,79 @@
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- rej => {}
|
|
|
|
|
|
|
+ rej => {
|
|
|
|
|
+ this.isPaying = false;
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ icon:'none',
|
|
|
|
|
+ title: '网络请求失败',
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
);
|
|
);
|
|
|
|
|
+ },
|
|
|
|
|
+ // payOrder(){
|
|
|
|
|
+ // var data = {orderId:this.order.id,payType:this.order.payType};
|
|
|
|
|
+ // var that=this;
|
|
|
|
|
+ // uni.showLoading();
|
|
|
|
|
+ // pay(data).then(
|
|
|
|
|
+ // res => {
|
|
|
|
|
+ // if(res.code==200){
|
|
|
|
|
+ // console.log(res);
|
|
|
|
|
+ // if(res.payType==1||res.payType==2||res.payType==3){
|
|
|
|
|
+ // uni.requestPayment({
|
|
|
|
|
+ // provider: 'wxpay',
|
|
|
|
|
+ // timeStamp: res.result.timeStamp,
|
|
|
|
|
+ // nonceStr:res.result.nonceStr,
|
|
|
|
|
+ // package: res.result.packageValue,
|
|
|
|
|
+ // signType: res.result.signType,
|
|
|
|
|
+ // paySign: res.result.paySign,
|
|
|
|
|
+ // success: function(res) {
|
|
|
|
|
+ // console.log('yess:' + JSON.stringify(res));
|
|
|
|
|
+ // uni.hideLoading();
|
|
|
|
|
+ // uni.redirectTo({
|
|
|
|
|
+ // url:"success?order="+JSON.stringify(that.order)
|
|
|
|
|
+ // })
|
|
|
|
|
+ // },
|
|
|
|
|
+ // fail: function(err) {
|
|
|
|
|
+ // uni.showToast({
|
|
|
|
|
+ // icon:'none',
|
|
|
|
|
+ // title:'fail:' + JSON.stringify(err),
|
|
|
|
|
+ // });
|
|
|
|
|
+ // console.log('fail:' + JSON.stringify(err));
|
|
|
|
|
+ // uni.hideLoading();
|
|
|
|
|
+ // },
|
|
|
|
|
+ // complete: (err) => {
|
|
|
|
|
+ // console.log('fail:' + JSON.stringify(err));
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+ // }
|
|
|
|
|
+ // // else if(res.payType==3){
|
|
|
|
|
+ // // uni.hideLoading();
|
|
|
|
|
+ // // if(that.order.isPrescribe){
|
|
|
|
|
+ // // //如果是处方订单开处方
|
|
|
|
|
+ // // uni.redirectTo({
|
|
|
|
|
+ // // url:"prescribe?orderId="+that.order.id
|
|
|
|
|
+ // // })
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // // else{
|
|
|
|
|
+ // // //如果是普通订单
|
|
|
|
|
+ // // uni.redirectTo({
|
|
|
|
|
+ // // url:"success?order="+JSON.stringify(that.order)
|
|
|
|
|
+ // // })
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // // }
|
|
|
|
|
+
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // uni.showToast({
|
|
|
|
|
+ // icon:'none',
|
|
|
|
|
+ // title: res.msg,
|
|
|
|
|
+ // });
|
|
|
|
|
+ // }
|
|
|
|
|
+ // },
|
|
|
|
|
+ // rej => {}
|
|
|
|
|
+ // );
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|