From 195c32873b1bdc81d93e3e2c2fa22dbc6ab2a42d Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Wed, 1 Apr 2026 08:49:07 +0800 Subject: [PATCH] 11 --- package1/order/orderList.vue | 198 ++++++++++++++++++++++++++--------- 1 file changed, 146 insertions(+), 52 deletions(-) diff --git a/package1/order/orderList.vue b/package1/order/orderList.vue index f578afc..5c553b0 100644 --- a/package1/order/orderList.vue +++ b/package1/order/orderList.vue @@ -50,80 +50,75 @@ 全部 - 待付款 + 待支付 + + 待成团 + + 待消费 + + 待接单 - 待发货 + 待取货 + + 待送达 + + 已完成 - 待收货 - - 待评价 + 待商家同意退款 + + 已退款 - 已关闭 + 已取消 - + 待支付 - - {{tab1Checked == 'paotui'?'跑腿':tab1Checked == 'ershou'?'二手':tab1Checked == 'fantuan'?'饭团':"订单"}} + {{item.orderType == 4 ? '快递' : item.orderType == 5 ? '跑腿' : item.orderType == 6 ? '二手':"饭团"}} - {{tab1Checked == 'paotui'?'跑腿帮送':tab1Checked == 'ershou'?'二手物品':tab1Checked == 'fantuan'?'竹仔园牛仔农庄(第六分店)':"订单详情"}} + {{item.orderType == 4 ? '快递代取' : item.orderType == 5 ? '跑腿帮送' : item.orderType == 6 ? '二手物品': item.shopName}} - - - - - - - 牛仔农庄(医专店) - - - - 打分;不要啦 - - - - - X1 - - - ¥90.00 - - - - - + @@ -147,9 +142,32 @@ + + + + + + + {{item1.productName}} + + + + {{item1.specs == null ? '' : item1.specs}} + + + + + X{{item1.quantity}} + + + ¥{{item1.price}} + + + + - - 待支付 23:59:23 + + 待支付 {{ formatTime(item.timeLeft) }} 实付(含包装/配送费) 取消订单 - 去支付 @@ -189,10 +207,12 @@ tab2Checked: 'quanbu', totalPages: 1, pageNum:1, + timer: null, orderList:[], searchForm:{ pageNum:1, pageSize:10, + searchType:0, userId:uni.getStorageSync('id'), regionId:JSON.parse(uni.getStorageSync('area')).id }, @@ -207,13 +227,85 @@ }, onLoad(option) { this.getOrderList() + this.startGlobalTimer() + }, + onUnload() { + // 页面卸载清除定时器 + if (this.timer) clearInterval(this.timer) }, onShow() { this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() }, methods: { + // 1. 开启全局定时器 + startGlobalTimer() { + // 立即执行一次,避免等待1秒才显示 + this.updateCountdown() + + this.timer = setInterval(() => { + this.updateCountdown() + }, 1000) + }, + + // 2. 核心逻辑:计算每条数据的剩余时间 + updateCountdown() { + const now = new Date().getTime() + + this.orderList.forEach(item => { + const reg = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/ + const match = item.createTime.match(reg) + + if (match) { + // 2. 手动构造时间 (注意:月份要减 1,因为 JS 月份是 0-11) + // 这种写法在 iOS 上绝对不会报错 + let targetTime = new Date( + parseInt(match[1]), // 年 + parseInt(match[2]) - 1, // 月 (记得减1) + parseInt(match[3]), // 日 + parseInt(match[4]), // 时 + parseInt(match[5]), // 分 + parseInt(match[6]) // 秒 + ).getTime() + + // 3. 加上 1 小时 + targetTime = targetTime + (60 * 60 * 1000) + + // 4. 计算差值 + const diff = targetTime - new Date().getTime() + + // 如果时间已过期,设为0 + item.timeLeft = diff > 0 ? diff : 0 + } + }) + }, + + // 3. 格式化时间 (毫秒 -> 天时分秒) + formatTime(ms) { + const second = Math.floor(ms / 1000) + const day = Math.floor(second / 86400) + const hour = Math.floor((second % 86400) / 3600) + const minute = Math.floor((second % 3600) / 60) + const sec = second % 60 + + // 补零操作 + const pad = (n) => n < 10 ? '0' + n : n + + // 根据需要返回格式,例如:1天 02时 05分 10秒 + return `${day > 0 ? day + '天' : ''}${pad(hour)}时${pad(minute)}分${pad(sec)}秒` + }, checkTab1(type) { this.tab1Checked = type + if(type == 'quanbu'){ + this.searchForm.searchType = 0 + }else if(type == 'fantuan'){ + this.searchForm.searchType = 1 + }else if(type == 'paotui'){ + this.searchForm.searchType = 2 + }else if(type == 'ershou'){ + this.searchForm.searchType = 3 + } + this.searchForm.pageNum = 1 + this.getOrderList() }, checkTabs2(type) { this.tab2Checked = type @@ -229,6 +321,7 @@ } else { that.orderList = [...that.orderList, ...res.result.records] } + console.log(that.orderList) that.totalPages = res.result.pages; // pages = 总页数 that.$forceUpdate(); } else { @@ -377,6 +470,7 @@ background: #fff; border-radius: 20rpx; padding: 20rpx; + position: relative; } .goods-img {