From 6aba65a85687a1c0c7332466c2a505ef62247ec5 Mon Sep 17 00:00:00 2001 From: ISFP_T <68358856@qq.com> Date: Wed, 8 Oct 2025 03:15:07 +0800 Subject: [PATCH] =?UTF-8?q?feat&fix=EF=BC=9A=E6=96=B0=E5=A2=9E=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=A7=9F=E5=80=9F=E7=AD=89=E5=BE=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=9B=E8=B0=83=E6=95=B4=E8=AE=A2=E5=8D=95=E5=BF=AB=E9=80=92?= =?UTF-8?q?=E5=BD=92=E8=BF=98=E5=89=8D=E7=BD=AE=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 10 +- pages/return/index.vue | 103 ++++++++++++---- pages/waiting/index.vue | 262 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 353 insertions(+), 22 deletions(-) create mode 100644 pages/waiting/index.vue diff --git a/pages.json b/pages.json index 92c4194..b14d889 100644 --- a/pages.json +++ b/pages.json @@ -84,7 +84,7 @@ { "path": "pages/return/index", "style": { - "navigationBarTitleText": "归还设备", + "navigationBarTitleText": "订单详情", "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black" } @@ -119,6 +119,14 @@ "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black" } + }, + { + "path": "pages/waiting/index", + "style": { + "navigationBarTitleText": "设备弹出中", + "navigationBarBackgroundColor": "#ffffff", + "navigationBarTextStyle": "black" + } } ], "globalStyle": { diff --git a/pages/return/index.vue b/pages/return/index.vue index 9d47e4e..38c4b9a 100644 --- a/pages/return/index.vue +++ b/pages/return/index.vue @@ -118,7 +118,12 @@ 刷新状态 - 返回首页 + + {{ formatHms(countdownRemaining) }} 后可发起快递归还 + + + 暂停计费,快递归还 + import { queryById, - cancelOrder + cancelOrder, + getSystemConfig } from '@/config/user.js' import { URL @@ -170,7 +176,11 @@ maxStatusChecks: 30, // 最多检查30次 currentStatusChecks: 0, statusCheckInterval: 5000, // 5秒检查一次 - isPageActive: false // 跟踪页面是否活跃 + isPageActive: false, // 跟踪页面是否活跃 + // 倒计时与快递归还触发(默认4小时=14400秒,可被配置覆盖) + countdownRemaining: 14400, + showExpressAction: false, + countdownTimer: null } }, onLoad(options) { @@ -207,6 +217,14 @@ // 注册全局订单完成事件监听器 uni.$on('orderCompleted', this.handleOrderCompleted) + + // 获取系统配置,覆盖默认倒计时 + this.loadSystemConfig().then(() => { + // 如果进入时就是使用中状态,启动倒计时 + if (this.orderInfo.orderStatus === 'in_used') { + this.startExpressCountdown() + } + }) }, // 添加onHide生命周期,处理页面隐藏时的清理工作 onHide() { @@ -217,6 +235,7 @@ // 清理所有计时器 this.clearTimer() this.clearStatusCheckTimer() + this.clearExpressCountdown() // 从全局订单监控服务中移除当前订单 this.removeFromOrderMonitor() @@ -229,6 +248,7 @@ // 页面卸载时清除定时器 this.clearTimer() this.clearStatusCheckTimer() + this.clearExpressCountdown() // 从全局订单监控服务中移除当前订单 this.removeFromOrderMonitor() @@ -237,6 +257,50 @@ uni.$off('orderCompleted', this.handleOrderCompleted) }, methods: { + // 预留:加载系统配置,覆盖倒计时(单位:秒) + async loadSystemConfig() { + try { + const res = await getSystemConfig() + if (res && res.code === 200 && res.data && typeof res.data.expressReturnCountdownSeconds === 'number') { + const seconds = res.data.expressReturnCountdownSeconds + if (seconds > 0) { + this.countdownRemaining = seconds + } + } + } catch (e) { + // 后端未实现或网络错误时,沿用默认 + } + }, + // 启动快递归还倒计时 + startExpressCountdown() { + this.clearExpressCountdown() + this.showExpressAction = false + // 使用当前设定的倒计时(可能已被系统配置覆盖) + this.countdownTimer = setInterval(() => { + if (!this.isPageActive) { + this.clearExpressCountdown() + return + } + if (this.orderInfo.orderStatus !== 'in_used') { + this.clearExpressCountdown() + return + } + if (this.countdownRemaining > 0) { + this.countdownRemaining -= 1 + } else { + this.showExpressAction = true + this.clearExpressCountdown() + } + }, 1000) + }, + + // 清除倒计时 + clearExpressCountdown() { + if (this.countdownTimer) { + clearInterval(this.countdownTimer) + this.countdownTimer = null + } + }, // 从订单监控服务中移除当前订单 removeFromOrderMonitor() { if (this.orderInfo.orderId && this.$orderMonitor) { @@ -359,6 +423,8 @@ this.startTimer() // 启动状态检查定时器 this.startStatusCheckTimer() + // 启动快递归还倒计时 + this.startExpressCountdown() // 记录当前活跃订单ID uni.setStorageSync('activeOrderId', this.orderInfo.orderId) @@ -647,24 +713,10 @@ }) }, expressRetrunOrder() { - uni.showLoading(); - setTimeout(() => { - uni.hideLoading(); - uni.showModal({ - title: '提示', - content: '计费暂停,是否前往填写归还信息', - confirmText: '立即前往', - cancelText: '稍后填写', - success: (res) => { - if (res.confirm) { - uni.navigateTo({ - url: `/pages/expressReturn/addExpressReturn?orderId=${this.orderInfo.orderId}` - }) - } - } - }) - }, 3000) - + // 触发快递归还申请:跳转到填写页(由填写页调用申请接口) + uni.navigateTo({ + url: `/pages/expressReturn/addExpressReturn?orderId=${this.orderInfo.orderId}` + }) }, // 取消订单 @@ -721,6 +773,15 @@ const remainingMins = mins % 60; return remainingMins > 0 ? `${hours}小时${remainingMins}分钟` : `${hours}小时`; } + }, + // 格式化倒计时(秒)为 hh:mm:ss + formatHms(totalSeconds) { + if (typeof totalSeconds !== 'number' || totalSeconds < 0) return '00:00:00' + const hours = Math.floor(totalSeconds / 3600) + const minutes = Math.floor((totalSeconds % 3600) / 60) + const seconds = totalSeconds % 60 + const pad = (n) => n.toString().padStart(2, '0') + return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}` } } } diff --git a/pages/waiting/index.vue b/pages/waiting/index.vue new file mode 100644 index 0000000..5eac642 --- /dev/null +++ b/pages/waiting/index.vue @@ -0,0 +1,262 @@ + + + + + +