Explorar o código

支付逻辑修改

lilei %!s(int64=4) %!d(string=hai) anos
pai
achega
cad62e298d
Modificáronse 5 ficheiros con 68 adicións e 44 borrados
  1. 2 2
      App.vue
  2. 2 5
      libs/axios.js
  3. 0 3
      pages/agreement/agreement.vue
  4. 29 11
      pages/getOrder/getOrder.vue
  5. 35 23
      pages/index/index.vue

+ 2 - 2
App.vue

@@ -1,6 +1,6 @@
 <script>
-	const uat_URL = 'https://carwash.test.zyucgj.com/cw-wechat/' // 预发布
-	// const uat_URL = 'http://192.168.16.103:8103/cw-wechat/' // 本地
+	// const uat_URL = 'https://carwash.test.zyucgj.com/cw-wechat/' // 预发布
+	const uat_URL = 'http://192.168.16.103:8103/cw-wechat/' // 本地
 	const pro_URL = 'https://carwash.zyucgj.com/saas/clz/'  // 生产
 	const buildType = 0 // 打包环境对应类型,1 生产 0 预发布
 	const buildURL = buildType ? pro_URL : uat_URL // 打包后实际对应的url

+ 2 - 5
libs/axios.js

@@ -48,8 +48,8 @@ const request = (opts, hasToken) => {
 						setTimeout(function() {
 						  const currentRoute = getRoutePath();
 						  const url = `/pages/login/login?lanuch=${currentRoute.lanuch}&path=` + encodeURIComponent(currentRoute.url);
-						  uni.reLaunch({ url });
-						}, 1000);
+						  uni.redirectTo({ url });
+						}, 5000);
 					}
 					else{
 						uni.showToast({
@@ -73,11 +73,8 @@ const request = (opts, hasToken) => {
 function getRoutePath() {
   // eslint-disable-next-line no-undef
   const pages = getCurrentPages(); // 获取加载的页面
-
   const currentPage = pages[pages.length - 1]; // 获取当前页面的对象
-
   let url = currentPage.route; // 当前页面url
-
   const options = objToUrl(currentPage.options); // 如果要获取url中所带的参数可以查看options
 
   const lanuch = [

+ 0 - 3
pages/agreement/agreement.vue

@@ -337,9 +337,6 @@
 					<view class="MsoNormal">
 						【可分性】如果本服务协议中任何一条被视为废止、无效或因任何理由不可执行,该条应视为可分的且并不影响任何其余条款的有效性和可执行性。
 					</view>
-					<view class="MsoNormal">
-						<text>如您对本服务协议有任何问题或建议,请在工作时间联系智能快洗客服部门(联系方式:</text>029-89150750-363<text>)</text>
-					</view>
 					<view class="MsoNormal">
 						再次感谢您的耐心阅读!
 					</view>

+ 29 - 11
pages/getOrder/getOrder.vue

@@ -390,11 +390,7 @@
 						let data = res.data
 						// 0元订单直接支付成功,不用吊微信支付
 						if (data.tradeStatus && data.tradeStatus == "PAID") {
-							this.$store.state.vuex_orderInfo.orderStatus = 'PAID'
-							// 付款成功后开始洗车
-							uni.redirectTo({
-								url: `/pages/work/index/index`
-							})
+							this.paySuccess()
 						} else {
 							uni.requestPayment({
 								provider: 'wxpay',
@@ -405,14 +401,11 @@
 								paySign: data.paySign,
 								success: function(res) {
 									console.log('success:' + JSON.stringify(res));
-									this.$store.state.vuex_orderInfo.orderStatus = 'PAID'
-									// 付款成功后开始洗车
-									uni.redirectTo({
-										url: `/pages/work/index/index`
-									})
+									this.paySuccess()
 								},
 								fail: function(err) {
 									console.log('fail:' + JSON.stringify(err));
+									this.payFail(err)
 								}
 							});
 						}
@@ -420,8 +413,33 @@
 						this.toashMsg(res.message)
 					}
 				})
+			},
+			// 付款成功后
+			paySuccess(){
+				this.$store.state.vuex_orderInfo.orderStatus = 'PAID'
+				// 付款成功后开始洗车
+				uni.redirectTo({
+					url: `/pages/work/index/index`
+				})
+			},
+			// 付款失败或取消
+			payFail(err){
+				this.$store.state.vuex_orderInfo.orderStatus = 'FAIL'
+				let content = '支付失败,请重新下单'
+				if(err.errMsg.indexOf("cancel")>=0){
+					content = '支付取消,请重新下单'
+				}
+				uni.showModal({
+				    title: '提示',
+				    content: content,
+					showCancel: false,
+				    success: function (res) {
+				        if (res.confirm) {
+							uni.navigateBack()
+				        }
+				    }
+				});
 			}
-
 		}
 	}
 </script>

+ 35 - 23
pages/index/index.vue

@@ -275,31 +275,43 @@
 			// 扫码洗车
 			scanCode () {
 				let _this = this
-				// 检验是否登录或登录是否过期
-				checkLogin().then(res => {
-					if (res.status == '200') {
-						uni.scanCode({
-						    success: function (res) {
-						        console.log('条码类型:' + res.scanType);
-						        console.log('条码内容:' + res.result);
-								if(res.scanType !== 'WX_CODE'){
-									_this.toashMsg("无法识别此二维码")
-								}
-								uni.navigateTo({
-									url: res.result
-								})
-						    }
-						});
-						
-						// uni.navigateTo({
-						// 	url: `/pages/getOrder/getOrder?scene=100037,9998`
-						// })
-					} else if (res.status == '9001') {
+				uni.scanCode({
+				    success: function (res) {
+				        console.log('条码类型:' + res.scanType);
+				        console.log('条码内容:' + res.result);
+						if(res.scanType !== 'WX_CODE'){
+							_this.toashMsg("无法识别此二维码")
+						}
 						uni.navigateTo({
-							url: `/pages/login/login?lanuch=${false}&path=` + encodeURIComponent('/pages/index/index')
+							url: res.result
 						})
-					}
-				})
+				    }
+				});
+				// 检验是否登录或登录是否过期
+				// checkLogin().then(res => {
+				// 	if (res.status == '200') {
+				// 		uni.scanCode({
+				// 		    success: function (res) {
+				// 		        console.log('条码类型:' + res.scanType);
+				// 		        console.log('条码内容:' + res.result);
+				// 				if(res.scanType !== 'WX_CODE'){
+				// 					_this.toashMsg("无法识别此二维码")
+				// 				}
+				// 				uni.navigateTo({
+				// 					url: res.result
+				// 				})
+				// 		    }
+				// 		});
+						
+				// 		// uni.navigateTo({
+				// 		// 	url: `/pages/getOrder/getOrder?scene=100037,9998`
+				// 		// })
+				// 	} else if (res.status == '9001') {
+				// 		uni.navigateTo({
+				// 			url: `/pages/login/login?lanuch=${false}&path=` + encodeURIComponent('/pages/index/index')
+				// 		})
+				// 	}
+				// })
 			},
 			// 创建标记点 OPEN :正常营业  CLOSED:暂停营业  TO_BE_OPENED:待开业
 			createMarker(point) {