// pages/bookExhibitionDetails/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { bookName: null, bookBeginDate: null, bookCreator: null, bookContent: null, bookImage: null, bookExhibitionList: [] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { const passId = options.id this.bookExhibitionGet(passId) this.getBookExhibitionDetails(passId) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, bookExhibitionGet(passId) { 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() }) }, //书展详情接口 getBookExhibitionDetails(passId) { 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, 88888); }) }, onBookDetails(event) { const item = event.currentTarget.dataset.item; console.log(item, 'item'); // wx.navigateTo({ // url: '/pages/bookExhibitionDetails/index?id?name=' + item.id + item.name // 假设跳转到详情页面,并传递了id参数 // }); } })