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;
}
}
}