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: "取消订单",