From c0c9335c4e404beb94890fe2ef402380b8e3b151 Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期三, 13 三月 2024 19:57:35 +0800 Subject: [PATCH] fix(sad): 阿斯蒂芬 --- pages/personalCenter/sampleBooks/index.js | 185 ++++++++++++++++++++++++++++++++++++++------- 1 files changed, 155 insertions(+), 30 deletions(-) diff --git a/pages/personalCenter/sampleBooks/index.js b/pages/personalCenter/sampleBooks/index.js index 1cd80ed..984fa38 100644 --- a/pages/personalCenter/sampleBooks/index.js +++ b/pages/personalCenter/sampleBooks/index.js @@ -1,11 +1,44 @@ -// pages/personalCenter/sampleBooks/index.js +const app = getApp(); +import moment from 'moment' Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - + active: 0, + topicIdOrRefCode: "applyEntityBook", + active1: 0, + tabList: [ + { + label: '鍏ㄩ儴', + value: 'all', + }, + { + label: '瀹℃牳涓�', + value: 'waitAudit', + }, + { + label: '宸查�氳繃', + value: 'Normal', + }, + { + label: '鏈�氳繃', + value: 'Reject', + } + ], + list: [], + //鍒嗛〉 + page: 1, + limit: 10, + pageTotalCount: 0, + bottomLoading: false, + isMoreData: false, + // 杩斿洖椤堕儴 + isBackTop: false, + setScrollValue: 0, + skeletonLoding: true, + queryFilter: [] }, /** @@ -13,48 +46,140 @@ */ onLoad(options) { console.log(options); + this.getDataList(false); + }, + tabClick(item) { + let that = this; + if (item.detail.value == '1') { + that.setData({ + active: item.detail.value, + topicIdOrRefCode: 'applyBook', + }) + } else { + that.setData({ + active: item.detail.value, + topicIdOrRefCode: 'applyEntityBook', + }) + } + that.setData({ + active1: 0, + queryFilter: [], + skeletonLoding: true, + list: [], + page: 1, + bottomLoading: false, + isMoreData: false, + }) + that.getDataList(false); + }, + tabBookClick(item) { + let that = this; + let info = this.data.tabList[item.detail.value] + that.setData({ + skeletonLoding: true, + active1: item.detail.value, + queryFilter: info.value == 'all' ? [] : [{ field: 'State', value: info.value }], + list: [], + page: 1, + bottomLoading: false, + isMoreData: false, + }) + that.getDataList(false); }, - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 - */ - onReady() { - - }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず - */ - onShow() { - - }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 - */ - onHide() { - - }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 - */ - onUnload() { - + getDataList(isReachBottom) { + app.MG.ugc.getTopicMessageList({ + start: this.data.page * this.data.limit - this.data.limit, + size: this.data.limit, + topicIdOrRefCode: this.data.topicIdOrRefCode, + appRefCode: app.config.appRefCode, + filterList: this.data.queryFilter, + sort: { + type: 'Desc', + field: 'CreateDate' + } + }).then((res) => { + try { + if (res.datas.length > 0) { + res.datas.forEach((item) => { + item.updateDate = moment(item.updateDate).format("YYYY-MM-DD"); + if (item.feedBack) { + item.feedBack = JSON.parse(item.feedBack) + } + if (item.content) { + item.productList = JSON.parse(item.content) + } + }) + let dataList = res.datas; + //瑙﹀簳鍔犺浇鏂版暟鎹苟淇濈暀鑰佹暟鎹� + if (isReachBottom) { + dataList = [...this.data.list, ...dataList] //灏嗘柊鏁版嵁鍔犲叆鑰佹暟鎹腑 + } + this.setData({ + list: dataList, + pageTotalCount: res.totalSize, + bottomLoading: false, + isMoreData: dataList.length > 0 ? false : true, + skeletonLoding: false, + loading: false + }) + } else { + this.setData({ + skeletonLoding: false, + loading: false + }) + } + } catch (error) { + console.log(error) + } + }) }, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ onPullDownRefresh() { - + if (this._freshing) return + this.setData({ + // list: [], + page: 1, + limit: 10, + pageTotalCount: 0, + bottomLoading: false, + isMoreData: false + }) + this._freshing = true; + this.setData({ + triggered: false, + }) + this.getDataList(false); + this._freshing = false }, /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ onReachBottom() { - + this.setData({ + bottomLoading: true, + isMoreData: false + }) + let bool = false; + if (this.data.pageTotalCount > this.data.list.length) { + bool = true; + this.setData({ + page: this.data.page + 1, + }) + } else { + setTimeout(() => { + this.setData({ + bottomLoading: false, + isMoreData: true + }) + }, 100) + return false; + } + this.getDataList(bool); }, /** -- Gitblit v1.9.1