优化,完善代码

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

@@ -17,6 +17,9 @@
</view>
<u-icon name="arrow-right" color="rgb(203,203,203)" :size="26" class="arrow-icon"></u-icon>
</view>
<!-- 加载更多 -->
<u-loadmore :status="loadStatus" />
</view>
</scroll-view>
</view>
@@ -26,20 +29,18 @@
<script>
export default {
data() {
// 静态公告数据
const staticNoticeList = [];
return {
pageNo: 1,
pageSize: 20,
flowList: [],
loadStatus: 'loadmore',
loadStatus: 'more', // ✅ 修复为官方正确值
isRefreshing: false
};
},
onLoad() {
// 静态数据已在data中初始化无需调用接口
this.getNoticecList();
},
// ✅ 删除和 scroll-view 冲突的 onReachBottom
methods: {
clickContent(item) {
if (item.noticeId) {
@@ -52,30 +53,39 @@ export default {
}
},
getNoticecList() {
if (this.loadStatus !== 'loadmore') return;
this.loadStatus = 'loading';
// ✅ 正确判断加载状态
if (this.loadStatus !== 'more') return;
this.loadStatus = 'loading';
let url = "/notice/pageQuery";
this.$u.post(url, {
pageNo: this.pageNo,
pageSize: this.pageSize
}).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 = 'more'; // ✅ 异常恢复
});
},
// 上拉加载
loadMore() {
this.getNoticecList();
}
}
};
</script>
<style lang="scss" scoped>
.tabSwiper {
width: 95%;
@@ -158,4 +168,4 @@ export default {
.page-box {
padding: 16rpx 0 40rpx 0;
}
</style>
</style>