Kaynağa Gözat

跳转订单详情查询支付状态/退款优化

空白格 3 yıl önce
ebeveyn
işleme
cb733be309

+ 2 - 3
pages.json

@@ -224,9 +224,8 @@
 			"path": "pages/applyRefundDetails/applyRefundDetails",
 			"style": {
 				"navigationBarTitleText": "申请退款",
-				"enablePullDownRefresh": false,
-				"navigationBarBackgroundColor": "#008CFF",
-				"navigationBarTextStyle": "white"
+				"navigationStyle":"custom",
+				"enablePullDownRefresh": false
 			}
 
 		}, {

+ 16 - 8
pages/applyRefundDetails/applyRefundDetails.vue

@@ -1,5 +1,9 @@
 <template>
 	<view class="refund-details">
+		<u-navbar v-if="details.refundStatus === 0" :is-back="false" back-text="" title="申请退款" :background="{backgroundColor: '#008CFF'}" title-color="#fff"
+			back-icon-color="#fff"></u-navbar>
+		<u-navbar v-else back-text="" title="申请退款" :background="{backgroundColor: '#008CFF'}" title-color="#fff"
+				back-icon-color="#fff"></u-navbar>
 		<view class="refund-details-list">
 			<view class="refund-details-list-item">
 				<view class="rdli-label">申请时间:</view>
@@ -16,11 +20,7 @@
 			<view class="refund-details-list-item" v-if="details.images && details.images.length > 0">
 				<view class="rdli-label">图片:</view>
 				<view class="rdli-content">
-					<u-lazy-load
-						class="image"
-						v-for="(item, index) in details.images"
-						:key="index"
-						:image="item"
+					<u-lazy-load class="image" v-for="(item, index) in details.images" :key="index" :image="item"
 						img-mode="aspectFill"></u-lazy-load>
 				</view>
 			</view>
@@ -28,6 +28,9 @@
 		<view class="apply-button" v-if="details.refundStatus === 0">
 			<u-button type="primary" disabled>申请中</u-button>
 		</view>
+		<view class="apply-button" v-if="details.refundStatus === 0">
+			<u-button type="primary" @click="jumpPage('pages/center/order/order')">返回列表页</u-button>
+		</view>
 		<view class="refund-details-status" v-if="details.refundStatus === 2">
 			<view class="refund-details-status-item">
 				<view>处理时间:</view>
@@ -60,8 +63,8 @@
 		methods: {
 			getOrderRefundDetails(orderId) {
 				this.$u.api.getOrderRefundDetails({
-					orderId: orderId
-				})
+						orderId: orderId
+					})
 					.then(res => {
 						if (res.code === 200) {
 							this.details = res.data
@@ -78,11 +81,16 @@
 							type: 'error'
 						})
 					})
+			},
+			jumpPage(url) {
+				this.$u.route({
+					url
+				})
 			}
 		}
 	}
 </script>
 
 <style lang="scss" scoped>
-@import './applyRefundDetails.scss';
+	@import './applyRefundDetails.scss';
 </style>

+ 36 - 23
pages/center/order/orderDetails/orderDetails.vue

@@ -184,6 +184,7 @@ export default {
     return {
       orderId: null,
       openFlag: null,
+			polyOrderId: null,
       // 订单信息
       orderInfo: {},
       // 立即支付弹框
@@ -196,27 +197,26 @@ export default {
     }
   },
   onLoad (page) {
-    const orderId = page?.orderId
+    this.orderId = page?.orderId
 		// 该标识判断是否是从支付完成页面回调回来
-		const openFlag = page?.type
-		if (orderId) {
-			this.orderId = orderId
-			// 如果标识存在,证明需要执行轮询判断支付状态,否则直接查询
-			if (openFlag && openFlag === 'open') {
-				this.openFlag = openFlag
+		this.openFlag = page?.type
+		this.polyOrderId = page?.polyOrderId
+		if (this.orderId) {
+			// 如果type标识和支付订单id同时存在,证明需要执行轮询判断支付状态,否则直接查询
+			if (this.openFlag && this.polyOrderId) {
 				this.loadingMask = true
-				this.handleGetOrderinfo(orderId, openFlag)
+				this.handlePayStatus(this.polyOrderId)
 				let time = 0
 				this.timer = setInterval(() => {
 					time ++
-					this.handleGetOrderinfo(orderId, openFlag)
+					this.handlePayStatus(this.polyOrderId, openFlag)
 					// 超过60s直接清除轮询
 					if (time === 60) {
 						clearInterval(this.timer)
 					}
 				}, 1000)
 			} else {
-				this.handleGetOrderinfo(orderId)
+				this.handleGetOrderinfo(this.orderId)
 			}
 		}
   },
@@ -229,17 +229,11 @@ export default {
 		/**
 		 * 通过订单id去获取订单信息
 		 * */
-    handleGetOrderinfo (orderId, openFlag) {
+    handleGetOrderinfo (orderId) {
       this.$u.api.getOrderDetail({ id: orderId })
         .then(res => {
           if (res.code === 200) {
             this.orderInfo = res.data
-						if (openFlag === 'open') {
-							if (res.data.payStatus === 1 || res.data.payStatus === 3) {
-								this.loadingMask = false
-								clearInterval(this.timer)
-							}
-						}
           } else {
             this.$refs.uToast.show({
               title: res.msg,
@@ -247,13 +241,32 @@ export default {
             })
           }
         })
-        .catch(() => {
-          this.$refs.uToast.show({
-            title: '程序错误!',
-            type: 'error'
-          })
-        })
     },
+		/**
+		 * 查询支付状态
+		 * @param { String } orderId
+		 */
+		handlePayStatus(orderId) {
+			this.$u.api.getOrderInfo({ orderId }).then(res => {
+				if (res.code === 200) {
+					if (res.data.payStatus === 1 || res.data.payStatus === 3) {
+						this.loadingMask = false
+						clearInterval(this.timer);
+						this.handleGetOrderinfo(this.orderId)
+					}
+				} else {
+					this.$refs.uToast.show({
+					  title: res.msg,
+					  type: 'error'
+					})
+					this.loadingMask = false
+					clearInterval(this.timer);
+				}
+			}).catch(() => {
+				this.loadingMask = false
+				clearInterval(this.timer);
+			})
+		},
     goPay (orderId) {
       this.orderList = []
       this.orderList.push(orderId)

+ 38 - 11
pages/parkingLock/parkingLock.vue

@@ -265,7 +265,9 @@
 				orderId: null,
 				// 重定向地址
 				jumpUrl: location.href + '&isBack=1',
-				show: true
+				show: true,
+				isBack: '',
+				polyOrderId: ''
 			}
 		},
 		onLoad(page) {
@@ -275,6 +277,8 @@
 				this.orderId = page.orderId
 				this.orderList.push(page.orderId)
 				this.deviceNo = page.deviceNo
+				this.isBack = page?.isBack
+				this.polyOrderId = page?.polyOrderId
 			} else {
 				this.tipsMsg = page.msg || '参数丢失!';
 				this.parkingLockStatus = 5
@@ -282,10 +286,13 @@
 		},
 		onShow() {
 			if (this.orderId) {
-				this.timer1 = setInterval(() => {
-					this.show = true
-					this.getOrderDetails(this.orderId)
-				}, 2000)
+				this.getOrderDetails(this.orderId)
+				if (this.polyOrderId && this.isBack == 1) {
+					this.timer1 = setInterval(() => {
+						this.show = true
+						this.handlePayStatus(this.polyOrderId)
+					}, 2000)
+				}
 			} else {
 				this.show = false
 			}
@@ -399,18 +406,40 @@
 			confirmColor(e) {
 				this.vehicleColor = this.colorList[e].colorCode;
 			},
-
+			/**
+			 * 反复查询支付状态
+			 * @param { String } orderId
+			 */
+			handlePayStatus(orderId) {
+				this.$u.api.getOrderInfo({ orderId }).then(res => {
+					if (res.code === 200) {
+						if (res.data.payStatus === 1 || res.data.payStatus === 3) {
+							this.show = false
+							clearInterval(this.timer1);
+							this.getOrderDetails(this.orderId)
+						}
+					} else {
+						this.show = false
+						clearInterval(this.timer1);
+						this.$refs.uToast.show({
+							title: res.msg,
+							type: 'error',
+						});
+					}
+				}).catch(() => {
+					this.show = false
+					clearInterval(this.timer1);
+				})
+			},
 			payMoney() {
 				this.payWayPop = true
 			},
 			// 查询订单信息
 			getOrderDetails(id) {
-				// uni.showLoading({
-				//     title: '订单查询中'
-				// });
 				this.$u.api.getOrderDetail({
 					id: id
 				}).then(res => {
+
 					console.log(res)
 					if (res.code === 200) {
 						// 获取页面完整url
@@ -419,8 +448,6 @@
 						const locationLocaturl = window.location.search;
 						// 截取url中的isBack
 						let isBack = getUrlParams(local, "isBack");
-						console.log('isBack', isBack);
-						console.log('isBack', isBack == null || isBack != '1');
 						// 如果没有isBack,则去请求
 						if (!isBack) {
 							// uni.hideLoading();