// pages/bookExhibitionDetails/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { loading: true, hidden: true, bookName: '', bookBeginDate: '', bookCreator: '', bookContent: '', bookImage: '', bookExhibitionList: [], navBarHeight: '', barHeight: '', subtitleName: '', }, /** * 生命周期函数--监听页面加载 */ 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, }) console.log(); this.setData({ bookName: options.bookName, subtitleName: options.subtitleName }) const passId = options.id this.bookExhibitionGet(passId) this.getBookExhibitionDetails(passId) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, bookExhibitionGet(passId) { this.setData({ loading: true, hidden: true, }) wx.showLoading({ title: '加载中...', }) console.log(passId, 8988989); app.MG.store.getProductDetail({ storeInfo: 'jsek_bookFair', //商品库 path: '*', //路径 queryType: '*', productId: passId, //详情的id fields: { subtitle: [], content: [], isbn: [], introduction: [], Creator: [] } }).then(res => { console.log(res.datas.datas.Creator.Name, '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 }); wx.hideLoading() this.setData({ loading: false, hidden: false, }) }) }, //书展详情接口 getBookExhibitionDetails(passId) { this.setData({ loading: true, hidden: true, }) app.MG.store.getProductList({ path: '*', storeInfo: 'jsek_bookFair', mainProductId: passId, queryType: 'Related', // 查询类型: Related:查询关联商品;SubProduct: 查询子商品; fields: { author: [], publicationDate: [], isbn: [], content: [], Creator: [] } }).then(res => { this.setData({ bookExhibitionList: res.datas }) console.log(this.data.bookExhibitionList, 'bookExhibitionList'); this.setData({ 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(); }, })