| | |
| | | learn: [], |
| | | openLearnids: [], |
| | | bookId: "", |
| | | loading: false, |
| | | loading: true, |
| | | shoppingList: [], |
| | | shoppingCartGetId: [], |
| | | methodId: [], |
| | | paymentPage: false, |
| | | superior: false, |
| | | checkAllState: false, |
| | | checkAllState: true, |
| | | productLinkPath: '', |
| | | refCode: '', |
| | | haider: false |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | 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(); |
| | | console.log(options); |
| | | this.getResourceData({ |
| | | productLinkPath: options.productLinkPath, |
| | | refCode: options.refCode, |
| | | }); |
| | | this.getShoppingCartProductGet(); |
| | | this.getBookInfo(options.bookId); |
| | | }, |
| | | |
| | | /** |
| | |
| | | return this.setData({ |
| | | noResources: true, |
| | | loading: false, |
| | | haider: true |
| | | }); |
| | | } |
| | | //教学资源 云学习 |
| | |
| | | this.setData({ |
| | | teach: list, |
| | | loading: false, |
| | | haider: true |
| | | }); |
| | | this.findChildIds(this.data.teach, (this.data.openTeachids = [])); |
| | | } else if (type.refCode == "jsek_cloudLearning") { |
| | |
| | | learn: list, |
| | | loading: false, |
| | | openLearnids: result, |
| | | haider: true |
| | | }); |
| | | console.log("教学资源", list); |
| | | } |
| | | console.log(list, '云學習'); |
| | | } else { |
| | | // 无数据 |
| | | } |
| | |
| | | this.setData({ |
| | | test: res.datas.cmsDatas[0].datas, |
| | | loading: false, |
| | | haider: true |
| | | }); |
| | | } else { |
| | | console.log("其他"); |
| | |
| | | jsek_resourceBrief: [], |
| | | jsek_link: [], |
| | | accessType: [], |
| | | learnSelectType: [], |
| | | }, |
| | | pading: { |
| | | start: 0, |
| | |
| | | }); |
| | | 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() { |
| | |
| | | const isSHow = this.data.buyIdList.some( |
| | | (item) => item == data.saleMethod[0].Id |
| | | ); |
| | | return !isSHow; |
| | | } else { |
| | | 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; |
| | |
| | | let item = []; |
| | | let selectAllId = []; |
| | | const child = this.selectComponent("#tree"); |
| | | |
| | | console.log( |
| | | child.data.superiorPurchaseSaleMethodId, |
| | | "superiorPurchaseSaleMethodId" |
| | | ); |
| | | console.log(child.data.sonPurchaseSaleMethodId, "child.data"); |
| | | // console.log(child.data.selectAll, 'selectAll'); |
| | | item = child.data.superiorPurchaseSaleMethodId; |
| | | const sonItem = child.data.sonPurchaseSaleMethodId; |
| | | let selectAll = child.data.selectAll; |
| | | if (selectAll) { |
| | | // console.log(selectAll); |
| | | selectAll.forEach((item) => { |
| | | if (item.saleMethod != 0) { |
| | | // console.log(item, 'item'); |
| | | selectAllId.push(item.saleMethod[0].Id); |
| | | } |
| | | }); |
| | | console.log(selectAllId); |
| | | app.MG.store |
| | | .initOrder({ |
| | | requests: selectAllId.map((id) => ({ |
| | |
| | | .then((res) => { |
| | | if (res) { |
| | | wx.navigateTo({ |
| | | url: |
| | | "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | url: "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | }); |
| | | selectAllId = []; |
| | | child.setData({ |
| | |
| | | }); |
| | | } |
| | | if (item) { |
| | | console.log(item, "sadsdasd"); |
| | | // 拿到id |
| | | item.forEach((items) => { |
| | | if (items.saleMethod != 0) { |
| | | saleMethodIds.push(items.saleMethod[0].Id); |
| | | } |
| | | }); |
| | | console.log(saleMethodIds, "saleMethodIds"); |
| | | |
| | | app.MG.store |
| | | .initOrder({ |
| | | requests: saleMethodIds.map((id) => ({ |
| | |
| | | .then((res) => { |
| | | if (res) { |
| | | wx.navigateTo({ |
| | | url: |
| | | "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | url: "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | }); |
| | | |
| | | child.setData({ |
| | |
| | | .then((res) => { |
| | | if (res) { |
| | | wx.navigateTo({ |
| | | url: |
| | | "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | url: "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | }); |
| | | this.setData({ |
| | | paymentPage: true, |
| | |
| | | }); |
| | | } |
| | | }, |
| | | }); |
| | | |
| | | // 章节勾选方法 |
| | | findAndUpdateItemsByIds(tree, ids, state) { |
| | | function findAndUpdate(node) { |
| | | if (ids.includes(node.id)) { |
| | | // console.log(node, 'node'); |
| | | node.checked = state; // 将目标项的 check 属性设置为 true |
| | | } |
| | | if (node.children && node.children.length > 0) { |
| | | for (let child of node.children) { |
| | | findAndUpdate(child); // 递归处理子节点 |
| | | } |
| | | } |
| | | } |
| | | for (let node of tree) { |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | // console.log(tree, 'tree345'); |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | // 单个勾选方法 |
| | | checkResoucrceInfo(tree, id) { |
| | | function findAndUpdate(node) { |
| | | if (node.sysType == "CmsFolder" && node.children.length > 0) { |
| | | for (let index = 0; index < node.children.length; index++) { |
| | | const element = node.children[index]; |
| | | findAndUpdate(element); |
| | | } |
| | | } else if (id == node.id && node.sysType == "CmsItem") { |
| | | node.checked = !node.checked; // 将目标项的 check 属性设置为 true |
| | | } |
| | | } |
| | | for (let node of tree) { |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | // 章节勾选事件 |
| | | changeListChecked(e) { |
| | | const ids = e.detail.ids |
| | | const state = e.detail.flag |
| | | const updated = this.findAndUpdateItemsByIds(this.data.learn, ids, state) |
| | | this.setData({ |
| | | learn: updated |
| | | }) |
| | | }, |
| | | // 单个勾选事件 |
| | | changeResourceChecked(e) { |
| | | const id = e.detail.id |
| | | const updated = this.checkResoucrceInfo(this.data.learn, id) |
| | | this.setData({ |
| | | learn: updated |
| | | }) |
| | | } |
| | | }); |