| | |
| | | } |
| | | } |
| | | const indexof = listIndex |
| | | const questionId = questionList[indexof].id; |
| | | const idPath = questionList[indexof].idPath; |
| | | const bookId = questionList[indexof].bookId; |
| | | const bookName = "大学生心理健康(第3版)(融媒体版)" |
| | | const formPath = "questionBank" |
| | | // 进行处理 |
| | | const query = { |
| | | "cmsItemId": Number(questionId) |
| | | path: "*", |
| | | queryType: "*", |
| | | productId: bookId, |
| | | cmsPath: "161796", |
| | | cmsType: "*" |
| | | }; |
| | | app.MG.file.checkCmsItem(query) |
| | | .then((res) => { |
| | | const isBuys = res; |
| | | this.setData({ |
| | | isBuy: isBuys |
| | | }); |
| | | if (!isBuys) { |
| | | wx.showModal({ |
| | | icon: 'error', |
| | | title: '温馨提示', |
| | | content: '请购买题库,即将返回购买页', |
| | | confirmText: '确定', |
| | | showCancel: false, // 关闭取消按钮 |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: '/packageBookService/pages/bookServices/detail/index?id=' + bookId + '&name=' + bookName + '&tabValue=' + formPath, |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | return; // 直接返回,避免执行后续代码 |
| | | app.MG.store.getProductDetail(query).then(async (res) => { |
| | | const linkPathList = res.datas.cmsDatas[0].datas |
| | | const isBuyList = res.datas.purchasedSaleMethodIdList |
| | | let isBuy = false |
| | | const idParhList = idPath.split("/").reverse() |
| | | for (let index = 0; index < idParhList.length; index++) { |
| | | const item = idParhList[index]; |
| | | const thisItem = linkPathList.find(citem => item == citem.id); |
| | | if (thisItem.saleMethod.length > 0) { |
| | | if (isBuyList.includes(thisItem.saleMethod[0].Id)) { |
| | | isBuy = true |
| | | break |
| | | } else { |
| | | isBuy = false |
| | | break |
| | | } |
| | | } |
| | | // 其他逻辑 |
| | | this.initialize() |
| | | }) |
| | | .catch((err) => { |
| | | console.error('检查题库失败:', err); |
| | | wx.showToast({ |
| | | icon: 'error', |
| | | title: '加载失败,请重试' |
| | | }); |
| | | } |
| | | this.setData({ |
| | | isBuy: isBuy |
| | | }); |
| | | if (!isBuy) { |
| | | wx.showModal({ |
| | | icon: 'error', |
| | | title: '温馨提示', |
| | | content: '请购买题库,即将返回购买页', |
| | | confirmText: '确定', |
| | | showCancel: false, // 关闭取消按钮 |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: '/packageBookService/pages/bookServices/detail/index?id=' + bookId + '&name=' + bookName + '&tabValue=' + formPath, |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | return; // 直接返回,避免执行后续代码 |
| | | } |
| | | // 其他逻辑 |
| | | this.initialize() |
| | | }).catch((err) => { |
| | | console.error('检查题库失败:', err); |
| | | wx.showToast({ |
| | | icon: 'error', |
| | | title: '加载失败,请重试' |
| | | }); |
| | | }); |
| | | } |
| | | }, |
| | | |