|
@@ -100,6 +100,7 @@ export default {
|
|
|
showLoading: false,
|
|
|
checked: false,
|
|
|
phone: '',
|
|
|
+ last: null,
|
|
|
payType: [
|
|
|
{
|
|
|
name: "支付宝",
|
|
@@ -114,6 +115,17 @@ export default {
|
|
|
],
|
|
|
rechargeList: []
|
|
|
},
|
|
|
+ //函数节流
|
|
|
+ throttle(fun, delay) {
|
|
|
+ let last = this.last;
|
|
|
+ const now = + new Date();
|
|
|
+ if (now - last > delay) {
|
|
|
+ fun();
|
|
|
+ this.last = now;
|
|
|
+ } else {
|
|
|
+ console.log('间隔太短了')
|
|
|
+ }
|
|
|
+ },
|
|
|
changePayType(type) {
|
|
|
this.curPayType = type.value;
|
|
|
},
|
|
@@ -137,7 +149,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- async toPay() {
|
|
|
+ toPay() {
|
|
|
if (this.checked && !this.phone) {
|
|
|
prompt.showDialog({
|
|
|
title: '友情提示',
|
|
@@ -156,25 +168,25 @@ export default {
|
|
|
cancel: function () {
|
|
|
console.log('取消绑定')
|
|
|
},
|
|
|
-
|
|
|
})
|
|
|
-
|
|
|
} else {
|
|
|
- let cur_pay_type = this.curPayType;
|
|
|
- let product_id = this.rechargeList[this.curSelect].product_id;
|
|
|
- let ret = null;
|
|
|
- if (cur_pay_type === 1) {
|
|
|
- ret = await configAliPay({ product_id: product_id, bid: this.bid, send_order_id: this.send_order_id });
|
|
|
- }
|
|
|
- else {
|
|
|
- ret = await configWxPay({ product_id: product_id, bid: this.bid, send_order_id: this.send_order_id });
|
|
|
- }
|
|
|
- // 成功支付后的回调操作
|
|
|
- if (ret.code === "9000") this.showWaitingWrap(ret);
|
|
|
- else this.showToastByCode(ret.code);
|
|
|
+ this.throttle(() => { this.payFunc() }, 1000)
|
|
|
}
|
|
|
+ },
|
|
|
+ async payFunc() {
|
|
|
|
|
|
-
|
|
|
+ let cur_pay_type = this.curPayType;
|
|
|
+ let product_id = this.rechargeList[this.curSelect].product_id;
|
|
|
+ let ret = null;
|
|
|
+ if (cur_pay_type === 1) {
|
|
|
+ ret = await configAliPay({ product_id: product_id, bid: this.bid, send_order_id: this.send_order_id });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ret = await configWxPay({ product_id: product_id, bid: this.bid, send_order_id: this.send_order_id });
|
|
|
+ }
|
|
|
+ // 成功支付后的回调操作
|
|
|
+ if (ret.code === "9000") this.showWaitingWrap(ret);
|
|
|
+ else this.showToastByCode(ret.code);
|
|
|
},
|
|
|
checkOrder(order_info) {
|
|
|
this.showLoading = true;
|