From 99dfeb5fc86bce593a5d3f43f45c26eedc00ab0a Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 10 九月 2024 16:28:54 +0800 Subject: [PATCH] bug --- pages/bookExhibitionDetails/index.js | 85 ++++++++++++++++++++++++++++-------------- 1 files changed, 57 insertions(+), 28 deletions(-) diff --git a/pages/bookExhibitionDetails/index.js b/pages/bookExhibitionDetails/index.js index 43c1898..11f9121 100644 --- a/pages/bookExhibitionDetails/index.js +++ b/pages/bookExhibitionDetails/index.js @@ -1,11 +1,15 @@ // pages/bookExhibitionDetails/index.js const app = getApp() +import { + loginInfo +} from '../../assets/js/login'; Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { + start: 1, loading: true, hidden: true, bookName: '', @@ -17,6 +21,9 @@ navBarHeight: '', barHeight: '', subtitleName: '', + totalSize: '', + passId: '', + isMore: null, }, /** @@ -30,18 +37,30 @@ navBarHeight: navBarHeight, barHeight: systInfo.statusBarHeight, }) - console.log(); - - this.setData({ bookName: options.bookName, - subtitleName: options.subtitleName + subtitleName: options.subtitleName, + passId: options.id }) + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + if (data) { + this.bookExhibitionGet(this.data.passId) + this.getBookExhibitionDetails() + } else { + this.bookExhibitionGet(this.data.passId) + this.getBookExhibitionDetails() + } + }) - const passId = options.id - - this.bookExhibitionGet(passId) - this.getBookExhibitionDetails(passId) + } else { + this.bookExhibitionGet(this.data.passId) + this.getBookExhibitionDetails() + } + wx.setNavigationBarTitle({ + title: this.data.subtitleName + }); }, /** @@ -98,10 +117,6 @@ loading: true, hidden: true, }) - wx.showLoading({ - title: '鍔犺浇涓�...', - }) - console.log(passId, 8988989); app.MG.store.getProductDetail({ storeInfo: 'jsek_bookFair', //鍟嗗搧搴� path: '*', //璺緞 @@ -121,26 +136,24 @@ bookBeginDate: res.datas.beginDate, bookCreator: res.datas.datas.Creator.Name, bookContent: res.datas.content, - bookImage: res.datas.icon - }); - wx.hideLoading() - this.setData({ + bookImage: res.datas.icon, loading: false, hidden: false, - }) + }); + console.log(this.data.loading, 123) }) }, //涔﹀睍璇︽儏鎺ュ彛 - getBookExhibitionDetails(passId) { - this.setData({ - loading: true, - hidden: true, - }) + getBookExhibitionDetails() { app.MG.store.getProductList({ path: '*', storeInfo: 'jsek_bookFair', - mainProductId: passId, + mainProductId: this.data.passId, queryType: 'Related', // 鏌ヨ绫诲瀷锛� Related锛氭煡璇㈠叧鑱斿晢鍝侊紱SubProduct: 鏌ヨ瀛愬晢鍝侊紱 + paging: { + start: 0, + size: this.data.start * 6 + }, fields: { author: [], publicationDate: [], @@ -149,12 +162,9 @@ Creator: [] } }).then(res => { - this.setData({ - bookExhibitionList: res.datas - }) - console.log(this.data.bookExhibitionList, 'bookExhibitionList'); - this.setData({ + bookExhibitionList: res.datas, + totalSize: res.total, loading: false, hidden: false, }) @@ -170,5 +180,24 @@ goBack() { wx.navigateBack(); }, + // 瑙﹀簳鍑芥暟 + onReachBottom() { + if (this.data.bookExhibitionList.length < this.data.totalSize) { + this.setData({ + isMore: true, + start: this.data.start + 1 + }) + this.getBookExhibitionDetails() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 300) + } + }, }) \ No newline at end of file -- Gitblit v1.9.1