From e03417edfeaf52c017e4a5539f3b41ad0204a2f0 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期二, 05 三月 2024 19:03:51 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/jsek-applet --- pages/personalCenter/myCollection/index.js | 171 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 149 insertions(+), 22 deletions(-) diff --git a/pages/personalCenter/myCollection/index.js b/pages/personalCenter/myCollection/index.js index 358d636..d5bdf97 100644 --- a/pages/personalCenter/myCollection/index.js +++ b/pages/personalCenter/myCollection/index.js @@ -1,10 +1,35 @@ +const app = getApp(); Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - + active: 0, + activeName: "FavoriteBookCity", + tabList: [ + { + label: '鍥句功', + key: 0, + linkType: 'FavoriteBookCity', + }, + { + label: '璇剧▼', + key: 1, + linkType: 'Favoriteclass', + } + ], + list: [], + //鍒嗛〉 + page: 1, + limit: 12, + pageTotalCount: 0, + bottomLoading: false, + isMoreData: false, + // 杩斿洖椤堕儴 + isBackTop: false, + setScrollValue: 0, + skeletonLoding: true, }, /** @@ -12,6 +37,7 @@ */ onLoad(options) { console.log(options); + this.getDataList(); }, /** @@ -21,41 +47,142 @@ }, - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず - */ - onShow() { - + tabBookClick(item) { + console.log(item, 1) + let that = this; + let info = this.data.tabList[item.detail.value] + that.setData({ + skeletonLoding: true, + active: item.detail.value, + activeName: info.linkType, + list: [], + page: 1, + bottomLoading: false, + isMoreData: false, + }) + that.getDataList(false); }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 - */ - onHide() { - + getDataList(isReachBottom) { + app.MG.store.getProductList({ + handelEBooK: true, + queryType: "AppUserProductLink", + linkType: this.data.activeName, + paging: { + start: this.data.page * this.data.limit - this.data.limit, + size: this.data.limit + }, + fields: { + author: [] + } + }).then((res) => { + try { + if (res.datas.length > 0) { + let dataList = res.datas; + //瑙﹀簳鍔犺浇鏂版暟鎹苟淇濈暀鑰佹暟鎹� + if (isReachBottom) { + dataList = [...this.data.list, ...dataList] //灏嗘柊鏁版嵁鍔犲叆鑰佹暟鎹腑 + } + this.setData({ + list: dataList, + pageTotalCount: res.total, + bottomLoading: false, + isMoreData: dataList.length > 0 ? false : true, + skeletonLoding: false, + loading: false + }) + } else { + this.setData({ + skeletonLoding: false, + loading: false + }) + } + } catch (error) { + console.log(error) + } + }) }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 - */ - onUnload() { - - }, - /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ onPullDownRefresh() { - + if (this._freshing) return + this.setData({ + // list: [], + page: 1, + limit: 18, + 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); }, + setCoolect(itemData) { + let that = this; + let info = itemData.currentTarget.dataset.info; + wx.showModal({ + title: '鎻愮ず', //鎻愮ず鐨勬爣棰� + content: '纭畾瑕佸彇娑堟敹钘忥紵', //鎻愮ず鐨勫唴瀹� + success: function (res) { + if (res.confirm) { + app.MG.store + .delProductLink({ + productIds: [info.id], + linkType: that.data.activeName, + }) + .then(() => { + wx.showToast({ + title: "鏀惰棌宸插彇娑�", + icon: 'success', + duration: 1000, + }) + this.getDataList(false) + }); + } else if (res.cancel) { + console.log('鐢ㄦ埛鐐瑰嚮浜嗗彇娑�') + } + } + }) + }, + goBookDetails(itemData) { + let info = itemData.currentTarget.dataset.info; + // wx.navigateTo({ + // url: "/pages/personalCenter/myMassage/massageDetail/index?id=" + info.id, + // }); + }, + + /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ -- Gitblit v1.9.1