优化,完善代码

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>

View File

@@ -29,11 +29,33 @@
this.id = option.id
this.getDetail()
},
onShow(){
this.recordView(this.id)
},
methods:{
recordView(assetId) {
let token = this.$getToken()
let userInfo = uni.getStorageSync('userInfo')
if(token){
return
}
if (token) {
let url = "/potential/add";
this.$u.get(url, {
assetId: this.id,
assetsName: '查看公告' + this.title,
userType: userInfo.userType
}, {
'WT': this.$getToken()
}).then(obj => {
}).catch(err => {
console.log("记录客户浏览记录失败", err)
})
}
},
getDetail(){
this.$u.get(`/notice/detail?id=${this.id}`,{},{
WT: this.$getToken()
}).then(res=>{
this.$u.get(`/notice/detail?id=${this.id}`,{},{}).then(res=>{
if(res.flag) {
this.title = res.data.noticeTitle;
this.content = res.data.noticeContent;
@@ -44,12 +66,13 @@
})
}
this.attachments = res.data.attachments;
this.recordView(this.id)
}
})
},
download(item){
uni.downloadFile({
url: this.$config.staticUrl + item.url,
url: this.$config.staticUrl + item.fileUrl,
success(res) {
uni.openDocument({
filePath: res.tempFilePath