From 02eb8d0829a78a30bdb6ce25f93858dfdd61c4dc Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期六, 07 九月 2024 19:06:14 +0800 Subject: [PATCH] bug --- packageBookService/pages/bookServices/detail/index.js | 73 ++++++++++++++++++++++-------------- 1 files changed, 44 insertions(+), 29 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index bbc3420..e8b3f6f 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -1,6 +1,7 @@ // pages/bookServices/detail/index.js import Toast from "tdesign-miniprogram/toast"; import tool from "../../../../assets/js/toolClass"; +import moment from 'moment' import { loginInfo } from "../../../../assets/js/login"; @@ -11,6 +12,9 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { + // 杩涢〉闈㈤粯璁ゅ垏鎹� 灞曞紑鐨刬d + // defaultactiveTeachid 鏁欏璧勬簮 + // defaultactiveLearnid 浜戝涔� bookId: "", barHeight: "", navBarHeight: "", @@ -189,20 +193,24 @@ bookId: options.id + "", barHeight: systInfo.statusBarHeight, navBarHeight: navBarHeight, - }); - this.setData({ options: { id: options.id, - name: options.name, + name: decodeURI(options.name), storeInfo: options.storeInfo, }, }); wx.setNavigationBarTitle({ - title: options.name, + 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(); // 鑾峰彇璧勬簮鎵�灞炲垎绫� - const token = wx.getStorageSync(app.config.tokenKey); + token = wx.getStorageSync(app.config.tokenKey) if (token) { this.getShoppingCartProductGet(); this.getApplyInfo(options.id); @@ -216,6 +224,15 @@ // 鑾峰彇鐢宠娆℃暟 this.getSelectPaperBookCount(); this.getSelectBookCount(); + } + if (options.tabValue) { + this.setData({ + tabValue: options.tabValue, + }); + const checkData = this.data.cmsDatas.find( + (item) => item.refCode == options.tabValue + ); + this.getResourceDataList(checkData) } }, @@ -462,9 +479,7 @@ } } this.setData({ - "bookDetail.publicationDate": this.formatDate( - this.data.bookDetail.publicationDate - ), + "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( @@ -700,7 +715,7 @@ link } = e.currentTarget.dataset; wx.navigateTo({ - url: `/packageBookService/pages/bookServices/webpage/index?url=${link}`, + url: `/packageBookService/pages/bookServices/linkPage/index?path=${link}`, }); }, // tag鍒囨崲 @@ -716,7 +731,7 @@ e.detail.label == "浜戞祴璇�" ) { const checkData = this.data.cmsDatas.find( - (item) => item.refCode == e.detail.value + (item) => item.refCode == this.data.tabValue ); if (!this.data.resourceClassList.length) this.getResourceClass() if (checkData) { @@ -819,7 +834,7 @@ }, // 鎵佸钩鍖栨暟鎹浆鎹ree - getTreeList(rootList, pathLength, newArr, path, addNum) { + getTreeList(rootList, pathLength, newArr, path) { for (const item of rootList) { // 姝ゅ鍘熸湰 item.productLinkPath.length == pathLength 浣� productLinkPath 闀垮害涓埆涔﹀瓨鍦�4銆�5浣嶄氦閿� if ((pathLength - item.productLinkPath.length >= 0 && pathLength - item.productLinkPath.length <= 3) && item.productLinkPath.includes(path)) { @@ -837,7 +852,7 @@ } // newArr.push(item) // 鍦ㄦ彃鍏ヨ繃绋嬩腑瀵规暟鎹繘琛屾帓搴� - newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item, addNum) + newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item) // 鎻掕繘鏁扮粍鍚� 浠庡師鏁版嵁涓垹闄� rootList = rootList.filter(nitem => nitem.id != item.id) } @@ -847,7 +862,7 @@ for (const i of newArr) { i.children = [] let addnum1 = i.productLinkPath.length - path.length == 6 ? 6 : 7 - this.getTreeList(rootList, pathLength + addnum1, i.children, i.productLinkPath, addnum1) + this.getTreeList(rootList, pathLength + addnum1, i.children, i.productLinkPath) if (i.children.length == 0) { delete i.children } @@ -872,9 +887,9 @@ }, // 鎺掑簭鏁扮粍 鎸夌収productLinkPath - insertAndSortObjectsByProductLinkPath(array, newObj, addNum) { + insertAndSortObjectsByProductLinkPath(array, newObj) { // 鏌ユ壘鏂板璞″簲璇ユ彃鍏ョ殑浣嶇疆 - let insertIndex = array.findIndex(obj => Number(newObj.productLinkPath.substring(newObj.productLinkPath.length - addNum, newObj.productLinkPath.length)) < Number(obj.productLinkPath.substring(obj.productLinkPath.length - addNum, obj.productLinkPath.length))); + let insertIndex = array.findIndex(obj => Number(newObj.productLinkPath.substring(newObj.productLinkPath.lastIndexOf('\\') + 1, newObj.productLinkPath.length)) < Number(obj.productLinkPath.substring(obj.productLinkPath.lastIndexOf('\\') + 1, obj.productLinkPath.length))); // 濡傛灉娌℃湁鎵惧埌鍚堥�傜殑浣嶇疆锛屽垯鏀惧湪鏁扮粍鏈熬 if (insertIndex === -1) { insertIndex = array.length; @@ -884,10 +899,10 @@ // 娴嬭瘯6 姝e紡5 // 瀵规暟缁勮繘琛屾帓搴� array.sort((a, b) => { - if (Number(a.productLinkPath.substring(a.productLinkPath.length - addNum, a.productLinkPath.length)) < Number(b.productLinkPath.substring(b.productLinkPath.length - addNum, b.productLinkPath.length))) { + if (Number(a.productLinkPath.substring(a.productLinkPath.lastIndexOf('\\') + 1, a.productLinkPath.length)) < Number(b.productLinkPath.substring(b.productLinkPath.lastIndexOf('\\') + 1, b.productLinkPath.length))) { return -1; } - if (Number(a.productLinkPath.substring(a.productLinkPath.length - addNum, a.productLinkPath.length)) > Number(b.productLinkPath.substring(b.productLinkPath.length - addNum, b.productLinkPath.length))) { + if (Number(a.productLinkPath.substring(a.productLinkPath.lastIndexOf('\\') + 1, a.productLinkPath.length)) > Number(b.productLinkPath.substring(b.productLinkPath.lastIndexOf('\\') + 1, b.productLinkPath.length))) { return 1; } // a must be equal to b @@ -985,19 +1000,17 @@ }) } } - const addNum = query.cmsPath.length > 10 ? 7 : query.cmsPath.length > 14 ? 8 : 6 + const addNum = query.cmsPath.length > 10 ? 7 : query.cmsPath.length > 13 ? 8 : 6 const num = query.cmsPath.length + addNum - this.getTreeList(res.datas.cmsDatas[0].datas, num, list, '\\', addNum) + this.getTreeList(res.datas.cmsDatas[0].datas, num, list, '\\') list = this.ensureTreeConsistency(list) list = this.changeResourceChildren(list) - console.log('淇敼鍚�', list); let result = []; if (type.refCode == "jsek_teachingResources") { this.findChildIds(list, result); - const newUSeList = this.deleteTreeData(list, result) - console.log('鏍戝墧闄�', result, newUSeList); - console.log('鏍戝姞涓�', this.increaseTreeData(list, newUSeList, 16094)); - + // const newUSeList = this.deleteTreeData(list, result) + // console.log('鏍戝墧闄�', result, newUSeList); + // console.log('鏍戝姞涓�', this.increaseTreeData(list, newUSeList, 16094)); this.setData({ openTeachids: result, loading: false, @@ -1101,9 +1114,9 @@ let list = [] // 娴嬭瘯 6浣�// 姝e紡 5浣�// 娴嬭瘯璋冪敤浼�20锛屽唴閮�7 姝e紡璋冪敤浼�17 鍐呴儴浼�6 - const addNum = query.cmsPath.length > 10 ? 7 : query.cmsPath.length > 14 ? 8 : 6 + const addNum = query.cmsPath.length > 10 ? 7 : query.cmsPath.length > 13 ? 8 : 6 const num = query.cmsPath.length + addNum - that.getTreeList(data, num, list, '\\', addNum) + that.getTreeList(data, num, list, '\\') list = that.ensureTreeConsistency(list) that.findChildIds(list[0].children, result); that.setData({ @@ -2524,9 +2537,11 @@ let resultList = [] for (let index = 0; index < list.length; index++) { const item = list[index]; - for (let cindex = 0; cindex < item.children.length; cindex++) { - const citem = item.children[cindex]; - citem.children = [] + if (item.children.length > 0) { + for (let cindex = 0; cindex < item.children.length; cindex++) { + const citem = item.children[cindex]; + citem.children = [] + } } resultList.push(item) } -- Gitblit v1.9.1