// pages/bookExhibitionDetails/index.js const app = getApp() import { loginInfo } from '../../assets/js/login'; Page({ /** * 页面的初始数据 */ data: { start: 1, loading: true, hidden: true, bookName: '', bookBeginDate: '', bookCreator: '', bookContent: '', bookImage: '', bookExhibitionList: [], navBarHeight: '', barHeight: '', totalSize: '', passId: '', isMore: null, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 this.setData({ navBarHeight: navBarHeight, barHeight: systInfo.statusBarHeight, }) this.setData({ passId: options.id }) this.bookExhibitionGet(this.data.passId) this.getBookExhibitionDetails() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() {}, onShareTimeline() {}, bookExhibitionGet(passId) { this.setData({ loading: true, hidden: true, }) app.MG.store.getProductDetail({ storeInfo: 'jsek_bookFair', //商品库 path: '*', //路径 queryType: '*', productId: passId, //详情的id fields: { subtitle: [], content: [], isbn: [], introduction: [], Creator: [] } }).then(res => { console.log(res.datas, 'res'); this.setData({ bookName: res.datas.name, bookBeginDate: res.datas.beginDate, bookCreator: res.datas.datas.Creator.Name, bookContent: res.datas.content, bookImage: res.datas.icon || '/static/images/bookExhibitionList/banner.png', loading: false, hidden: false, }); if (res.datas.subtitle == undefined) { res.datas.subtitle = ""; } let title = res.datas.subtitle + this.data.bookName wx.setNavigationBarTitle({ title: title }); }) }, //书展详情接口 getBookExhibitionDetails() { app.MG.store.getProductList({ path: '*', storeInfo: 'jsek_bookFair', mainProductId: this.data.passId, queryType: 'Related', // 查询类型: Related:查询关联商品;SubProduct: 查询子商品; paging: { start: 0, size: this.data.start * 6 }, fields: { author: [], publicationDate: [], isbn: [], content: [], Creator: [] } }).then(res => { this.setData({ bookExhibitionList: res.datas, totalSize: res.total, loading: false, hidden: false, }) }) }, onBookDetails(event) { const item = event.currentTarget.dataset.item; console.log(item, 'item'); wx.navigateTo({ url: '/packageBookService/pages/bookServices/detail/index?id=' + item.id + '&name=' + item.name }); }, 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) } }, })