| | |
| | | paymentPage: false, |
| | | superior: false, |
| | | checkAllState: true, |
| | | productLinkPath: '', |
| | | refCode: '' |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | this.getBookInfo(options.bookId); |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = |
| | |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | bookId: options.bookId, |
| | | productLinkPath: options.productLinkPath, |
| | | refCode: options.refCode |
| | | }); |
| | | this.getResourceClass(); |
| | | this.getResourceData({ |
| | | productLinkPath: options.productLinkPath, |
| | | refCode: options.refCode, |
| | | }); |
| | | this.getShoppingCartProductGet(); |
| | | this.getBookInfo(options.bookId); |
| | | }, |
| | | |
| | | /** |
| | |
| | | }); |
| | | data.datas.cmsDatas[0].datas.forEach((item) => { |
| | | item.checked = false; |
| | | item.isbuy = this.resourceIsBuy(item); |
| | | item.isbuy = this.isShowNeedBuy(item); |
| | | item.isShopCar = this.isShoppingCart(item); |
| | | }); |
| | | return data.datas.cmsDatas[0].datas; |
| | | }, |
| | | getBookInfo(id) { |
| | | async getBookInfo(id) { |
| | | this.setData({ |
| | | "mockData'.id": 0, |
| | | "mockData.price": 0, |
| | |
| | | freeEpubPage: [], //epub试读百分比 |
| | | }, |
| | | }; |
| | | app.MG.store.getProductDetail(query).then(async (res) => { |
| | | await app.MG.store.getProductDetail(query).then(async (res) => { |
| | | this.setData({ |
| | | bookDetail: res.datas, |
| | | buyIdList: res.datas.purchasedSaleMethodIdList, |
| | | }); |
| | | this.getResourceData({ |
| | | productLinkPath: this.data.productLinkPath, |
| | | refCode: this.data.refCode, |
| | | }); |
| | | }); |
| | | |
| | | }, |
| | | // 获取已购买商品 |
| | | getShoppingCartProductGet() { |
| | |
| | | return false; |
| | | } |
| | | }, |
| | | |
| | | isShowNeedBuy(data) { |
| | | if (data.saleMethod && data.saleMethod.length) { |
| | | const isSHow = this.data.buyIdList.some( |
| | | (item) => item == data.saleMethod[0].Id |
| | | ); |
| | | if (isSHow) { |
| | | return false; |
| | | } else { |
| | | return data.saleMethod[0].price > 0 ? true : false; |
| | | } |
| | | return !isSHow; |
| | | } else { |
| | | return false; |
| | | } |
| | | }, |
| | | // 判断资源加入购物车按钮是否显示 |
| | | isShoppingCart(data) { |
| | | if (data.saleMethod && data.saleMethod.length) { |