// pages/test/testCover.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { bookId: 0, bookName: '', cmsId: '', productLinkPath: '', rootCmsItemId: '', answerTitle: '', }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { const token = wx.getStorageSync(app.config.tokenKey) if (!token) { loginInfo(app, (data) => { // 如果不是第一次登录,会执行回调 if (data) { // 登录成功,自动记录token和用户信息,并返回true if (options.scene) { this.getBookInfo(options.scene) } } }) } else { // 如果是第一次登录,会跳转至绑定用户信息页面,填写完用户信息后进行登录并储存token和用户信息,结束后跳转回当前页面(携带页面参数) if (options.scene) { this.getBookInfo(options.scene) } } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, getBookInfo(refcode) { const obj = { storeInfo: app.config.jslx, path: app.config.jslx, queryType: 'ProductCmsItem', SysType: "CmsFolder", RefCode: refcode, paging: { start: 0, size: 99, }, coverSize: { width: 260 }, fields: { ProductLinkInfo: [], productLinkPath: [], } } app.MG.resource.getItem(obj).then((res) => { console.log(res.datas, '图书信息') let idPathList = []; let book = res.datas[0] this.setData({ bookId: book.productLinkInfo.ProductId, bookName: book.productLinkInfo.Name, productLinkPath: book.productLinkInfo.LinkPath + "\\" + book.id, rootCmsItemId: book.productLinkInfo.LinkPath, cmsId: book.id, answerTitle: book.name }) idPathList.push({ id: book.id, name: book.name, productLinkPath: this.data.productLinkPath, type: book.type, }) wx.redirectTo({ url: `/packageBookService/pages/bookServices/examination/examination?bookId=${ this.data.bookId }&productLinkPath=${this.data.productLinkPath}& =${ this.data.rootCmsItemId }&idPathList=${JSON.stringify(idPathList)}&answerTitle=${ this.data.answerTitle }&answerType=${"option"}&storeInfo=${book.storeInfo}`, }); }) }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })