Переглянути джерело

添加微信支付取消回调后台返回券问题

zaijin 2 роки тому
батько
коміт
d29317ea8e
3 змінених файлів з 366 додано та 352 видалено
  1. 3 1
      common/apiurl.js
  2. 3 1
      common/http.api.js
  3. 360 350
      pages/paymentMethod/paymentMethod.vue

+ 3 - 1
common/apiurl.js

@@ -130,7 +130,9 @@ const apiurl = {
   // 查询优惠券列表
   couponListUrl: '/client/couponInfo/couponList',
   // 兑换优惠券
-  exchangeCouponUrl: '/client/couponInfo/couponExchange'
+  exchangeCouponUrl: '/client/couponInfo/couponExchange',
+	// 根据订单号刷新优惠券状态(用于取消支付情况)
+	updateCouponStatusUrl: '/client/couponInfo/backCoupon'
 };
 
 export { apiurl };

+ 3 - 1
common/http.api.js

@@ -118,6 +118,7 @@ const install = (Vue, vm) => {
 	let monthlyRuleDetailsApi = (params = {}) => vm.$u.get(apiurl.monthlyRuleDetailsUrl, params);
 	let couponListApi = (params = {}) => vm.$u.get(apiurl.couponListUrl, params);
   let exchangeCouponApi = (params = {}) => vm.$u.put(apiurl.exchangeCouponUrl, params);
+	let updateCouponStatusApi = (params = {}) => vm.$u.post(apiurl.updateCouponStatusUrl, params);
   // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
   vm.$u.api = {
     feedbackAdd,
@@ -181,7 +182,8 @@ const install = (Vue, vm) => {
     wechatMonthlyPayapi,
 		monthlyRuleDetailsApi,
 		couponListApi,
-    exchangeCouponApi
+    exchangeCouponApi,
+		updateCouponStatusApi
   };
 };
 

+ 360 - 350
pages/paymentMethod/paymentMethod.vue

@@ -9,18 +9,12 @@
 -->
 
 <template>
-  <view>
-    <u-modal
-      v-model="payWayPop"
-      :title-style="{ color: '#404040' }"
-      title="缴费方式"
-      width="660rpx"
-      :show-confirm-button="false"
-      :show-cancel-button="false"
-    >
-      <view class="slot-content">
-        <view class="pay-way-new">
-          <!-- <view class="pay-way-item pay-way-item-hy" @click="gyBankPay">
+	<view>
+		<u-modal v-model="payWayPop" :title-style="{ color: '#404040' }" title="缴费方式" width="660rpx"
+			:show-confirm-button="false" :show-cancel-button="false">
+			<view class="slot-content">
+				<view class="pay-way-new">
+					<!-- <view class="pay-way-item pay-way-item-hy" @click="gyBankPay">
 						<image src="../../static/img/guiyang-bank-icon.png" mode=""></image>
 						<view class="title">贵州银行</view>
 						<view class="subtitle">前三个月每天首次一分钱<br/>长期八折优惠</view>
@@ -29,348 +23,364 @@
 						<image src="../../static/img/juhe-icon.png" mode=""></image>
 						<view class="title">微信/支付宝</view>
 					</view> -->
-          <view class="pay-way-item pay-way-item-hy" @click="$u.debounce(gyBankPay, 1000, (immediate = true))">
-            <image src="/static/img/gyyh-icon.svg" mode=""></image>
-            <view class="title">贵州银行</view>
-          </view>
-          <!-- #ifdef H5 || MP-WEIXIN -->
-          <view class="pay-way-item pay-way-item-wx" @click="$u.debounce(wechatPay, 1000, (immediate = true))" v-if="wxEnv">
-            <image src="/static/img/weixin-icon.svg" mode=""></image>
-            <view class="title">微信支付</view>
-          </view>
-          <!-- #endif -->
-          <view class="pay-way-item pay-way-item-jh" @click="$u.debounce(juhePay, 1000, (immediate = true))">
-            <image src="/static/img/juhe-icon.svg" mode=""></image>
-            <view class="title">聚合支付</view>
-          </view>
-        </view>
-        <view class="pay-way-subtitle">
-          <view class="pay-way-subtitle-item">前三个月每天首次一分钱,长期八折优惠</view>
-          <!-- #ifdef H5 || MP-WEIXIN -->
-          <view class="pay-way-subtitle-item" v-if="wxEnv">&nbsp;</view>
-          <!-- #endif -->
-          <view class="pay-way-subtitle-item">&nbsp;</view>
-        </view>
-        <button class="pay-way-close-btn" @click="closePaymentMethod">关闭</button>
-      </view>
-    </u-modal>
-    <u-toast ref="uToast" />
-  </view>
+					<view class="pay-way-item pay-way-item-hy"
+						@click="$u.debounce(gyBankPay, 1000, (immediate = true))">
+						<image src="/static/img/gyyh-icon.svg" mode=""></image>
+						<view class="title">贵州银行</view>
+					</view>
+					<!-- #ifdef H5 || MP-WEIXIN -->
+					<view class="pay-way-item pay-way-item-wx" @click="$u.debounce(wechatPay, 1000, (immediate = true))"
+						v-if="wxEnv">
+						<image src="/static/img/weixin-icon.svg" mode=""></image>
+						<view class="title">微信支付</view>
+					</view>
+					<!-- #endif -->
+					<view class="pay-way-item pay-way-item-jh" @click="$u.debounce(juhePay, 1000, (immediate = true))">
+						<image src="/static/img/juhe-icon.svg" mode=""></image>
+						<view class="title">聚合支付</view>
+					</view>
+				</view>
+				<view class="pay-way-subtitle">
+					<view class="pay-way-subtitle-item">前三个月每天首次一分钱,长期八折优惠</view>
+					<!-- #ifdef H5 || MP-WEIXIN -->
+					<view class="pay-way-subtitle-item" v-if="wxEnv">&nbsp;</view>
+					<!-- #endif -->
+					<view class="pay-way-subtitle-item">&nbsp;</view>
+				</view>
+				<button class="pay-way-close-btn" @click="closePaymentMethod">关闭</button>
+			</view>
+		</u-modal>
+		<u-toast ref="uToast" />
+	</view>
 </template>
 
 <script>
-import { getEnvIsWx } from '@/utils/judgEnvironment.js';
-import $wxPay from '@/utils/wxPay.js';
-export default {
-  props: {
-    // 弹框显示
-    payWayPop: {
-      type: Boolean,
-      default: false
-    },
-    // 订单数组
-    curOrderList: {
-      type: Array,
-      default: null
-    },
-    // 设备编号
-    deviceNo: {
-      type: String,
-      default: null
-    },
-    // 地磁支付需要字段
-    payeeId: {
-      type: String,
-      default: undefined
-    },
-    // 地磁支付需要字段
-    payeeName: {
-      type: String,
-      default: undefined
-    },
-    // 扫码支付需要字段
-    sanPay: {
-      type: Boolean,
-      default: false
-    },
-    // 追缴类型
-    pursueType: {
-      type: String,
-      default: undefined
-    },
-    // 车牌号
-    vehicleNo: {
-      type: String,
-      default: undefined
-    },
-    // 跳转页面
-    jumpUrl: {
-      type: String,
-      default: null
-    },
-    // 出口扫码   接口不一样
-    exportFlag: {
-      type: Boolean,
-      default: false
-    }
-  },
-  data() {
-    return {
-      wxEnv: true
-    };
-  },
-  created() {
-    this.wxEnv = getEnvIsWx();
-  },
-  methods: {
-    /**
-     * 贵阳银行支付
-     * @param {Array} orderList 需要支付的订单号组成的数组
-     * @param {String} deviceNo 设备编号(只有车位锁部分有)
-     * */
-    gyBankPay() {
-      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
-      };
-      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'
-            });
-          });
-      }
-    },
-    /**
-     * 聚合支付
-     * */
-    juhePay() {
-      this.getWXPayByJava(this.curOrderList, this.deviceNo);
-    },
-    /**
-     * 微信支付
-     */
-    wechatPay() {
-      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
-      };
-      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.$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);
-            }
-          }
-        });
-      } 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.$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);
-            }
-          }
-        });
-      }
-    },
-    /**
-     * 直接通过后台获取贵阳银行微信支付地址
-     * @param {Array} list 需要支付的订单组合数组
-     * @param {Number} deviceNo 设备编号(在停车锁部分需要)
-     * */
-    getWXPayByJava(orderList, deviceNo) {
-      let params = {
-        orderList: orderList,
-        openid: this.vuex_wxinfo.openId,
-        jumpUrl: this.jumpUrl,
-        deviceNo: 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.$refs.uToast.show({
-                  title: '无需支付',
-                  type: 'info'
-                });
-                setTimeout(() => {
-                  uni.hideLoading();
-                  location.href = this.jumpUrl;
-                }, 1000);
-              }
-            } else {
-              uni.hideLoading();
-            }
-          })
-          .catch((err) => {
-            this.$refs.uToast.show({
-              title: '无法调起微信支付!',
-              type: '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.$refs.uToast.show({
-                  title: '无需支付',
-                  type: 'info'
-                });
-                setTimeout(() => {
-                  uni.hideLoading();
-                  location.href = this.jumpUrl;
-                }, 1000);
-              }
-            } else {
-              uni.hideLoading();
-            }
-          })
-          .catch((err) => {
-            this.$refs.uToast.show({
-              title: '无法调起微信支付!',
-              type: 'error'
-            });
-          });
-      }
-    },
-    /**
-     * 关闭弹框
-     * */
-    closePaymentMethod() {
-      this.$emit('closePaymentMethod');
-    }
-  }
-};
+	import {
+		getEnvIsWx
+	} from '@/utils/judgEnvironment.js';
+	import $wxPay from '@/utils/wxPay.js';
+	export default {
+		props: {
+			// 弹框显示
+			payWayPop: {
+				type: Boolean,
+				default: false
+			},
+			// 订单数组
+			curOrderList: {
+				type: Array,
+				default: null
+			},
+			// 设备编号
+			deviceNo: {
+				type: String,
+				default: null
+			},
+			// 地磁支付需要字段
+			payeeId: {
+				type: String,
+				default: undefined
+			},
+			// 地磁支付需要字段
+			payeeName: {
+				type: String,
+				default: undefined
+			},
+			// 扫码支付需要字段
+			sanPay: {
+				type: Boolean,
+				default: false
+			},
+			// 追缴类型
+			pursueType: {
+				type: String,
+				default: undefined
+			},
+			// 车牌号
+			vehicleNo: {
+				type: String,
+				default: undefined
+			},
+			// 跳转页面
+			jumpUrl: {
+				type: String,
+				default: null
+			},
+			// 出口扫码   接口不一样
+			exportFlag: {
+				type: Boolean,
+				default: false
+			}
+		},
+		data() {
+			return {
+				wxEnv: true
+			};
+		},
+		created() {
+			this.wxEnv = getEnvIsWx();
+		},
+		methods: {
+			/**
+			 * 贵阳银行支付
+			 * @param {Array} orderList 需要支付的订单号组成的数组
+			 * @param {String} deviceNo 设备编号(只有车位锁部分有)
+			 * */
+			gyBankPay() {
+				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
+				};
+				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'
+							});
+						});
+				}
+			},
+			/**
+			 * 聚合支付
+			 * */
+			juhePay() {
+				this.getWXPayByJava(this.curOrderList, this.deviceNo);
+			},
+			/**
+			 * 微信支付
+			 */
+			wechatPay() {
+				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
+				};
+				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.$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);
+							}
+						}
+					});
+				} 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);
+							}
+						}
+					});
+				}
+			},
+			/**
+			 * 直接通过后台获取贵阳银行微信支付地址
+			 * @param {Array} list 需要支付的订单组合数组
+			 * @param {Number} deviceNo 设备编号(在停车锁部分需要)
+			 * */
+			getWXPayByJava(orderList, deviceNo) {
+				let params = {
+					orderList: orderList,
+					openid: this.vuex_wxinfo.openId,
+					jumpUrl: this.jumpUrl,
+					deviceNo: 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.$refs.uToast.show({
+										title: '无需支付',
+										type: 'info'
+									});
+									setTimeout(() => {
+										uni.hideLoading();
+										location.href = this.jumpUrl;
+									}, 1000);
+								}
+							} else {
+								uni.hideLoading();
+							}
+						})
+						.catch((err) => {
+							this.$refs.uToast.show({
+								title: '无法调起微信支付!',
+								type: '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.$refs.uToast.show({
+										title: '无需支付',
+										type: 'info'
+									});
+									setTimeout(() => {
+										uni.hideLoading();
+										location.href = this.jumpUrl;
+									}, 1000);
+								}
+							} else {
+								uni.hideLoading();
+							}
+						})
+						.catch((err) => {
+							this.$refs.uToast.show({
+								title: '无法调起微信支付!',
+								type: 'error'
+							});
+						});
+				}
+			},
+			/**
+			 * 关闭弹框
+			 * */
+			closePaymentMethod() {
+				this.$emit('closePaymentMethod');
+			}
+		}
+	};
 </script>
 
 <style lang="scss" scoped>
-@import './paymentMethod.scss';
+	@import './paymentMethod.scss';
 </style>