From 2ee8ddb1ecac7df4198e54e08ec7f22daf4b07c0 Mon Sep 17 00:00:00 2001 From: QYF-GitLab1 <1940665526@qq.com> Date: 星期五, 03 一月 2025 16:57:38 +0800 Subject: [PATCH] 111 --- packageBookService/pages/bookServices/detail/index.js | 208 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 189 insertions(+), 19 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index 44051f6..6eae7bd 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -7,6 +7,7 @@ } from "../../../../assets/js/login"; import FormData from '../../../../utils/formdata/index.js'; const app = getApp(); +var pastData = require('../../psychologyAnswer/testdata/index') Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� @@ -50,10 +51,12 @@ resourceClassList: [], // 璧勬簮鎵�灞炲垎绫� applyState: "", // 鏁欏璧勬簮鐢宠鐘舵�� deadline: "", // 鏁欏璧勬簮鐢宠鏈夋晥鏃ユ湡, + isShowBuyCloundBtn: false, isshowDrawBtn: true, // 浜戝涔犻鍙栨煡鐪嬫寜閽槸鍚︽樉绀� isShowBuyCloundMenu: false, // 浜戝涔犲叏閮ㄨ喘涔版寜閽槸鍚︽樉绀� isCloundHaveSaleMethod: false, // 浜戝涔犳槸鍚︽湁閿�鍞柟寮� cloundMenuIsBuy: false, + learnTaskData: {}, rejectCause: "", // 涓嬭浇鎷掔粷鍘熷洜 buyIdList: [], shoppingCartGetId: [], // 宸茶喘涔癷d鍒楄〃 @@ -72,6 +75,9 @@ residue: 0, // 缁勫嵎鍓╀綑娆℃暟 mockList: [], // 鐢ㄦ埛缁勫嵎鎻愪氦淇℃伅 }, + isBuyBank: false, // 棰樺簱鏄惁璐拱 + isShoppingBank: false, // 棰樺簱鏄惁鍔犲叆璐墿杞� + bankSaleData: null, relatedBookLoading: false, noRelatedBookData: false, relatedBookPath: "", // 鐩稿叧鍥句功path @@ -206,7 +212,10 @@ fileList: [], isShowUp: true, protocolShow: false, - protocolTxt: '' + protocolTxt: '', + learnMenu: null, + md5List: [], + editDialog: false }, resetTree: function (e) { @@ -263,15 +272,13 @@ this.setData({ tabValue: options.tabValue, }); - - } }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ - onShow() { + onShow(options) { if (wx.getStorageSync("paperBookList")) { this.setData({ paperBookList: JSON.parse(wx.getStorageSync("paperBookList")), @@ -285,6 +292,9 @@ this.setData({ num: Number(this.data.paperBookList.length) + Number(this.data.electronicBookList.length), }); + if (this.data.bookDetail.id) { + this.getBookInfo(this.data.bookDetail.id) + } }, /** @@ -422,10 +432,14 @@ protectedEpub: [], probationPage: [], //pdf璇曡椤垫暟 freeEpubPage: [], //epub璇曡鐧惧垎姣� + bookEditor: [], //鍥句功缂栬緫 + contactInformation: [], //鑱旂郴鏂瑰紡 }, }; app.MG.store.getProductDetail(query).then(async (res) => { this.getResourceCode(id, res.datas.rootCmsItemId) + 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, @@ -459,6 +473,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( @@ -497,13 +521,12 @@ } } this.setData({ - "bookDetail.publicationDate": moment(this.data.bookDetail.publicationDate).format("YYYY骞碝M鏈�"), + "bookDetail.publicationDate": this.data.bookDetail.publicationDate ? moment(this.data.bookDetail.publicationDate).format("YYYY骞碝M鏈�") : '', "bookDetail.price": this.numFormat(this.data.bookDetail.price), "bookDetail.oldPrice": this.numFormat(this.data.bookDetail.oldPrice), "bookDetail.paperPrice": this.numFormat( this.data.bookDetail.paperPrice ), - }); }); }, @@ -522,10 +545,30 @@ } } app.MG.store.getProductDetail(query).then((res) => { + let isBuyBank = true + let isShoppingBank = true + let bankSaleData = null + // 鍒ゆ柇棰樺簱鏄惁鏁翠綋璐拱 + const bank = res.datas.cmsDatas[0].datas.find((item) => item.refCode == 'questionBank') + if (bank) { + if (bank.saleMethod.length) { + 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) + } + } + } this.setData({ resourceCodeList: res.datas.cmsDatas[0].datas, + learnTaskData: res.datas.cmsDatas[0].datas.filter((item) => item.refCode == 'jsek_learningTasks')[0], + isBuyBank, + isShoppingBank, + bankSaleData }) - console.log('refcode', this.data.resourceCodeList); + if (res.datas.cmsDatas[0].datas.length) this.setData({ + learnMenu: res.datas.cmsDatas[0].datas.find(item => item.refCode == 'jsek_cloudLearning') + }) }) }, //璇锋眰瀛愬晢鍝佺殑鏂囦欢 @@ -716,6 +759,14 @@ } } }, + + // 鑱旂郴 + editPhone() { + this.setData({ + editDialog: true + }) + }, + // 鎴戣寤鸿 suggestBtn() { // 妫�鏌ョ櫥褰曠姸鎬� @@ -869,7 +920,7 @@ } // newArr.push(item) // 鍦ㄦ彃鍏ヨ繃绋嬩腑瀵规暟鎹繘琛屾帓搴� - newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item) + newArr = this.insertAndSortObjectsById(newArr, item) // 鎻掕繘鏁扮粍鍚� 浠庡師鏁版嵁涓垹闄� rootList = rootList.filter(nitem => nitem.id != item.id) } @@ -901,8 +952,8 @@ return tree }, - // 鎺掑簭鏁扮粍 鎸夌収productLinkPath - insertAndSortObjectsByProductLinkPath(array, newObj) { + // 鎺掑簭鏁扮粍 鎸夌収id + insertAndSortObjectsById(array, newObj) { // 鏌ユ壘鏂板璞″簲璇ユ彃鍏ョ殑浣嶇疆 let insertIndex = array.findIndex(obj => newObj.id < obj.id); // 濡傛灉娌℃湁鎵惧埌鍚堥�傜殑浣嶇疆锛屽垯鏀惧湪鏁扮粍鏈熬 @@ -949,7 +1000,6 @@ let query = { path: '*', queryType: '*', - // storeInfo: this.data.options.storeInfo, productId: this.data.bookDetail.id, cmsPath: type.productLinkPath, cmsType: '*', @@ -962,10 +1012,9 @@ file: [], protectedFile: [], resourcesClassification: [], - isDownload: [], + // isDownload: [], jsek_resourceBrief: [], jsek_link: [], - jsek_questionBank: [] }, pading: { start: 0, @@ -973,13 +1022,13 @@ }, } app.MG.store.getProductDetailNoChildren(query).then((res) => { - console.log('鏈鐞嗚祫婧�', res.datas.cmsDatas[0].datas); - if (!res.datas.cmsDatas[0].datas.length) { + if (!res.datas.cmsDatas[0].datas.length || res.datas.cmsDatas[0].datas.length == 0) { return this.setData({ noResources: true, loading: false, }); } + let list = [] // 鍒ゆ柇浜戝涔犳湁鏃犻攢鍞柟寮忓拰鏈夋晥鏈� const cloundSaleMethod = @@ -991,8 +1040,19 @@ cloundSaleMethod && new Date().getTime() <= new Date(cloundSaleMethod.EndDate).getTime() && new Date().getTime() >= new Date(cloundSaleMethod.BeginDate).getTime() + let md5s = [] 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) + } + this.setData({ + md5List: md5s, + }); + } if (flags) item.saleMethod = [] item.checked = false; if (item.sysType == 'CmsItem') { @@ -1041,7 +1101,9 @@ new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() ) || (flags && cloundSaleMethod.Price == 0) // 鍒ゆ柇浜戝涔犲叏閮ㄨ喘涔版寜閽槸鍚︽樉绀� - let isShowBuyCloundMenu = flags && cloundSaleMethod.Price >= 0 + 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) // 鍒ゆ柇璐墿杞︽寜閽拰閿佹寜閽槸鍚︽樉绀� this.handleTreeData(list).forEach(item => { item.isbuy = this.resourceIsBuy(item); @@ -1051,6 +1113,7 @@ this.setData({ isshowDrawBtn, isShowBuyCloundMenu, + isShowBuyCloundBtn, isCloundHaveSaleMethod: flags, learn: list, loading: false, @@ -1123,17 +1186,22 @@ } } else { if (isTSFW.length > 0) { - data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.childrenFolderCount > 0) + 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 !== '鍗曢�夐') that.setData({ jslx: false, }); } else { data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder') + // && item.refCode != 'jsek_interaction' that.setData({ jslx: true, }); } if (data.length > 0) { + console.log('data', data); let list = [] that.getTreeList(data, list, query.cmsPath) list = that.ensureTreeConsistency(list) @@ -1143,6 +1211,20 @@ loading: false, openTeachids: result, }); + //Json璧嬪�� + // const bookId = that.data.bookId + // if (bookId == 6619) { + // const jsonData = {} + // jsonData.name = "蹇冪悊娴嬭瘎" + // jsonData.children = [...pastData.postData.list] + // var test = that.data.test; + // test.push(jsonData); + // that.setData({ + // test: test, + // }); + // console.log(that.data.test, "鏁欏浜掑姩"); + // } + } else { that.setData({ noResources: true, @@ -1836,6 +1918,31 @@ }); } }, + // 浜戝涔犲叏閮ㄨ喘涔� + async buyCloudLearnClass() { + 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: "璇烽噸璇�", + }); + } + }, // 浜戝涔犲瓧娈佃喘涔� async buyCloundMenu() { const cloundData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning') @@ -1861,6 +1968,59 @@ }, handleTrue() { // findAndUpdateItemsByIds(this.date.) + }, + + // 棰樺簱璐拱 + async buyBank() { + let query = { + remarks: '浜戞祴璇�', + requests: [{ + saleMethodId: this.data.bankSaleData.Id, + count: 1 + }] + } + const initOrderRes = await app.MG.store.initOrder(query) + if (this.data.bankSaleData.Price) { + // 璐拱 + const url = "/pages/cart/paymentPage/index?orderNumber=" + initOrderRes.orderNumber + '&onNorderSaleMethod=' + initOrderRes.saleMethodLinks[0].orderSaleMethod.id; + wx.navigateTo({ + url, + }); + } else { + // 鍏嶈垂棰嗗彇 + app.MG.store + .confirmOrder({ + orderNum: initOrderRes.orderNumber, + }) + .then((res) => { + if (res) { + wx.showToast({ + title: "棰嗗彇鎴愬姛", + icon: "none", + duration: 1000, + }); + this.getBookInfo(this.data.bookDetail.id); + } + }); + } + }, + // 棰樺簱鍔犲叆璐墿杞� + 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) { @@ -2544,6 +2704,11 @@ 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 @@ -2773,7 +2938,7 @@ app.MG.ugc.newTopicMessage(query).then((res) => { wx.showToast({ icon: "success", - title: "璇蜂笂浼犺祫婧愭枃浠�", + title: "涓婁紶鎴愬姛", }); this.closeDialog() }) @@ -2788,5 +2953,10 @@ this.setData({ cloundMenuIsBuy: flag }) - } + }, + /** + * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� + */ + onShareAppMessage() {}, + onShareTimeline() {} }) \ No newline at end of file -- Gitblit v1.9.1