|
@@ -13,8 +13,7 @@
|
|
|
<view class="pay-content">
|
|
|
<view class="pay-list">
|
|
|
<radio-group @change="payRadioChange">
|
|
|
- <!-- #ifdef H5 || MP-WEIXIN -->
|
|
|
- <view class="pay-list-item" v-if="wxEnv">
|
|
|
+ <view class="pay-list-item">
|
|
|
<view class="pay-list-item-image">
|
|
|
<image class="image" src="/static/img/wechat-icon-new.png" mode="aspectFit" />
|
|
|
<view>微信支付</view>
|
|
@@ -23,7 +22,6 @@
|
|
|
<radio color="#2DCF8C" value="weixin" :checked="'weixin' === radioCurrent" />
|
|
|
</view>
|
|
|
</view>
|
|
|
- <!-- #endif -->
|
|
|
<template v-if="alipayEnv">
|
|
|
<view class="pay-list-item">
|
|
|
<view class="pay-list-item-image">
|
|
@@ -210,6 +208,11 @@ export default {
|
|
|
monthId: {
|
|
|
type: String,
|
|
|
default: null
|
|
|
+ },
|
|
|
+ // 室内扫码
|
|
|
+ isIndoor: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
@@ -299,26 +302,25 @@ export default {
|
|
|
* @param {String} deviceNo 设备编号(只有车位锁部分有)
|
|
|
* */
|
|
|
async gyBankPay() {
|
|
|
+ const { curOrderList, deviceNo, jumpUrl, payeeName, payeeId, pursueType, sanPay } = this;
|
|
|
const params = {
|
|
|
- orderList: this.curOrderList,
|
|
|
- deviceNo: this.deviceNo,
|
|
|
- jumpUrl: this.jumpUrl,
|
|
|
- payeeId: this.payeeId,
|
|
|
- payeeName: this.payeeName,
|
|
|
- pursueType: this.pursueType,
|
|
|
- vehicleNo: this.vehicleNo,
|
|
|
- sanPay: this.sanPay
|
|
|
+ orderList: curOrderList,
|
|
|
+ deviceNo,
|
|
|
+ jumpUrl,
|
|
|
+ payeeId,
|
|
|
+ payeeName,
|
|
|
+ pursueType,
|
|
|
+ vehicleNo,
|
|
|
+ sanPay
|
|
|
};
|
|
|
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;
|
|
|
+ location.href = res?.data?.url;
|
|
|
} else {
|
|
|
this.showToast('无需支付', 'info');
|
|
|
setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
location.reload();
|
|
|
}, 1000);
|
|
|
}
|
|
@@ -330,22 +332,19 @@ export default {
|
|
|
* @description: 贵阳银行包月支付
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- gyBankMonthPay() {
|
|
|
- this.$u.api
|
|
|
- .monthPay({
|
|
|
+ async gyBankMonthPay() {
|
|
|
+ try {
|
|
|
+ const params = {
|
|
|
monthId: this.monthId,
|
|
|
jumpUrl: this.jumpUrl
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- location.href = res?.data?.url;
|
|
|
- } else {
|
|
|
- this.showToast(res?.msg, 'error');
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- this.showToast('无法调起支付', 'error');
|
|
|
- });
|
|
|
+ };
|
|
|
+ const { code, data } = await this.$u.api.monthPay({ ...params });
|
|
|
+ if (code === 200) {
|
|
|
+ location.href = data?.url;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.showToast(error?.msg ?? '无法调起支付', 'error');
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 聚合支付
|
|
@@ -357,216 +356,150 @@ export default {
|
|
|
* @description: 聚合包月支付
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- juheMonthPay() {
|
|
|
- // 支付成功跳转到包月页面
|
|
|
- let params = {
|
|
|
- monthId: this.monthId,
|
|
|
- jumpUrl: this.jumpUrl
|
|
|
- };
|
|
|
- this.$u.api
|
|
|
- .monthlyWxPay(params)
|
|
|
- .then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- localStorage.setItem('jumpUrl', this.jumpUrl);
|
|
|
- location.href = res.data.qrCodeUrl;
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'error');
|
|
|
- });
|
|
|
+ async juheMonthPay() {
|
|
|
+ try {
|
|
|
+ const { monthId, jumpUrl } = this;
|
|
|
+ const { code, data } = await this.$u.api.monthlyWxPay({ monthId, jumpUrl });
|
|
|
+ if (code === 200) {
|
|
|
+ localStorage.setItem('jumpUrl', this.jumpUrl);
|
|
|
+ location.href = data?.qrCodeUrl;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.showToast(error?.msg ?? '拉起支付失败!', 'error');
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 微信支付
|
|
|
*/
|
|
|
- wechatPay() {
|
|
|
+ async wechatPay() {
|
|
|
+ const { curOrderList, vuex_wxinfo, deviceNo, payeeId, payeeName, vehicleNo, sanPay, couponPopup } = this;
|
|
|
const params = {
|
|
|
- orderList: this.curOrderList,
|
|
|
- openid: this.vuex_wxinfo.openId,
|
|
|
- deviceNo: this.deviceNo || undefined,
|
|
|
- payeeId: this.payeeId || undefined,
|
|
|
- payeeName: this.payeeName || undefined,
|
|
|
- vehicleNo: this.vehicleNo,
|
|
|
- sanPay: this.sanPay
|
|
|
+ orderList: curOrderList,
|
|
|
+ openid: vuex_wxinfo?.openId,
|
|
|
+ deviceNo,
|
|
|
+ payeeId,
|
|
|
+ payeeName,
|
|
|
+ vehicleNo,
|
|
|
+ sanPay,
|
|
|
+ couponMemberId: couponPopup?.radioCurrent
|
|
|
};
|
|
|
- if (this.couponPopup.radioCurrent) {
|
|
|
- params.couponMemberId = this.couponPopup.radioCurrent;
|
|
|
- }
|
|
|
- if (this.exportFlag) {
|
|
|
- this.$u.api.parkingWechatPayApi(params).then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- if (res.data.needPay) {
|
|
|
- $wxPay.wexinPay(res.data.wx).then((r) => {
|
|
|
- switch (Number(r.code)) {
|
|
|
- case 0: // 成功
|
|
|
- //#ifdef H5
|
|
|
- window.location.reload();
|
|
|
- //#endif
|
|
|
- break;
|
|
|
- case 1: // 取消
|
|
|
- this.$u.api
|
|
|
- .updateCouponStatusApi({
|
|
|
- orderList: this.curOrderList
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.showToast('已取消支付', 'info');
|
|
|
- window.location.reload();
|
|
|
- }
|
|
|
- });
|
|
|
- break;
|
|
|
- case 2: // 支付失败
|
|
|
- this.showToast('支付失败,请检查!', 'error');
|
|
|
- break;
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.showToast('无需支付', 'info');
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
- location.reload();
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.$u.api.wechatPayApi(params).then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- if (res.data.needPay) {
|
|
|
- $wxPay.wexinPay(res.data.wx).then((r) => {
|
|
|
- switch (Number(r.code)) {
|
|
|
- case 0: // 成功
|
|
|
- //#ifdef H5
|
|
|
- window.location.reload();
|
|
|
- //#endif
|
|
|
- break;
|
|
|
- case 1: // 取消
|
|
|
- this.$u.api
|
|
|
- .updateCouponStatusApi({
|
|
|
- orderList: this.curOrderList
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '已取消支付',
|
|
|
- type: 'info'
|
|
|
- });
|
|
|
- window.location.reload();
|
|
|
- }
|
|
|
- });
|
|
|
- break;
|
|
|
- case 2: // 支付失败
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '支付失败,请检查!',
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- break;
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: '无需支付',
|
|
|
- type: 'info'
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
- location.reload();
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- /**
|
|
|
- * @description: 微信包月支付
|
|
|
- * @return {*}
|
|
|
- */
|
|
|
- wechatMonthPay() {
|
|
|
- this.$u.api
|
|
|
- .wechatMonthlyPayapi({
|
|
|
- monthId: this.monthId,
|
|
|
- openid: this.vuex_wxinfo.openId
|
|
|
- })
|
|
|
- .then((r) => {
|
|
|
- if (r.code === 200) {
|
|
|
- $wxPay.wexinPay(r.data.wx).then((res) => {
|
|
|
- switch (Number(res.code)) {
|
|
|
+ const apiCall = this.exportFlag ? this.$u.api.parkingWechatPayApi : this.$u.api.wechatPayApi;
|
|
|
+ try {
|
|
|
+ const { code, data } = await apiCall({ ...params });
|
|
|
+ if (code === 200) {
|
|
|
+ if (data.needPay) {
|
|
|
+ $wxPay.weixinPay(data.wx).then((r) => {
|
|
|
+ const messageMap = {
|
|
|
+ 0: '成功',
|
|
|
+ 1: '已取消支付',
|
|
|
+ 2: '支付失败,请检查!'
|
|
|
+ };
|
|
|
+ switch (Number(r.code)) {
|
|
|
case 0: // 成功
|
|
|
//#ifdef H5
|
|
|
- location.href = this.jumpUrl;
|
|
|
+ location.reload();
|
|
|
//#endif
|
|
|
break;
|
|
|
case 1: // 取消
|
|
|
- this.showToast('已取消支付', 'info');
|
|
|
+ if (this.isCancelCoupon) {
|
|
|
+ this.cancelCoupon(messageMap[r.code]);
|
|
|
+ } else {
|
|
|
+ this.showToast(messageMap[r.code], 'info');
|
|
|
+ location.reload();
|
|
|
+ }
|
|
|
break;
|
|
|
case 2: // 支付失败
|
|
|
- this.showToast('支付失败,请检查!', 'error');
|
|
|
+ this.showToast(messageMap[r.code], 'error');
|
|
|
break;
|
|
|
}
|
|
|
});
|
|
|
+ } else {
|
|
|
+ this.showToast('无需支付', 'info');
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.hideLoading();
|
|
|
+ location.reload();
|
|
|
+ }, 1000);
|
|
|
}
|
|
|
+ }
|
|
|
+ } catch (error) {}
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @description: 取消优惠券
|
|
|
+ * @param {*} msg
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ async cancelCoupon(msg) {
|
|
|
+ try {
|
|
|
+ const { code } = await this.$u.api.updateCouponStatusApi({ orderList: this.curOrderList });
|
|
|
+ if (code === 200) {
|
|
|
+ this.showToast(msg, 'info');
|
|
|
+ location.reload();
|
|
|
+ }
|
|
|
+ } catch (error) {}
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @description: 微信包月支付
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ async wechatMonthPay() {
|
|
|
+ const { code, data } = await this.$u.api.wechatMonthlyPayapi({ monthId: this.monthId, openid: this.vuex_wxinfo.openId });
|
|
|
+ if (code === 200) {
|
|
|
+ $wxPay.weixinPay(data?.wx).then((res) => {
|
|
|
+ this.handleMonthlyPay.call(this, res);
|
|
|
});
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @description: 微信包月支付响应处理
|
|
|
+ * @param {*} response
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ handleMonthlyPay(response) {
|
|
|
+ const messageMap = {
|
|
|
+ 0: { title: '成功', jumpUrl: this.jumpUrl },
|
|
|
+ 1: { title: '已取消支付' },
|
|
|
+ 2: { title: '支付失败,请检查!', type: 'error' }
|
|
|
+ };
|
|
|
+ const message = messageMap[Number(response.code)];
|
|
|
+ this.showToast(message.title, message.type || 'info');
|
|
|
+ if (message.jumpUrl) {
|
|
|
+ location.href = message.jumpUrl;
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 直接通过后台获取贵阳银行微信支付地址
|
|
|
* @param {Array} list 需要支付的订单组合数组
|
|
|
* @param {Number} deviceNo 设备编号(在停车锁部分需要)
|
|
|
* */
|
|
|
- getWXPayByJava(orderList, deviceNo) {
|
|
|
- let params = {
|
|
|
- orderList: orderList,
|
|
|
+ async getWXPayByJava(orderList, deviceNo) {
|
|
|
+ const params = {
|
|
|
+ orderList,
|
|
|
openid: this.vuex_wxinfo.openId,
|
|
|
jumpUrl: this.jumpUrl,
|
|
|
- deviceNo: deviceNo ? deviceNo : null,
|
|
|
+ deviceNo: deviceNo || null,
|
|
|
payeeId: this.payeeId,
|
|
|
payeeName: this.payeeName,
|
|
|
pursueType: this.pursueType,
|
|
|
vehicleNo: this.vehicleNo,
|
|
|
sanPay: this.sanPay
|
|
|
};
|
|
|
- if (this.exportFlag) {
|
|
|
- this.$u.api
|
|
|
- .polyPayExportApi(params)
|
|
|
- .then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- if (res.data.needPay) {
|
|
|
- localStorage.setItem('jumpUrl', this.jumpUrl);
|
|
|
- location.href = res.data.qrCodeUrl;
|
|
|
- } else {
|
|
|
- this.showToast('无需支付', 'info');
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
- location.href = this.jumpUrl;
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- } else {
|
|
|
- uni.hideLoading();
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'error');
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.$u.api
|
|
|
- .ordinaryWxPay(params)
|
|
|
- .then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- if (res.data.needPay) {
|
|
|
- localStorage.setItem('jumpUrl', this.jumpUrl);
|
|
|
- location.href = res.data.qrCodeUrl;
|
|
|
- } else {
|
|
|
- this.showToast('无需支付', 'info');
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
- location.href = this.jumpUrl;
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- } else {
|
|
|
+ const apiCall = this.exportFlag ? this.$u.api.polyPayExportApi : this.$u.api.ordinaryWxPay;
|
|
|
+ try {
|
|
|
+ const { code, data } = await apiCall({ ...params });
|
|
|
+ if (code === 200) {
|
|
|
+ if (data.needPay) {
|
|
|
+ localStorage.setItem('jumpUrl', this.jumpUrl);
|
|
|
+ location.href = data.qrCodeUrl;
|
|
|
+ } else {
|
|
|
+ this.showToast('无需支付', 'info');
|
|
|
+ setTimeout(() => {
|
|
|
uni.hideLoading();
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'info');
|
|
|
- });
|
|
|
+ location.href = this.jumpUrl;
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ // this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'error');
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
@@ -614,11 +547,7 @@ export default {
|
|
|
// this.couponPopup.currentCoupon = this.couponPopup.couponList.find((item) => item.id === this.couponPopup.radioCurrent);
|
|
|
},
|
|
|
couponItemClick(item) {
|
|
|
- if (item.id === this.couponPopup.radioCurrent) {
|
|
|
- this.couponPopup.radioCurrent = '';
|
|
|
- } else {
|
|
|
- this.couponPopup.radioCurrent = item.id;
|
|
|
- }
|
|
|
+ this.couponPopup.radioCurrent = item.id === this.couponPopup.radioCurrent ? '' : item.id;
|
|
|
},
|
|
|
/**
|
|
|
* 优惠券确认
|
|
@@ -626,11 +555,9 @@ export default {
|
|
|
* @returns {any}
|
|
|
*/
|
|
|
confimCoupon() {
|
|
|
- if (this.couponPopup.radioCurrent) {
|
|
|
- this.couponPopup.currentCoupon = this.couponPopup.couponList.find((item) => item.id === this.couponPopup.radioCurrent);
|
|
|
- } else {
|
|
|
- this.couponPopup.currentCoupon = {};
|
|
|
- }
|
|
|
+ this.couponPopup.currentCoupon = this.couponPopup.radioCurrent
|
|
|
+ ? this.couponPopup.couponList.find((item) => item.id === this.couponPopup.radioCurrent)
|
|
|
+ : {};
|
|
|
this.couponPopup.show = false;
|
|
|
},
|
|
|
/**
|
|
@@ -639,16 +566,87 @@ export default {
|
|
|
* @returns {any}
|
|
|
*/
|
|
|
immediatePayment() {
|
|
|
- switch (this.radioCurrent) {
|
|
|
- case 'weixin': // 微信支付
|
|
|
- this.isMonthPay ? this.wechatMonthPay() : this.wechatPay();
|
|
|
- break;
|
|
|
- case 'gzyh':
|
|
|
- this.isMonthPay ? this.gyBankMonthPay() : this.gyBankPay();
|
|
|
- break;
|
|
|
- case 'juhe':
|
|
|
- this.isMonthPay ? this.juheMonthPay() : this.juhePay();
|
|
|
- break;
|
|
|
+ if (this.isIndoor) {
|
|
|
+ const relationObj = {
|
|
|
+ weixin: 'wechat',
|
|
|
+ gzyh: 'quick',
|
|
|
+ juhe: 'poly'
|
|
|
+ };
|
|
|
+ this.indoorPayment(relationObj[this.radioCurrent]);
|
|
|
+ } else {
|
|
|
+ switch (this.radioCurrent) {
|
|
|
+ case 'weixin': // 微信支付
|
|
|
+ this.isMonthPay ? this.wechatMonthPay() : this.wechatPay();
|
|
|
+ break;
|
|
|
+ case 'gzyh': // 贵州银行支付或快捷支付
|
|
|
+ this.isMonthPay ? this.gyBankMonthPay() : this.gyBankPay();
|
|
|
+ break;
|
|
|
+ case 'juhe': // 聚合支付
|
|
|
+ this.isMonthPay ? this.juheMonthPay() : this.juhePay();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @description: 室内支付
|
|
|
+ * @param {*} payMode
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ async indoorPayment(payMode) {
|
|
|
+ const { curOrderList, couponPopup, vuex_wxinfo, jumpUrl } = this;
|
|
|
+ const params = {
|
|
|
+ orderList: curOrderList,
|
|
|
+ payMode,
|
|
|
+ couponMemberId: couponPopup?.radioCurrent,
|
|
|
+ openid: vuex_wxinfo?.openId,
|
|
|
+ sanPay: true,
|
|
|
+ jumpUrl
|
|
|
+ };
|
|
|
+ const { code, data } = await this.$u.api.indoorPaymentApi({ ...params });
|
|
|
+ if (code === 200) {
|
|
|
+ if (data?.needPay) {
|
|
|
+ switch (payMode) {
|
|
|
+ case 'wechat': // 微信支付
|
|
|
+ $wxPay.weixinPay(data?.wechat?.wx).then((r) => {
|
|
|
+ const messageMap = {
|
|
|
+ 0: '成功',
|
|
|
+ 1: '已取消支付',
|
|
|
+ 2: '支付失败,请检查!'
|
|
|
+ };
|
|
|
+ switch (Number(r.code)) {
|
|
|
+ case 0: // 成功
|
|
|
+ //#ifdef H5
|
|
|
+ location.reload();
|
|
|
+ //#endif
|
|
|
+ break;
|
|
|
+ case 1: // 取消
|
|
|
+ if (this.isCancelCoupon) {
|
|
|
+ this.cancelCoupon(messageMap[r.code]);
|
|
|
+ } else {
|
|
|
+ this.showToast(messageMap[r.code], 'info');
|
|
|
+ location.reload();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2: // 支付失败
|
|
|
+ this.showToast(messageMap[r.code], 'error');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 'quick': // 快捷支付
|
|
|
+ location.href = data?.quick?.url;
|
|
|
+ break;
|
|
|
+ case 'poly':
|
|
|
+ localStorage.setItem('jumpUrl', this.jumpUrl);
|
|
|
+ location.href = data?.poly?.qrCodeUrl;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.showToast('无需支付', 'info');
|
|
|
+ setTimeout(() => {
|
|
|
+ location.href = this.jumpUrl;
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
/**
|