From 04c7b0163caeae4ab1c5da62e301fa993101cfad Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期一, 31 三月 2025 10:40:45 +0800 Subject: [PATCH] bug修改 --- packageBookService/pages/bookServices/detail/index.js | 1037 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 577 insertions(+), 460 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index 8c7fbf8..4a1ea38 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -13,9 +13,6 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - // 杩涢〉闈㈤粯璁ゅ垏鎹� 灞曞紑鐨刬d - // defaultactiveTeachid 鏁欏璧勬簮 - // defaultactiveLearnid 浜戝涔� bookId: "", barHeight: "", navBarHeight: "", @@ -49,7 +46,7 @@ learnPath: '', applyResourceState: false, // 鐢宠鏁欏璧勬簮鎸夐挳闃叉姈 resourceClassList: [], // 璧勬簮鎵�灞炲垎绫� - applyState: "", // 鏁欏璧勬簮鐢宠鐘舵�� + applyState: "1", // 鏁欏璧勬簮鐢宠鐘舵�� deadline: "", // 鏁欏璧勬簮鐢宠鏈夋晥鏃ユ湡, isShowBuyCloundBtn: false, isshowDrawBtn: true, // 浜戝涔犻鍙栨煡鐪嬫寜閽槸鍚︽樉绀� @@ -75,7 +72,8 @@ residue: 0, // 缁勫嵎鍓╀綑娆℃暟 mockList: [], // 鐢ㄦ埛缁勫嵎鎻愪氦淇℃伅 }, - isBuyBank: false, + isBuyBank: false, // 棰樺簱鏄惁璐拱 + isShoppingBank: false, // 棰樺簱鏄惁鍔犲叆璐墿杞� bankSaleData: null, relatedBookLoading: false, noRelatedBookData: false, @@ -213,7 +211,8 @@ protocolShow: false, protocolTxt: '', learnMenu: null, - md5List: [] + md5List: [], + editDialog: false }, resetTree: function (e) { @@ -221,6 +220,26 @@ currentCheck: e.detail.checkedItem, list: e.detail.changeList, }); + }, + + logInFun(callback) { + loginInfo(app, (data) => { + if (data) { + this.getShoppingCartProductGet(); + this.getApplyInfo(this.data.options.id); + this.getAlreadyPBookList(); + this.getAlreadyEBookList(); + if (wx.getStorageSync(app.config.userInfoKey)) { + this.setData({ + userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), + }); + // 鑾峰彇鐢宠娆℃暟 + this.getSelectPaperBookCount(); + this.getSelectBookCount(); + } + callback() + } + }) }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 @@ -243,35 +262,26 @@ wx.setNavigationBarTitle({ title: decodeURI(options.name), }) - let token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - if (data) {} else {} - }) - } this.getBookInfo(options.id); - // this.getResourceClass(); // 鑾峰彇璧勬簮鎵�灞炲垎绫� - token = wx.getStorageSync(app.config.tokenKey) - if (token) { - this.getShoppingCartProductGet(); - this.getApplyInfo(options.id); - this.getAlreadyPBookList(); - this.getAlreadyEBookList(); - } - if (wx.getStorageSync(app.config.userInfoKey)) { - this.setData({ - userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), - }); - // 鑾峰彇鐢宠娆℃暟 - this.getSelectPaperBookCount(); - this.getSelectBookCount(); - } if (options.tabValue) { this.setData({ tabValue: options.tabValue, }); - - + } + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + this.getShoppingCartProductGet(); + this.getApplyInfo(this.data.options.id); + this.getAlreadyPBookList(); + this.getAlreadyEBookList(); + if (wx.getStorageSync(app.config.userInfoKey)) { + this.setData({ + userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), + }); + // 鑾峰彇鐢宠娆℃暟 + this.getSelectPaperBookCount(); + this.getSelectBookCount(); + } } }, @@ -291,8 +301,9 @@ } this.setData({ num: Number(this.data.paperBookList.length) + Number(this.data.electronicBookList.length), + editDialog: false }); - if (this.data.bookDetail) { + if (this.data.bookDetail.id) { this.getBookInfo(this.data.bookDetail.id) } }, @@ -432,11 +443,14 @@ protectedEpub: [], probationPage: [], //pdf璇曡椤垫暟 freeEpubPage: [], //epub璇曡鐧惧垎姣� + bookEditor: [], //鍥句功缂栬緫 + contactInformation: [], //鑱旂郴鏂瑰紡 }, }; app.MG.store.getProductDetail(query).then(async (res) => { this.getResourceCode(id, res.datas.rootCmsItemId) - console.log(res.datas, "res.datas") + res.datas.bookEditor = res.datas.bookEditor ? res.datas.bookEditor : '-' + res.datas.contactInformation = res.datas.contactInformation ? res.datas.contactInformation : '-' this.setData({ bookDetail: res.datas, buyIdList: res.datas.purchasedSaleMethodIdList, @@ -470,6 +484,16 @@ } await this.getBookClass(classData); } + } + // 鎵爜浠庨搴撹烦杞洖鍥句功璇︽儏 + const localData = wx.getStorageSync('tabValue') + if (localData) { + this.setData({ + tabValue: localData + }) + wx.removeStorage({ + key: 'tabValue', + }) } if (this.data.tabValue == 'questionBank' || this.data.tabValue == 'jsek_cloudLearning' || this.data.tabValue == 'jsek_teachingResources') { const checkData = this.data.cmsDatas.find( @@ -514,7 +538,6 @@ "bookDetail.paperPrice": this.numFormat( this.data.bookDetail.paperPrice ), - }); }); }, @@ -533,8 +556,8 @@ } } app.MG.store.getProductDetail(query).then((res) => { - console.log(111, res.datas.cmsDatas[0].datas); let isBuyBank = true + let isShoppingBank = true let bankSaleData = null // 鍒ゆ柇棰樺簱鏄惁鏁翠綋璐拱 const bank = res.datas.cmsDatas[0].datas.find((item) => item.refCode == 'questionBank') @@ -543,6 +566,7 @@ bankSaleData = bank.saleMethod.find((item) => item.SaleType == 'Normal') if (bankSaleData) { isBuyBank = this.data.buyIdList.includes(bankSaleData.Id) + isShoppingBank = this.data.buyIdList.includes(bankSaleData.Id) ? true : this.data.shoppingCartGetId.includes(bankSaleData.Id) } } } @@ -550,6 +574,7 @@ resourceCodeList: res.datas.cmsDatas[0].datas, learnTaskData: res.datas.cmsDatas[0].datas.filter((item) => item.refCode == 'jsek_learningTasks')[0], isBuyBank, + isShoppingBank, bankSaleData }) if (res.datas.cmsDatas[0].datas.length) this.setData({ @@ -710,51 +735,64 @@ setCollect() { const token = wx.getStorageSync(app.config.tokenKey); if (!token) { - // 妫�鏌ョ櫥褰曠姸鎬� - loginInfo(app, (data) => { - // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� - if (data) { - // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue - this.getBookInfo(this.data.bookId); - } else { - // 鍑虹幇閿欒锛岃繑鍥瀎alse - } - }); + this.logInFun(() => { + this.getBookInfo(this.data.bookId); + }) } else { - if (this.data.bookDetail.isFavourite) { - app.MG.store - .delProductLink({ - productIds: [this.data.bookDetail.id], - linkType: "FavoriteBookCity", - }) - .then(() => { - this.setData({ - "bookDetail.isFavourite": false, - }); - }); - } else { - const params = { + this.collectFun() + } + }, + collectFun() { + if (this.data.bookDetail.isFavourite) { + app.MG.store + .delProductLink({ productIds: [this.data.bookDetail.id], linkType: "FavoriteBookCity", - }; - app.MG.store.addProductLink(params).then((res) => { + }) + .then(() => { this.setData({ - "bookDetail.isFavourite": true, + "bookDetail.isFavourite": false, }); }); - } + } else { + const params = { + productIds: [this.data.bookDetail.id], + linkType: "FavoriteBookCity", + }; + app.MG.store.addProductLink(params).then((res) => { + this.setData({ + "bookDetail.isFavourite": true, + }); + }); } + }, + // 鑱旂郴 + editPhone() { + this.setData({ + editDialog: true + }) + }, + closeEditDialog() { + this.setData({ + editDialog: false + }) }, // 鎴戣寤鸿 suggestBtn() { // 妫�鏌ョ櫥褰曠姸鎬� const token = wx.getStorageSync(app.config.tokenKey); - const child = this.selectComponent("#suggest-component"); - if (token) - // child.showDialog(); + if (token) { this.setData({ showIndex: '1' }) + } else { + this.logInFun(() => { + this.setData({ + showIndex: '1' + }) + }) + } + }, // 璺宠浆缃戝簵 goShop(e) { @@ -788,17 +826,6 @@ "buyResourceData.refCode": checkData.refCode, }); } - // if ( - // (e.detail.value == "jsek_teachingResources" && - // !this.data.teach.length) || - // (e.detail.value == "jsek_cloudLearning" && !this.data.learn.length) || - // (e.detail.value == "questionBank" && !this.data.test.length) - // ) { - // if (e.detail.value == "jsek_teachingResources") { - // wx.setStorageSync('teachResourcesPath', checkData.productLinkPath) - // } - // this.getResourceData(checkData); - // } if ((e.detail.value == "jsek_teachingResources" && !this.data.teach.length) || (e.detail.value == "jsek_cloudLearning" && !this.data.learn.length)) { wx.setStorageSync('teachResourcesPath', checkData.productLinkPath) this.getResourceDataList(checkData) @@ -1006,7 +1033,6 @@ loading: false, }); } - let list = [] // 鍒ゆ柇浜戝涔犳湁鏃犻攢鍞柟寮忓拰鏈夋晥鏈� const cloundSaleMethod = @@ -1022,7 +1048,6 @@ res.datas.cmsDatas[0].datas.forEach((item) => { // 浜戝涔犱笂鏈夐攢鍞柟寮忥紝鍘绘帀浜戝涔犱笅鎵�鏈夐攢鍞柟寮� if (this.data.tabValue == "jsek_teachingResources") { - if (item.file || item.freeFile) { let md5 = item.file ? item.file : item.freeFile md5s.push(md5) @@ -1031,7 +1056,7 @@ md5List: md5s, }); } - if (flags) item.saleMethod = [] + if (flags && cloundSaleMethod.Price > 0) item.saleMethod = [] item.checked = false; if (item.sysType == 'CmsItem') { // 鏁欏璧勬簮 绫诲瀷鍚嶇О璧嬪�� @@ -1079,7 +1104,7 @@ new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() ) || (flags && cloundSaleMethod.Price == 0) // 鍒ゆ柇浜戝涔犲叏閮ㄨ喘涔版寜閽槸鍚︽樉绀� - let isShowBuyCloundMenu = flags && cloundSaleMethod.Price >= 0 && !this.data.buyIdList.includes(cloundSaleMethod.Id) + let isShowBuyCloundMenu = flags && cloundSaleMethod.Price > 0 && !this.data.buyIdList.includes(cloundSaleMethod.Id) // 鍒ゆ柇璧勬簮璐拱鎸夐挳鏄惁鏄剧ず let isShowBuyCloundBtn = !flags && res.datas.cmsDatas[0].datas.some(citem => citem.saleMethod.length != 0) // 鍒ゆ柇璐墿杞︽寜閽拰閿佹寜閽槸鍚︽樉绀� @@ -1092,13 +1117,14 @@ isshowDrawBtn, isShowBuyCloundMenu, isShowBuyCloundBtn, - isCloundHaveSaleMethod: flags, + isCloundHaveSaleMethod: flags && cloundSaleMethod.Price > 0, learn: list, loading: false, openLearnids: result, learnPath: type.productLinkPath }); } + console.log('1', this.data.teach); }) }, // 鑾峰彇 浜戞祴璇� @@ -1163,9 +1189,8 @@ }); } } else { - if (isTSFW.length > 0) { - data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && (item.childrenFolderCount > 0 || item.childrenCount > 0) && (item.name !== '濉┖棰�' && + data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.refCode != 'jsek_interaction' && (item.childrenFolderCount > 0 || item.childrenCount > 0) && (item.name !== '濉┖棰�' && item.name !== '鍒ゆ柇棰�' && item.name !== '澶氶�夐' && item.name !== '绠�绛旈') && item.name !== '鍗曢�夐') @@ -1173,8 +1198,8 @@ jslx: false, }); } else { - data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && - item.refCode != 'jsek_interaction') + data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder') + // && item.refCode != 'jsek_interaction' that.setData({ jslx: true, }); @@ -1251,48 +1276,57 @@ }, // 鍥句功娣诲姞璐墿杞� - async addBookShopcCar() { - if (!this.data.expire) { - const shoppingCartGetId = []; - let query = { - start: 0, - size: 9999, - filterList: [], - searchList: [], - }; - const res = await app.MG.store.getShoppingCartProductList(query); - res.datas.forEach((item) => { - shoppingCartGetId.push(item.saleMethod.id); - }); - const determine = shoppingCartGetId.some( - (item) => item == this.data.selectedIds - ); - if (!determine) { + addBookShopcCar() { + const addFun = async () => { + if (!this.data.expire) { + const shoppingCartGetId = []; let query = { - requests: [{ - saleMethodId: this.data.selectedIds, - storeEventId: null, - agentCode: "鐢靛瓙涔�", - }, ], + start: 0, + size: 9999, + filterList: [], + searchList: [], }; - const addRes = app.MG.store.addShoppingCart(query); - this.showSuccessToast(); + const res = await app.MG.store.getShoppingCartProductList(query); + res.datas.forEach((item) => { + shoppingCartGetId.push(item.saleMethod.id); + }); + const determine = shoppingCartGetId.some( + (item) => item == this.data.selectedIds + ); + if (!determine) { + let query = { + requests: [{ + saleMethodId: this.data.selectedIds, + storeEventId: null, + agentCode: "鐢靛瓙涔�", + }, ], + }; + const addRes = app.MG.store.addShoppingCart(query); + this.showSuccessToast(); + } else { + Toast({ + context: this, + selector: "#t-toast", + message: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞", + theme: "warning", + direction: "column", + }); + } } else { - Toast({ - context: this, - selector: "#t-toast", - message: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞", - theme: "warning", - direction: "column", + wx.showToast({ + title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", + icon: "none", + duration: 1000, }); } - } else { - wx.showToast({ - title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", - icon: "none", - duration: 1000, - }); } + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + addFun() + } else { + this.logInFun(() => {}) + } + }, showSuccessToast() { @@ -1652,7 +1686,7 @@ (item) => item == saleData.Id ); // 宸茬粡璐拱 - if (isShow) return false + if (isShow || saleData.Price == 0) return false // 鏈喘涔帮紝鏌ョ湅閿�鍞柟寮忔槸鍚﹁繃鏈� if (!isShow) { const flag = new Date(saleData.EndDate).getTime() >= new Date().getTime() && @@ -1767,85 +1801,83 @@ return flattenedArray; }, // 浜戝涔犱竴閿鍙� - async getFreeResource() { + getFreeResource() { + const getFreeFun = async () => { + // 棰嗗彇鏌ョ湅 锛屽厛鐪嬩簯瀛︿範涓婄殑 鍐嶇湅璧勬簮涓婄殑 + const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') + const cloundMenuSaleMethod = + cloundMenu.saleMethod && cloundMenu.saleMethod.length ? + cloundMenu.saleMethod.find((ditem) => ditem.SaleType == 'Normal') : + undefined + let query = {} + if (this.data.isCloundHaveSaleMethod && !cloundMenuSaleMethod.Price) { + // 浜戝涔犱笂鏈夐攢鍞柟寮忥紝涓斾负0鍏冿紝鐩存帴棰嗗彇浜戝涔� + query = { + remarks: '浜戝涔�', + requests: [{ + saleMethodId: cloundMenuSaleMethod.Id, + count: 1 + }] + } + } else { + // 棰嗗彇璧勬簮 + let arr = this.handleTreeData(this.data.learn).filter(item => this.resourceIsBuy(item)) + let freeIds = arr.filter((item) => { + return item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price == 0 + }) + if (!freeIds.length) + return wx.showToast({ + icon: "error", + title: "鏆傛棤鍏嶈垂璧勬簮", + }); + let requests = []; + freeIds.forEach((item, index) => { + if (this.resourceIsBuy(item)) { + requests.push({ + saleMethodId: item.saleMethod[0].Id, + count: 1, + }); + } + }); + query = { + remarks: "浜戝涔�", + requests, + }; + } + child.changeReceive(true); + try { + const initOrderRes = await app.MG.store.initOrder(query); + let parameter = { + orderNum: initOrderRes.orderNumber, + }; + // 纭璁㈠崟 + const confirmOrderRes = await app.MG.store.confirmOrder(parameter); + if (confirmOrderRes.orderNumber) { + child.changeReceive(false); + wx.showToast({ + title: "棰嗗彇鎴愬姛", + }); + this.getBookInfo(this.data.bookId); + this.getResourceDataList({ + refCode: 'jsek_cloudLearning', + productLinkPath: this.data.learnPath + }) + this.setData({ + successOrderNumber: confirmOrderRes.orderNumber + }) + } + } catch (error) { + console.log(error); + } + } const child = this.selectComponent("#learn-resource"); const token = wx.getStorageSync(app.config.tokenKey); if (!token) { - loginInfo(app, (data) => { - // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� - if (data) { - // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue - } else { - // 鍑虹幇閿欒锛岃繑鍥瀎alse - } - }); - } - // 棰嗗彇鏌ョ湅 锛屽厛鐪嬩簯瀛︿範涓婄殑 鍐嶇湅璧勬簮涓婄殑 - const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') - const cloundMenuSaleMethod = - cloundMenu.saleMethod && cloundMenu.saleMethod.length ? - cloundMenu.saleMethod.find((ditem) => ditem.SaleType == 'Normal') : - undefined - let query = {} - if (this.data.isCloundHaveSaleMethod && !cloundMenuSaleMethod.Price) { - // 浜戝涔犱笂鏈夐攢鍞柟寮忥紝涓斾负0鍏冿紝鐩存帴棰嗗彇浜戝涔� - query = { - remarks: '浜戝涔�', - requests: [{ - saleMethodId: cloundMenuSaleMethod.Id, - count: 1 - }] - } + this.logInFun(() => {}); } else { - // 棰嗗彇璧勬簮 - let arr = this.handleTreeData(this.data.learn).filter(item => this.resourceIsBuy(item)) - let freeIds = arr.filter((item) => { - return item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price == 0 - }) - if (!freeIds.length) - return wx.showToast({ - icon: "error", - title: "鏆傛棤鍏嶈垂璧勬簮", - }); - let requests = []; - freeIds.forEach((item, index) => { - if (this.resourceIsBuy(item)) { - requests.push({ - saleMethodId: item.saleMethod[0].Id, - count: 1, - }); - } - }); - query = { - remarks: "浜戝涔�", - requests, - }; + getFreeFun() } - child.changeReceive(true); - try { - const initOrderRes = await app.MG.store.initOrder(query); - let parameter = { - orderNum: initOrderRes.orderNumber, - }; - // 纭璁㈠崟 - const confirmOrderRes = await app.MG.store.confirmOrder(parameter); - if (confirmOrderRes.orderNumber) { - child.changeReceive(false); - wx.showToast({ - title: "棰嗗彇鎴愬姛", - }); - this.getBookInfo(this.data.bookId); - this.getResourceDataList({ - refCode: 'jsek_cloudLearning', - productLinkPath: this.data.learnPath - }) - this.setData({ - successOrderNumber: confirmOrderRes.orderNumber - }) - } - } catch (error) { - console.log(error); - } + }, // 浜戝涔犱竴閿喘涔� async allAddShoppiingCar() { @@ -1898,34 +1930,37 @@ } }, // 浜戝涔犲叏閮ㄨ喘涔� - async buyCloudLearnClass() { - const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') - debugger - let query = { - remarks: '浜戝涔�', - requests: [{ - saleMethodId: cloundMenu.saleMethod.find((eitem) => eitem.SaleType == 'Normal').Id, - count: 1 - }] + buyCloudLearnClass() { + const buyClass = async () => { + const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') + let query = { + remarks: '浜戝涔�', + requests: [{ + saleMethodId: cloundMenu.saleMethod.find((eitem) => eitem.SaleType == 'Normal').Id, + count: 1 + }] + } + const initOrderRes = await app.MG.store.initOrder(query) + // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 + if (initOrderRes.orderNumber) { + // bookService: orderNumber.value, 灏戜紶杩欎釜 锛屾殏鏃朵笉鐭ラ亾鏈変粈涔堢敤 + wx.navigateTo({ + url: `/pages/cart/paymentPage/index?&bookId=${this.data.bookDetail.id}&bookName=${this.data.bookDetail.name}&orderNumber=${initOrderRes.orderNumber}`, + }); + } else { + // 璁㈠崟鍙蜂笉瀛樺湪锛屾樉绀鸿鍛婃秷鎭� + wx.showToast({ + icon: "error", + title: "璇烽噸璇�", + }); + } } - const initOrderRes = await app.MG.store.initOrder(query) - // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 - if (initOrderRes.orderNumber) { - // bookService: orderNumber.value, 灏戜紶杩欎釜 锛屾殏鏃朵笉鐭ラ亾鏈変粈涔堢敤 - wx.navigateTo({ - url: `/pages/cart/paymentPage/index?&bookId=${this.data.bookDetail.id}&bookName=${this.data.bookDetail.name}&orderNumber=${initOrderRes.orderNumber}`, - }); + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + buyClass() } else { - // 璁㈠崟鍙蜂笉瀛樺湪锛屾樉绀鸿鍛婃秷鎭� - wx.showToast({ - icon: "error", - title: "璇烽噸璇�", - }); + this.logInFun(() => {}) } - }, - // 浜戝涔犲瓧娈佃喘涔� - async buyCloundMenu() { - const cloundData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning') }, // 鍙樹负鎵�鏈塩heck true @@ -1946,13 +1981,9 @@ } return tree; // 杩斿洖淇敼鍚庣殑瀹屾暣鏁扮粍 }, - handleTrue() { - // findAndUpdateItemsByIds(this.date.) - }, // 棰樺簱璐拱 async buyBank() { - console.log(11, this.data.bankSaleData); let query = { remarks: '浜戞祴璇�', requests: [{ @@ -1984,6 +2015,24 @@ } }); } + }, + // 棰樺簱鍔犲叆璐墿杞� + handleShoppingBank() { + let query = { + requests: [{ + saleMethodId: this.data.bankSaleData.Id, + storeEventId: null, + agentCode: "浜戞祴璇�", + }, ], + }; + app.MG.store.addShoppingCart(query).then(res => { + wx.showToast({ + icon: 'success', + title: '鍔犲叆鎴愬姛', + }) + this.getShoppingCartProductGet(); + this.getBookInfo(this.data.bookDetail.id) + }) }, // 缁勫嵎鏍煎紡鍖栨棩鏈熸樉绀� DateFormat(date, fmt) { @@ -2054,53 +2103,62 @@ }); }, // 璐拱缁勫嵎 - async buyMock() { - let res; - if (!this.data.mockData.id) - return wx.showToast({ - icon: "error", - title: "鏆傛棤缁勫嵎", - mask: true, - }); - // 鏋勫缓璁㈠崟鏌ヨ瀵硅薄 - try { - let query = { - remarks: "缁勫嵎", - requests: [{ - saleMethodId: this.data.mockData.id, - count: 1, - }, ], - }; - if (this.data.flag) { - this.setData({ - flag: false, + buyMock() { + const buyMockFun = async () => { + let res; + if (!this.data.mockData.id) + return wx.showToast({ + icon: "error", + title: "鏆傛棤缁勫嵎", + mask: true, }); - res = await app.MG.store.initOrder(query); - } - if (res.orderNumber && this.data.mockData.price) { - wx.navigateTo({ - url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`, - }); - } else { - // 0鍏冪洿鎺ラ鍙� - // 纭璁㈠崟 - const confirmOrderRes = await app.MG.store.confirmOrder({ - orderNum: res.orderNumber, - }); - if (confirmOrderRes) { - wx.showToast({ - icon: "success", - title: "棰嗗彇鎴愬姛", - }); + // 鏋勫缓璁㈠崟鏌ヨ瀵硅薄 + try { + let query = { + remarks: "缁勫嵎", + requests: [{ + saleMethodId: this.data.mockData.id, + count: 1, + }, ], + }; + if (this.data.flag) { this.setData({ - flag: true, + flag: false, }); - await this.recordBuyMock(); // 璁板綍璐拱鏃堕棿 + res = await app.MG.store.initOrder(query); } + if (res.orderNumber && this.data.mockData.price) { + wx.navigateTo({ + url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`, + }); + } else { + // 0鍏冪洿鎺ラ鍙� + // 纭璁㈠崟 + const confirmOrderRes = await app.MG.store.confirmOrder({ + orderNum: res.orderNumber, + }); + if (confirmOrderRes) { + wx.showToast({ + icon: "success", + title: "棰嗗彇鎴愬姛", + }); + this.setData({ + flag: true, + }); + await this.recordBuyMock(); // 璁板綍璐拱鏃堕棿 + } + } + } catch (error) { + console.log(error); } - } catch (error) { - console.log(error); } + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + buyMockFun() + } else { + this.logInFun(() => {}) + } + }, // 璁板綍璐拱缁勫嵎鏃堕棿 recordBuyMock() { @@ -2202,40 +2260,65 @@ }, // 搴曢儴璐拱鎸夐挳 buyBtn() { - if (this.data.tabValue == "brief" && !this.data.bookBuy) { - this.buyBook(); - } else if (this.data.tabValue == "jsek_cloudLearning") { - const tree = this.selectComponent("#tree"); - tree.onCloudShoppingCart(); - } else { - console.log(this.data.tabValue); + const buyFun = () => { + if (this.data.tabValue == "brief" && !this.data.bookBuy) { + this.buyBook(); + } else if (this.data.tabValue == "jsek_cloudLearning") { + const tree = this.selectComponent("#tree"); + tree.onCloudShoppingCart(); + } else { + console.log(this.data.tabValue); + } } + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + buyFun() + } else { + this.logInFun(() => {}) + } + }, - goRead() { - if (!this.data.noFile) { - wx.showToast({ - title: "鏆傛棤闃呰鏂囦欢", - icon: "none", - duration: 2000, + goRead(e) { + const readFun = (bookBuy) => { + if (!this.data.noFile) { + wx.showToast({ + title: "鏆傛棤闃呰鏂囦欢", + icon: "none", + duration: 2000, + }); + return false; + } + wx.navigateTo({ + url: "/packageBookService/pages/components/webView/index?md5=" + + this.data.fileInfo.md5 + + "&fileName=" + + this.data.fileInfo.bookName + + "&fileType=" + + this.data.fileInfo.fileType + + "&freePage=" + + this.data.fileInfo.freePage + + "&bookBuy=" + + bookBuy + + "&bookId=" + + this.data.bookDetail.id, }); - return false; } - wx.navigateTo({ - url: "/packageBookService/pages/components/webView/index?md5=" + - this.data.fileInfo.md5 + - "&fileName=" + - this.data.fileInfo.bookName + - "&fileType=" + - this.data.fileInfo.fileType + - "&freePage=" + - this.data.fileInfo.freePage + - "&bookBuy=" + - this.data.bookBuy + - "&bookId=" + - this.data.bookDetail.id, + const { + type + } = e.currentTarget.dataset + if (type == 'freeFile') return readFun(this.data.bookBuy) + if (this.data.bookDetail.price == '0.00') + return readFun(true) + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + readFun(this.data.bookBuy) + } else { + this.logInFun(() => { + readFun(this.data.bookBuy) + }) + } - }); }, //鏍蜂功鐢宠 @@ -2348,179 +2431,127 @@ //鐢宠鐢靛瓙鏍蜂功 appplyElectronicBook() { - // 鍏堝垽鏂笅鏁欏笀璁よ瘉锛屾湭瀵瑰師鏈夐�昏緫淇敼 - let role = this.data.userInfo != null ? this.data.userInfo.role : null; - if (role && role == "Teacher") {} else { - return wx.showModal({ - title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� - content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� - confirmColor: "#ff6c00", - cancelColor: "#949494", - success: function (res) { - if (res.confirm) { - wx.navigateTo({ - url: "/packageDomain/pages/teacherCertification/index", - }); - } else if (res.cancel) {} - }, - }); - } - if ( - this.data.bookDetail.isApplyBook == 2 || - this.data.bookDetail.isApplyBook == 4 - ) { + const applyFun = () => { + // 鍏堝垽鏂笅鏁欏笀璁よ瘉锛屾湭瀵瑰師鏈夐�昏緫淇敼 let role = this.data.userInfo != null ? this.data.userInfo.role : null; - if (role && role == "Teacher") { - if (!this.data.noFile) { - wx.showToast({ - title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!", - icon: "none", - duration: 1000, - }); - return; - } - if (this.data.ebookCount == 0) { - wx.showToast({ - title: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", - icon: "none", - duration: 1000, - }); - return false; - } - - let isHas = this.data.electronicBookList.find( - (eitem) => eitem.id == this.data.bookDetail.id - ); - if (isHas) { - wx.showToast({ - title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", - icon: "none", - duration: 1000, - }); - return false; - } - let isApply = this.data.alreadyElectronicBookList.find( - (eitem) => eitem.content[0].id == this.data.bookDetail.id - ); - if (isApply) { - if (isApply.state == 'WaitAudit') { + if (role && role == "Teacher") {} else { + return wx.showModal({ + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� + confirmColor: "#ff6c00", + cancelColor: "#949494", + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: "/packageDomain/pages/teacherCertification/index", + }); + } else if (res.cancel) {} + }, + }); + } + if ( + this.data.bookDetail.isApplyBook == 2 || + this.data.bookDetail.isApplyBook == 4 + ) { + let role = this.data.userInfo != null ? this.data.userInfo.role : null; + if (role && role == "Teacher") { + if (!this.data.noFile) { wx.showToast({ - title: "璇ヤ功宸茬敵璇凤紒", + title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!", + icon: "none", + duration: 1000, + }); + return; + } + if (this.data.ebookCount == 0) { + wx.showToast({ + title: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", icon: "none", duration: 1000, }); return false; - } else if (isApply.state == 'Normal') { - const flag = new Date(isApply.feedBack.endDate + ' 23:59:59').getTime() > new Date().getTime() - if (flag) { + } + + let isHas = this.data.electronicBookList.find( + (eitem) => eitem.id == this.data.bookDetail.id + ); + if (isHas) { + wx.showToast({ + title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", + icon: "none", + duration: 1000, + }); + return false; + } + let isApply = this.data.alreadyElectronicBookList.find( + (eitem) => eitem.content[0].id == this.data.bookDetail.id + ); + if (isApply) { + if (isApply.state == 'WaitAudit') { wx.showToast({ title: "璇ヤ功宸茬敵璇凤紒", icon: "none", duration: 1000, }); return false; + } else if (isApply.state == 'Normal') { + const flag = new Date(isApply.feedBack.endDate + ' 23:59:59').getTime() > new Date().getTime() + if (flag) { + wx.showToast({ + title: "璇ヤ功宸茬敵璇凤紒", + icon: "none", + duration: 1000, + }); + return false; + } } } - } - if (this.data.electronicBookList.length >= 2) { - wx.showToast({ - title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", - icon: "none", - duration: 1000, + if (this.data.electronicBookList.length >= 2) { + wx.showToast({ + title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", + icon: "none", + duration: 1000, + }); + return false; + } + this.addBookFun(this.data.bookDetail, "eBook"); + } else { + wx.showModal({ + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� + confirmColor: "#ff6c00", + cancelColor: "#949494", + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: "/packageDomain/pages/teacherCertification/index", + }); + } else if (res.cancel) {} + }, }); - return false; } - this.addBookFun(this.data.bookDetail, "eBook"); } else { - wx.showModal({ - title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� - content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� - confirmColor: "#ff6c00", - cancelColor: "#949494", - success: function (res) { - if (res.confirm) { - wx.navigateTo({ - url: "/packageDomain/pages/teacherCertification/index", - }); - } else if (res.cancel) {} - }, + wx.showToast({ + title: "璇ヤ功涓嶈兘鐢宠鐢靛瓙鏍蜂功", + icon: "none", + duration: 1000, }); } - } else { - wx.showToast({ - title: "璇ヤ功涓嶈兘鐢宠鐢靛瓙鏍蜂功", - icon: "none", - duration: 1000, - }); } + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + applyFun() + } else { + this.logInFun(() => {}) + } + }, //鐢宠绾歌川鏍蜂功 appplyPaperBook() { - let role = this.data.userInfo != null ? this.data.userInfo.role : null; - if (role && role == "Teacher") {} else { - return wx.showModal({ - title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� - content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� - confirmColor: "#ff6c00", - cancelColor: "#949494", - success: function (res) { - if (res.confirm) { - wx.navigateTo({ - url: "/packageDomain/pages/teacherCertification/index", - }); - } else if (res.cancel) {} - }, - }); - } - if ( - this.data.bookDetail.isApplyBook == 3 || - this.data.bookDetail.isApplyBook == 4 - ) { + const applyFun = () => { let role = this.data.userInfo != null ? this.data.userInfo.role : null; - if (role && role == "Teacher") { - // 鐐瑰嚮閫変腑 - if (this.data.paperBookCount == 0) { - wx.showToast({ - title: "鎮ㄧ殑绾歌川鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", - icon: "none", - duration: 1000, - }); - return false; - } - let isApply = this.data.alreadyPaperBookList.find( - (pitem) => pitem.content[0].id == this.data.bookDetail.id - ); - if (isApply) { - wx.showToast({ - title: "璇ヤ功宸茬敵璇凤紒", - icon: "none", - duration: 1000, - }); - return false; - } - - let isHas = this.data.paperBookList.find( - (pitem) => pitem.id == this.data.bookDetail.id - ); - if (isHas) { - wx.showToast({ - title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", - icon: "none", - duration: 1000, - }); - return false; - } - if (this.data.paperBookList.length >= 2) { - wx.showToast({ - title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", - icon: "none", - duration: 1000, - }); - return false; - } - this.addBookFun(this.data.bookDetail, "pBook"); - } else { - wx.showModal({ + if (role && role == "Teacher") {} else { + return wx.showModal({ title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� confirmColor: "#ff6c00", @@ -2534,13 +2565,83 @@ }, }); } - } else { - wx.showToast({ - title: "璇ヤ功涓嶈兘鐢宠绾歌川鏍蜂功", - icon: "none", - duration: 1000, - }); + if ( + this.data.bookDetail.isApplyBook == 3 || + this.data.bookDetail.isApplyBook == 4 + ) { + let role = this.data.userInfo != null ? this.data.userInfo.role : null; + if (role && role == "Teacher") { + // 鐐瑰嚮閫変腑 + if (this.data.paperBookCount == 0) { + wx.showToast({ + title: "鎮ㄧ殑绾歌川鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", + icon: "none", + duration: 1000, + }); + return false; + } + let isApply = this.data.alreadyPaperBookList.find( + (pitem) => pitem.content[0].id == this.data.bookDetail.id + ); + if (isApply) { + wx.showToast({ + title: "璇ヤ功宸茬敵璇凤紒", + icon: "none", + duration: 1000, + }); + return false; + } + + let isHas = this.data.paperBookList.find( + (pitem) => pitem.id == this.data.bookDetail.id + ); + if (isHas) { + wx.showToast({ + title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", + icon: "none", + duration: 1000, + }); + return false; + } + if (this.data.paperBookList.length >= 2) { + wx.showToast({ + title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", + icon: "none", + duration: 1000, + }); + return false; + } + this.addBookFun(this.data.bookDetail, "pBook"); + } else { + wx.showModal({ + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� + confirmColor: "#ff6c00", + cancelColor: "#949494", + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: "/packageDomain/pages/teacherCertification/index", + }); + } else if (res.cancel) {} + }, + }); + } + } else { + wx.showToast({ + title: "璇ヤ功涓嶈兘鐢宠绾歌川鏍蜂功", + icon: "none", + duration: 1000, + }); + } } + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + applyFun() + } else { + this.logInFun(() => {}) + } + }, // 娣诲姞鏍蜂功 addBookFun(item, type) { @@ -2584,9 +2685,14 @@ //鍘绘牱涔︾敵璇峰崟 goApply() { - wx.navigateTo({ - url: "/packageDomain/pages/sampleBookList/applicationForm/index", - }); + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + wx.navigateTo({ + url: "/packageDomain/pages/sampleBookList/applicationForm/index", + }); + } else { + this.logInFun(() => {}) + } }, handleTree() { // const child = this.selectComponent('#teach-tree') @@ -2667,15 +2773,26 @@ return childrenList }, uploadFile(e) { - const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey)) - if (userInfo.role != 'Teacher') return wx.showToast({ - icon: 'error', - title: '璇峰厛杩涜鏁欏笀璁よ瘉', - }) - this.setData({ - dialogBox: true, - isShowUp: true - }); + const uploadFun = () => { + const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey)) + if (userInfo.role != 'Teacher') return wx.showToast({ + icon: 'error', + title: '璇峰厛杩涜鏁欏笀璁よ瘉', + }) + this.setData({ + dialogBox: true, + isShowUp: true + }); + } + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + uploadFun() + } else { + this.logInFun(() => { + uploadFun() + }) + } + }, closeDialog() { this.setData({ -- Gitblit v1.9.1