|
@@ -295,7 +295,7 @@ export default {
|
|
|
* @param {Array} orderList 需要支付的订单号组成的数组
|
|
|
* @param {String} deviceNo 设备编号(只有车位锁部分有)
|
|
|
* */
|
|
|
- gyBankPay() {
|
|
|
+ async gyBankPay() {
|
|
|
const params = {
|
|
|
orderList: this.curOrderList,
|
|
|
deviceNo: this.deviceNo,
|
|
@@ -306,54 +306,21 @@ export default {
|
|
|
vehicleNo: this.vehicleNo,
|
|
|
sanPay: this.sanPay
|
|
|
};
|
|
|
- if (this.exportFlag == true) {
|
|
|
- this.$u.api
|
|
|
- .quickPayExportApi(params)
|
|
|
- .then((res) => {
|
|
|
- if (res.data.needPay) {
|
|
|
- let payUrl = res.data.url;
|
|
|
- location.href = payUrl;
|
|
|
- } else {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '无需支付',
|
|
|
- type: 'info'
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
- location.reload();
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: err.msg,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.$u.api
|
|
|
- .payGzbank(params)
|
|
|
- .then((res) => {
|
|
|
- if (res.data.needPay) {
|
|
|
- let payUrl = res.data.url;
|
|
|
- location.href = payUrl;
|
|
|
- } else {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '无需支付',
|
|
|
- type: 'info'
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
- location.reload();
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: err.msg,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- });
|
|
|
+ const apiCall = this.exportFlag ? this.$u.api.quickPayExportApi : this.$u.api.payGzbank;
|
|
|
+ try {
|
|
|
+ const res = await apiCall({ ...params });
|
|
|
+ if (res.data.needPay) {
|
|
|
+ let payUrl = res.data.url;
|
|
|
+ location.href = payUrl;
|
|
|
+ } else {
|
|
|
+ this.showToast('无需支付', 'info');
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.hideLoading();
|
|
|
+ location.reload();
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ // this.showToast(err.msg, 'error');
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
@@ -370,18 +337,12 @@ export default {
|
|
|
if (res.code === 200) {
|
|
|
location.href = res?.data?.url;
|
|
|
} else {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: res.msg,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
+ this.showToast(res?.msg, 'error');
|
|
|
}
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '无法调起支付!',
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- });
|
|
|
+ .catch((err) => {
|
|
|
+ this.showToast('无法调起支付', 'error');
|
|
|
+ });
|
|
|
},
|
|
|
/**
|
|
|
* 聚合支付
|
|
@@ -408,10 +369,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: `无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
+ this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'error');
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
@@ -448,27 +406,18 @@ export default {
|
|
|
})
|
|
|
.then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '已取消支付',
|
|
|
- type: 'info'
|
|
|
- });
|
|
|
+ this.showToast('已取消支付', 'info');
|
|
|
window.location.reload();
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
|
case 2: // 支付失败
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '支付失败,请检查!',
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
+ this.showToast('支付失败,请检查!', 'error');
|
|
|
break;
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '无需支付',
|
|
|
- type: 'info'
|
|
|
- });
|
|
|
+ this.showToast('无需支付', 'info');
|
|
|
setTimeout(() => {
|
|
|
uni.hideLoading();
|
|
|
location.reload();
|
|
@@ -544,16 +493,10 @@ export default {
|
|
|
//#endif
|
|
|
break;
|
|
|
case 1: // 取消
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '已取消支付',
|
|
|
- type: 'info'
|
|
|
- });
|
|
|
+ this.showToast('已取消支付', 'info');
|
|
|
break;
|
|
|
case 2: // 支付失败
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '支付失败,请检查!',
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
+ this.showToast('支付失败,请检查!', 'error');
|
|
|
break;
|
|
|
}
|
|
|
});
|
|
@@ -586,10 +529,7 @@ export default {
|
|
|
localStorage.setItem('jumpUrl', this.jumpUrl);
|
|
|
location.href = res.data.qrCodeUrl;
|
|
|
} else {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '无需支付',
|
|
|
- type: 'info'
|
|
|
- });
|
|
|
+ this.showToast('无需支付', 'info');
|
|
|
setTimeout(() => {
|
|
|
uni.hideLoading();
|
|
|
location.href = this.jumpUrl;
|
|
@@ -600,10 +540,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: `无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
+ this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'error');
|
|
|
});
|
|
|
} else {
|
|
|
this.$u.api
|
|
@@ -614,10 +551,7 @@ export default {
|
|
|
localStorage.setItem('jumpUrl', this.jumpUrl);
|
|
|
location.href = res.data.qrCodeUrl;
|
|
|
} else {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '无需支付',
|
|
|
- type: 'info'
|
|
|
- });
|
|
|
+ this.showToast('无需支付', 'info');
|
|
|
setTimeout(() => {
|
|
|
uni.hideLoading();
|
|
|
location.href = this.jumpUrl;
|
|
@@ -628,10 +562,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: `无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
+ this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'info');
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -731,6 +662,15 @@ export default {
|
|
|
},
|
|
|
getDifference(a, b) {
|
|
|
return a > b ? a - b : 0;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @description: 显示报错信息
|
|
|
+ * @param {*} title
|
|
|
+ * @param {*} type
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ showToast(title, type = 'error') {
|
|
|
+ this.$refs.uToast.show({ title, type });
|
|
|
}
|
|
|
}
|
|
|
};
|