From 730eac05b792f16933729b7c159650c488e3af3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com> Date: Tue, 2 Dec 2025 09:27:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=A9=E4=B8=9A=E8=B4=B9?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA=E4=B8=8D=E5=85=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/user/wallet/index.css | 9 ++++ packages/user/wallet/index.vue | 79 ++++++++++++++++++++++++++++++---- 2 files changed, 80 insertions(+), 8 deletions(-) diff --git a/packages/user/wallet/index.css b/packages/user/wallet/index.css index 56337b66..6fb03e95 100644 --- a/packages/user/wallet/index.css +++ b/packages/user/wallet/index.css @@ -1,5 +1,6 @@ page { background-color: #f6f7fb; + padding-bottom: 0rpx; } .header { @@ -144,4 +145,12 @@ page { font-size: 26rpx; color: #999999; margin-top: 10rpx; +} + +/* 加载更多提示样式 */ +.load-more { + padding: 30rpx 0; + text-align: center; + font-size: 28rpx; + color: #999999; } \ No newline at end of file diff --git a/packages/user/wallet/index.vue b/packages/user/wallet/index.vue index f2a64dfa..bd5cf5d2 100644 --- a/packages/user/wallet/index.vue +++ b/packages/user/wallet/index.vue @@ -54,6 +54,11 @@ 暂无变动记录 + + + 加载中... + 没有更多数据了 + @@ -74,6 +79,8 @@ export default { itemType: '', page_num: 1, page_size: 10, + loading: false, + hasMore: true } }, onLoad(options) { @@ -84,7 +91,27 @@ export default { this.photoVal = options.type == 1 ? 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com//user_wallet1.png' : (options.type == 2 ? 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com//user_wallet2.png' : 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com//user_wallet3.png'); this.itemObj = JSON.parse(options.item); this.itemType = options.type; - this.balance = options.type == 1 ? this.itemObj.points : (options.type == 2 ? this.itemObj.property_housing_fund : 0) + this.balance = options.type == 1 ? this.itemObj.points : (options.type == 2 ? this.itemObj.property_housing_fund : 0); + this.page_num = 1; + this.records = []; + this.hasMore = true; + this.getWalletInfo(); + }, + + // 下拉刷新 + onPullDownRefresh() { + this.page_num = 1; + this.records = []; + this.hasMore = true; + this.getWalletInfo().then(() => { + uni.stopPullDownRefresh(); + }); + }, + + // 触底加载更多 + onReachBottom() { + if (this.loading || !this.hasMore) return; + this.page_num++; this.getWalletInfo(); }, methods: { @@ -95,18 +122,54 @@ export default { }, // 获取钱包信息 getWalletInfo() { + if (this.loading) return Promise.resolve(); + + this.loading = true; const params = { page_num: this.page_num, page_size: this.page_size, } - if (this.itemType == 1) { - request(apiArr.getPoints, 'POST', params, { silent: false }).then(res => { + + const requestPromise = new Promise((resolve, reject) => { + if (this.itemType == 1) { + request(apiArr.getPoints, 'POST', params, { silent: false }).then(res => { + this.handleResponse(res); + resolve(); + }).catch(err => { + reject(err); + }) + } else if (this.itemType == 2) { + request(apiArr.getAccumulationFund, 'POST', params, { silent: false }).then(res => { + this.handleResponse(res); + resolve(); + }).catch(err => { + reject(err); + }) + } else { + resolve(); + } + }); + + requestPromise.finally(() => { + this.loading = false; + }); + + return requestPromise; + }, + + // 处理响应数据 + handleResponse(res) { + if (res && res.rows) { + if (this.page_num === 1) { + // 第一页数据直接替换 this.records = res.rows; - }) - } else if (this.itemType == 2) { - request(apiArr.getAccumulationFund, 'POST', params, { silent: false }).then(res => { - this.records = res.rows; - }) + } else { + // 后续页数据追加 + this.records = [...this.records, ...res.rows]; + } + + // 判断是否还有更多数据 + this.hasMore = res.rows.length >= this.page_size; } } }