|
|
@@ -125,7 +125,17 @@ export default {
|
|
|
this.applyPageQuery(tabQuery);
|
|
|
queryUpdated = true;
|
|
|
}
|
|
|
+
|
|
|
+ // 未带店铺筛选参数时(底栏点「订单」、从 recent 回来等)恢复全部店铺;
|
|
|
+ // 从订单详情返回(refreshPage=1)保留当前筛选。
|
|
|
+ const hasShopFilterQuery = this.hasShopFilterInQuery(tabQuery);
|
|
|
+ const shouldResetStoreFilter =
|
|
|
+ !hasShopFilterQuery && Number(this.refreshPage) !== 1;
|
|
|
+
|
|
|
if (queryUpdated) {
|
|
|
+ if (shouldResetStoreFilter) {
|
|
|
+ this.resetStoreFilter({ reload: false });
|
|
|
+ }
|
|
|
this.init();
|
|
|
this.orderListBooted = true;
|
|
|
return;
|
|
|
@@ -137,8 +147,16 @@ export default {
|
|
|
}
|
|
|
// 首次 onLoad 时可能尚未登录而跳过 init;登录后回到本 Tab 补初始化
|
|
|
if (!this.orderListBooted) {
|
|
|
+ if (shouldResetStoreFilter) {
|
|
|
+ this.resetStoreFilter({ reload: false });
|
|
|
+ }
|
|
|
this.init();
|
|
|
this.orderListBooted = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // Tab 页常驻:进过某店后再回总订单,清筛选并强制重拉全部
|
|
|
+ if (shouldResetStoreFilter) {
|
|
|
+ this.resetStoreFilter({ reload: true });
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -152,12 +170,56 @@ export default {
|
|
|
url: "/pages/login/index?needBack=1" + (account ? "&account=" + account : "")
|
|
|
});
|
|
|
},
|
|
|
+ /**
|
|
|
+ * switchTab / 路由是否显式指定店铺筛选(hdId 或兼容字段 id/ghsId)
|
|
|
+ * @param {Object} query
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ hasShopFilterInQuery(query) {
|
|
|
+ if (!query || typeof query !== "object") {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return Number(query.hdId || query.id || query.ghsId || 0) > 0;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 去掉 option 上残留的店铺筛选字段,避免 init 再次锁到某店
|
|
|
+ */
|
|
|
+ stripShopFilterFromOption() {
|
|
|
+ if (!this.option || typeof this.option !== "object") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$delete(this.option, "hdId");
|
|
|
+ this.$delete(this.option, "id");
|
|
|
+ this.$delete(this.option, "ghsId");
|
|
|
+ this.$delete(this.option, "hdName");
|
|
|
+ this.$delete(this.option, "name");
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 恢复「全部店铺」:清页面筛选与 option 残留。
|
|
|
+ * @param {{ reload?: boolean }} opts reload=true 时强制重拉(已 boot 且随后不会再 init)
|
|
|
+ */
|
|
|
+ resetStoreFilter(opts) {
|
|
|
+ const reload = !opts || opts.reload !== false;
|
|
|
+ this.stripShopFilterFromOption();
|
|
|
+ this.hdName = "";
|
|
|
+ this.hdId = 0;
|
|
|
+ // 进店后 storage 仍有 hdId;请求层已尊重显式 hdId=0,这里刷新 UI 列表
|
|
|
+ if (reload && this.orderListBooted && this.$refs.orderList) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.orderList.pullRefresh && this.$refs.orderList.pullRefresh();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
/** 合并 switchTab / 路由 query */
|
|
|
applyPageQuery(query) {
|
|
|
if (!query || typeof query !== "object") {
|
|
|
return;
|
|
|
}
|
|
|
this.option = Object.assign({}, this.option || {}, query);
|
|
|
+ // 本次未指定店铺时清掉历史 option 店铺字段,防止 init 继续锁店
|
|
|
+ if (!this.hasShopFilterInQuery(query)) {
|
|
|
+ this.stripShopFilterFromOption();
|
|
|
+ }
|
|
|
if (query.account) {
|
|
|
uni.setStorageSync("account", String(query.account));
|
|
|
}
|
|
|
@@ -182,6 +244,7 @@ export default {
|
|
|
},
|
|
|
syncHdNameFromList() {
|
|
|
if (!this.hdId) {
|
|
|
+ this.hdName = "";
|
|
|
return;
|
|
|
}
|
|
|
const matched = this.storeList.find((item) => Number(item.id) === Number(this.hdId));
|
|
|
@@ -222,6 +285,10 @@ export default {
|
|
|
if (optionHdId > 0) {
|
|
|
this.hdId = optionHdId;
|
|
|
this.hdName = opt.hdName || opt.name || "";
|
|
|
+ } else {
|
|
|
+ // 无店铺参数时强制全部,避免 Tab 常驻导致上次筛选残留
|
|
|
+ this.hdId = 0;
|
|
|
+ this.hdName = "";
|
|
|
}
|
|
|
this.loadStoreList();
|
|
|
this.$nextTick(() => {
|