This commit is contained in:
2025-03-09 23:40:39 +08:00
parent ed1188098f
commit 7e801fed23
4 changed files with 218 additions and 148 deletions

View File

@@ -14,7 +14,13 @@ Page({
},
onShow() {
this.getOrderList()
// 重置页码并重新获取数据
this.setData({
pageNum: 1,
news: []
}, () => {
this.getOrderList()
})
},
// =============== 页面跳转相关 ===============
@@ -123,14 +129,22 @@ Page({
// 处理资讯列表响应
handleOrderListResponse(res) {
if (res.data.erro !== 0) return
if (res.data.erro !== 0) {
wx.showToast({
title: '获取数据失败',
icon: 'none'
})
return
}
const { lists, currentPage } = res.data
this.setData({
news: currentPage === 1 ? lists : this.data.news.concat(lists),
pageNum: currentPage + 1
})
if (lists && lists.length > 0) {
this.setData({
news: currentPage === 1 ? lists : this.data.news.concat(lists),
pageNum: currentPage + 1
})
}
},
// 资讯项点击
@@ -172,14 +186,21 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
// 下拉刷新时重置页码并重新获取数据
this.setData({
pageNum: 1,
news: []
}, () => {
this.getOrderList()
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
// 上拉加载更多数据
this.getOrderList()
},
/**
* 用户点击右上角分享

View File

@@ -1,3 +1,5 @@
{
"usingComponents": {}
"usingComponents": {},
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"
}