Commit ce1517b4 by Jaxon

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

1 parent b1883ddc
......@@ -111,6 +111,13 @@ export default {
RegionPicker,
WarnList,
},
inject: {
// 自定义内部变量名
getPageActive: {
from: "getPageActive", // 来自 provide 的 key
default: () => true, // 没传时的默认值
},
},
data() {
return {
throttledFilterSearchKeyword: null,
......@@ -210,6 +217,9 @@ export default {
};
},
async getData() {
if (!this.getPageActive()) {
return;
}
this.list.loading = true;
this.$loading.show();
try {
......
......@@ -78,6 +78,13 @@ export default {
StatisticsItem,
Empty,
},
inject: {
// 自定义内部变量名
getPageActive: {
from: "getPageActive", // 来自 provide 的 key
default: () => true, // 没传时的默认值
},
},
data() {
return {
throttledFilterSearchKeyword: null,
......@@ -134,7 +141,9 @@ export default {
};
},
async getData() {
console.log("parent");
if (!this.getPageActive()) {
return;
}
this.list.loading = true;
this.$loading.show();
try {
......
......@@ -2,7 +2,9 @@
<div class="page-container"
lazy-render
:style="{ backgroundImage: `url(${pageBgUrl})` }">
<van-tabs animated>
<van-tabs v-model="tabs.active"
animated
lazy-render>
<van-tab title="督导业绩">
<SupervisorTabItem />
</van-tab>
......@@ -24,11 +26,31 @@ export default {
SupervisorTabItem,
StoreTabItem,
},
provide() {
return {
getPageActive: () => {
return this.isPageActive;
},
};
},
data() {
return {
isPageActive: false,
tabs: {
active: 0,
},
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() {
},
async mounted() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!