优化,完善代码

This commit is contained in:
2026-05-14 14:42:51 +08:00
parent 79a21ff0a5
commit 16c91facac
26 changed files with 1792 additions and 1322 deletions

View File

@@ -39,14 +39,20 @@ export default {
pageNo:1,
pageSize:10,
isRefreshing: false,
loadStatus: 'loadmore'
loadStatus: 'more', // ✅ 修复为官方正确值
}
},
onLoad() { // ✅ 修复生命周期拼写
this.fetchMessageList();
},
onShow() {
this.$checkToken(this.$getToken())
},
onload(){
this.loadMore();
// ✅ 删除和 scroll-view 冲突的 onReachBottom
computed: {
staticHost() {
return this.$config.staticUrl;
}
},
methods: {
goBack() {
@@ -68,8 +74,10 @@ export default {
}
},
fetchMessageList(){
if (this.loadStatus !== 'loadmore') return;
// ✅ 正确判断加载状态
if (this.loadStatus !== 'more') return;
this.loadStatus = 'loading';
let url = '/message/queryPage'
this.$u.post(url, {
pageNo: this.pageNo,
@@ -78,36 +86,44 @@ export default {
WT: this.$getToken()
}).then(res => {
const rows = res.data.result || [];
console.log(rows)
if (this.pageNo === 1) this.flowList = [];
this.flowList = this.flowList.concat(rows);
// ✅ 判断是否还有更多
if (rows.length < this.pageSize) {
this.loadStatus = 'nomore';
} else {
this.pageNo++;
this.loadStatus = 'loadmore';
this.loadStatus = 'more';
}
}).catch(err => {
console.log("获取消息列表失败:", err)
this.loadStatus = 'loadmore';
this.loadStatus = 'more'; // ✅ 异常恢复
})
},
loadMore() {
// 只有在 loadStatus 为 'loadmore' 时才触发
if (this.loadStatus !== 'loadmore') return;
this.fetchMessageList()
},
viewMessage(msg) {
this.$u.route({url:'/pages-biz/message/messageDetail',params:{
id: msg.id,
read: msg.read
}});
this.$u.route({
url:'/pages-biz/message/messageDetail',
params:{
id: msg.id,
read: msg.read
}
});
},
// ✅ 修复下拉刷新(重置数据)
refresh() {
this.isRefreshing = true;
this.pageNo = 1;
this.flowList = [];
this.loadStatus = 'more';
this.fetchMessageList();
setTimeout(() => {
this.isRefreshing = false;
}, 1000);
}, 800);
}
}
}
@@ -119,7 +135,9 @@ export default {
min-height: 100vh;
}
/* ✅ 修复滚动区域高度 */
.message-list {
height: calc(100vh - var(--window-top));
padding: 20rpx;
box-sizing: border-box;
}