优化message

This commit is contained in:
TOP糯米 2023-04-08 16:30:24 +08:00
parent 10294c3939
commit 7a8e0455ba
1 changed files with 15 additions and 10 deletions

View File

@ -39,6 +39,7 @@ export default {
return { return {
utils: this.$utils, utils: this.$utils,
bodyPt: 0, bodyPt: 0,
loaded: false,
timer: null, timer: null,
tabIndex: 0, tabIndex: 0,
tabHeight: 0, tabHeight: 0,
@ -53,12 +54,13 @@ export default {
messageTabIndex: (state) => state.system.messageTabIndex, messageTabIndex: (state) => state.system.messageTabIndex,
}), }),
}, },
onLoad() {}, async onLoad() {
async onShow() {
if (this.messageTabIndex != this.tabIndex || (this.messageTabIndex == 0 && this.tabIndex == 0)) {
this.tabList = [];
await this.loadCate(); await this.loadCate();
this.switchTab(this.messageTabIndex); this.switchTab(this.tabIndex);
},
onShow() {
if (this.messageTabIndex != this.tabIndex) {
this.tabIndex = this.messageTabIndex;
} }
this.$store.commit("system/refreshOrder", true); this.$store.commit("system/refreshOrder", true);
}, },
@ -80,10 +82,11 @@ export default {
currentTab.page = 1; currentTab.page = 1;
currentTab.list = []; currentTab.list = [];
currentTab.more = true; currentTab.more = true;
clearTimeout(this.timer); uni.pageScrollTo({
this.timer = setTimeout(() => { scrollTop: 0,
duration: 0,
});
this.loadList(index); this.loadList(index);
}, 100);
}, },
setTabHeight() { setTabHeight() {
let query = uni.createSelectorQuery().in(this); let query = uni.createSelectorQuery().in(this);
@ -98,6 +101,7 @@ export default {
* 加载分类 * 加载分类
*/ */
async loadCate() { async loadCate() {
if (this.loaded) return;
await this.$models.system.notifyCate().then((cate) => { await this.$models.system.notifyCate().then((cate) => {
cate.forEach((item) => { cate.forEach((item) => {
this.tabList.push({ this.tabList.push({
@ -108,6 +112,7 @@ export default {
list: [], list: [],
}); });
}); });
this.loaded = true;
}); });
}, },
/** /**