Commit ce1517b4 by Jaxon

feat(性能概览): 添加页面激活状态管理,优化数据获取逻辑

1 parent b1883ddc
...@@ -111,6 +111,13 @@ export default { ...@@ -111,6 +111,13 @@ export default {
RegionPicker, RegionPicker,
WarnList, WarnList,
}, },
inject: {
// 自定义内部变量名
getPageActive: {
from: "getPageActive", // 来自 provide 的 key
default: () => true, // 没传时的默认值
},
},
data() { data() {
return { return {
throttledFilterSearchKeyword: null, throttledFilterSearchKeyword: null,
...@@ -210,6 +217,9 @@ export default { ...@@ -210,6 +217,9 @@ export default {
}; };
}, },
async getData() { async getData() {
if (!this.getPageActive()) {
return;
}
this.list.loading = true; this.list.loading = true;
this.$loading.show(); this.$loading.show();
try { try {
......
...@@ -78,6 +78,13 @@ export default { ...@@ -78,6 +78,13 @@ export default {
StatisticsItem, StatisticsItem,
Empty, Empty,
}, },
inject: {
// 自定义内部变量名
getPageActive: {
from: "getPageActive", // 来自 provide 的 key
default: () => true, // 没传时的默认值
},
},
data() { data() {
return { return {
throttledFilterSearchKeyword: null, throttledFilterSearchKeyword: null,
...@@ -134,7 +141,9 @@ export default { ...@@ -134,7 +141,9 @@ export default {
}; };
}, },
async getData() { async getData() {
console.log("parent"); if (!this.getPageActive()) {
return;
}
this.list.loading = true; this.list.loading = true;
this.$loading.show(); this.$loading.show();
try { try {
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
<div class="page-container" <div class="page-container"
lazy-render lazy-render
:style="{ backgroundImage: `url(${pageBgUrl})` }"> :style="{ backgroundImage: `url(${pageBgUrl})` }">
<van-tabs animated> <van-tabs v-model="tabs.active"
animated
lazy-render>
<van-tab title="督导业绩"> <van-tab title="督导业绩">
<SupervisorTabItem /> <SupervisorTabItem />
</van-tab> </van-tab>
...@@ -24,11 +26,31 @@ export default { ...@@ -24,11 +26,31 @@ export default {
SupervisorTabItem, SupervisorTabItem,
StoreTabItem, StoreTabItem,
}, },
provide() {
return {
getPageActive: () => {
return this.isPageActive;
},
};
},
data() { data() {
return { return {
isPageActive: false,
tabs: {
active: 0,
},
pageBgUrl: "https://img02.glsx.com.cn/weapp/resource/supervise-wecom/page-bg.png", pageBgUrl: "https://img02.glsx.com.cn/weapp/resource/supervise-wecom/page-bg.png",
}; };
}, },
activated() {
console.log("当前页面激活了 ✅");
this.isPageActive = true;
},
// 页面被隐藏时触发
deactivated() {
console.log("当前页面离开了 ❌");
this.isPageActive = false;
},
created() { created() {
}, },
async mounted() { async mounted() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!