diff --git a/src/views/Tabbars/Agriculture.vue b/src/views/Tabbars/Agriculture.vue deleted file mode 100644 index 086343d..0000000 --- a/src/views/Tabbars/Agriculture.vue +++ /dev/null @@ -1,123 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/views/Tabbars/Mall.vue b/src/views/Tabbars/Mall.vue index 1115d53..d543070 100644 --- a/src/views/Tabbars/Mall.vue +++ b/src/views/Tabbars/Mall.vue @@ -220,7 +220,11 @@ export default { name: 'Mall', // emits: ['changeTabbar'], activated() { - this.init(); + if (this._skipActivatedRefresh) { + this._skipActivatedRefresh = false + return + } + this.$refs.BaseList?.refresh() }, mounted() { this.init(); @@ -228,6 +232,7 @@ export default { data() { return { activeType: '', + _skipActivatedRefresh: true, searchParams: { mallstate: 3, pid: '', @@ -261,7 +266,11 @@ export default { this.typeData = res.data this.searchParams.pid = res.data?.[0]?.id || '' }), - ]).catch(err => { + ]).then(() => { + // 初始化完成后,允许 activated 触发 refresh + this._skipActivatedRefresh = false + }).catch(err => { + this.$showFailToast(err.message || '加载失败') }); }, groupItems(items, num) { diff --git a/src/views/Trade/Tradelist.vue b/src/views/Trade/Tradelist.vue index 1d3c463..76e6eaa 100644 --- a/src/views/Trade/Tradelist.vue +++ b/src/views/Trade/Tradelist.vue @@ -42,7 +42,8 @@
订单编号: - {{ item.ordernum }} + {{ item.ordernum }}
下单时间: @@ -102,7 +103,7 @@ export default { data() { return { activeTab: '', - TradeArea: Number(this.$route.query.TradeArea) || 0, + TradeArea: 0, _initialized: false, _searchParams: { ordernum: '', @@ -111,10 +112,6 @@ export default { tradeStates: [ ], mallList: [ - { value: 0, label: '全部订单' }, - { value: 3, label: '商城订单' }, - { value: 1, label: '礼包订单' }, - { value: 2, label: '买单订单' }, ], } }, @@ -125,13 +122,27 @@ export default { ]).then(([stateRes, areaRes]) => { this.tradeStates = stateRes.data; this.mallList = [{ value: 0, label: '全部订单' }, ...(areaRes.data || [])]; - this._initialized = true; - this.$refs.baseList?.refresh(); + // 先标记跳过,等 watch 触发完再刷新 + if (this.$refs.baseList) { + this.$refs.baseList._skipWatch = true + } + const areaFromRoute = this.$route.query.TradeArea; + if (areaFromRoute !== undefined && areaFromRoute !== '') { + this.TradeArea = Number(areaFromRoute) || 0; + } else { + this.TradeArea = 0; + } const stateFromRoute = this.$route.query.state; if (stateFromRoute !== undefined && stateFromRoute !== '') { this.activeTab = String(stateFromRoute); this._searchParams.state = stateFromRoute; } + this.$nextTick(() => { + if (this.$refs.baseList) { + this.$refs.baseList._skipWatch = false + this.$refs.baseList.refresh() + } + }) }).catch((err) => { this.$showFailToast(err.message || '加载失败'); }); @@ -155,10 +166,10 @@ export default { } }, watch: { - TradeArea(val) { - this._searchParams.state = ''; - this.activeTab = ''; - }, + // TradeArea(val) { + // this._searchParams.state = ''; + // this.activeTab = ''; + // }, '$route.query.state': { handler(newVal) { if (newVal !== undefined && newVal !== '') { @@ -168,7 +179,16 @@ export default { this.activeTab = ''; } } - } + }, + '$route.query.TradeArea': { + handler(newVal) { + if (newVal !== undefined && newVal !== '') { + this.TradeArea = Number(newVal) || 0; + } else { + this.TradeArea = 0; + } + } + }, }, methods: { back() {