From 12826becd5c60e6b6bdbe8e8a8c08e895d00021e Mon Sep 17 00:00:00 2001 From: BAKEYi <16298417+bakeyi@user.noreply.gitee.com> Date: Wed, 3 Jun 2026 16:54:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=A1=B5=E9=A6=96=E6=AC=A1?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E4=B8=8D=E6=98=BE=E7=A4=BA+=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E7=82=B9=E5=87=BB=E7=9B=B8=E5=90=8Ctab=E4=BC=9A?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E6=95=B0=E6=8D=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/order/userorder-list.vue | 128 ++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 59 deletions(-) diff --git a/pages/order/userorder-list.vue b/pages/order/userorder-list.vue index 81038d1..ada4742 100644 --- a/pages/order/userorder-list.vue +++ b/pages/order/userorder-list.vue @@ -289,26 +289,31 @@ uni.hideTabBar(); // 隐藏原生TabBar }, onShow() { - this.isLogin = uni.getStorageSync("accessToken") ? true : false; - if (this.isLogin) { - // 默认选中判断 - if(!this.activeFirstId) this.activeFirstId = 1; - if(!this.activeSecondId) this.activeSecondId = 3; - this.searchList(); - } else { - this.activeFirstId = null; - this.activeSecondId = null; - } - }, - watch: { - isLogin(newVal) { - if (newVal) { - this.activeFirstId = 1; - this.activeSecondId = 2; // 默认选中"待接单" - this.searchList(); - } - }, - }, + this.isLogin = uni.getStorageSync("accessToken") ? true : false; + if (this.isLogin) { + // 确保默认选中项正确 + if(!this.activeFirstId) this.activeFirstId = 1; + if(!this.activeSecondId) this.activeSecondId = 3; // 或者你想默认 2 (待接单),这里统一就行 + + // 使用 $nextTick 确保 CommonList 组件已经渲染完毕再调用刷新 + this.$nextTick(() => { + this.searchList(); + }); + } else { + this.activeFirstId = null; + this.activeSecondId = null; + this.popList = []; // 没登录清空数据 + } + }, + // watch: { + // isLogin(newVal) { + // if (newVal) { + // this.activeFirstId = 1; + // this.activeSecondId = 2; // 默认选中"待接单" + // this.searchList(); + // } + // }, + // }, methods: { searchList() { if (this.syrId && this.idType) { @@ -342,50 +347,55 @@ }, // 一级tab点击事件 handleFirstTabClick(item) { - this.popList = [] - if (!this.isLogin) return; - // 避免重复点击 - if (this.activeFirstId === item.id) return; - // 更新1级选中状态 - this.activeFirstId = item.id; + if (!this.isLogin) return; + // 避免重复点击 (一定要在最前面!) + if (this.activeFirstId === item.id) return; + + // 【修改点】:判断完不是重复点击后,再清空旧数据 + this.popList = []; + + // 更新1级选中状态 + this.activeFirstId = item.id; - this.haveButton = true - if (this.activeFirstId == 4 || this.activeFirstId == 5) { - this.haveButton = false - } + this.haveButton = true; + if (this.activeFirstId == 4 || this.activeFirstId == 5) { + this.haveButton = false; + } - // 重置2级选中状态(默认选中"全部") - if (this.activeFirstId == 1 || this.activeFirstId == 2) { - this.activeSecondId = 3; - } else { - this.activeSecondId = 2; - } + // 重置2级选中状态 + if (this.activeFirstId == 1 || this.activeFirstId == 2) { + this.activeSecondId = 3; + } else { + this.activeSecondId = 2; + } - // 传递给父组件(1级选中数据) - this.$emit("tabChange", { - firstId: this.activeFirstId, - secondId: this.activeSecondId, - }); - this.$nextTick(() => { - this.searchList(); - }); - }, + this.$emit("tabChange", { + firstId: this.activeFirstId, + secondId: this.activeSecondId, + }); + + this.$nextTick(() => { + this.searchList(); + }); + }, // 二级tab点击事件 handleSecondTabClick(id, title) { - this.popList = [] - if (!this.isLogin) return; - if (this.activeSecondId === id) return; - // 更新2级选中状态 - this.activeSecondId = id; - // 传递给父组件(2级选中数据) - this.$emit("tabChange", { - firstId: this.activeFirstId, - secondId: this.activeSecondId, - }); - this.$nextTick(() => { - this.searchList(); - }); - }, + if (!this.isLogin) return; + // 避免重复点击! + if (this.activeSecondId === id) return; + // 判断完不是重复点击后,再清空旧数据 + this.popList = []; + // 更新2级选中状态 + this.activeSecondId = id; + this.$emit("tabChange", { + firstId: this.activeFirstId, + secondId: this.activeSecondId, + }); + + this.$nextTick(() => { + this.searchList(); + }); + }, cancelOrder(e, order) { uni.showModal({ title: "取消订单",