From 75a9abca4f4cf0ebe579705abc369489cfe20e7c Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期五, 28 六月 2024 11:16:37 +0800 Subject: [PATCH] 小程序,课程 --- packageBookService/pages/bookServices/detail/index.js | 101 +++++++++++++++++++++++++++++--------------------- 1 files changed, 59 insertions(+), 42 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index 57f03e7..e500b90 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -992,31 +992,45 @@ app.MG.store .getProductDetail(query) .then(async (res) => { - if (!res.datas.cmsDatas[0].datas.length) { - return this.setData({ - noResources: true, - loading: false, - }); - } // 浜戞祴璇曪紝閫掑綊璇锋眰閲屽眰鏁版嵁 if (type.refCode == "questionBank") { - const data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.childrenFolderCount > 0); - if (data.length > 0) { - let list = [] - console.log(query.cmsPath, query.cmsPath.length) - // 娴嬭瘯 6浣�// 姝e紡 5浣�// 娴嬭瘯璋冪敤浼�20锛屽唴閮�7 姝e紡璋冪敤浼�17 鍐呴儴浼�6 - const addNum = query.cmsPath.length > 12 ? 7 : query.cmsPath.length > 14 ? 8 : 6 - const num = query.cmsPath.length + addNum - this.getTreeList(data, num, list, '\\', addNum) - list = this.ensureTreeConsistency(list) - let result = []; - this.findChildIds(list[0].children, result); - this.setData({ - test: list[0].children, - loading: false, - openTeachids: result, - }); - console.log(this.data.test, "test") + let data = [] + let result = []; + if (this.data.options.storeInfo == 'jsek_jslx') { + data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder'); + if (data.length > 0) { + this.setData({ + test: data, + loading: false, + openTeachids: result, + }); + } else { + this.setData({ + noResources: true, + loading: false, + }); + } + } else { + data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.childrenFolderCount > 0); + if (data.length > 0) { + let list = [] + // 娴嬭瘯 6浣�// 姝e紡 5浣�// 娴嬭瘯璋冪敤浼�20锛屽唴閮�7 姝e紡璋冪敤浼�17 鍐呴儴浼�6 + const addNum = query.cmsPath.length > 12 ? 7 : query.cmsPath.length > 14 ? 8 : 6 + const num = query.cmsPath.length + addNum + this.getTreeList(data, num, list, '\\', addNum) + list = this.ensureTreeConsistency(list) + this.findChildIds(list[0].children, result); + this.setData({ + test: list[0].children, + loading: false, + openTeachids: result, + }); + } else { + this.setData({ + noResources: true, + loading: false, + }); + } } } }) @@ -1112,30 +1126,33 @@ // 鑾峰彇灞曞紑椤� findChildIds(data, result) { let index = 0 - for (let i = 0; i < data.length; i++) { - if (index < 3) { - const item = data[i] - if (item.childrenFolderCount > 0) { - result.push(item.id) - for (let j = 0; j < item.children.length; j++) { - if (index < 3) { - const childrenItme = item.children[j] - if (item.childrenCount > 0) { - result.push(childrenItme.id) - index += 1 + if (data) + for (let i = 0; i < data.length; i++) { + if (index < 3) { + const item = data[i] + if (item.childrenFolderCount > 0) { + result.push(item.id) + if (item.children) { + for (let j = 0; j < item.children.length; j++) { + if (index < 3) { + const childrenItme = item.children[j] + if (item.childrenCount > 0) { + result.push(childrenItme.id) + index += 1 + } + } else { + break + } } - } else { - break } + } else if (item.childrenCount > 0) { + result.push(item.id) + index += 1 } - } else if (item.childrenCount > 0) { - result.push(item.id) - index += 1 + } else { + break } - } else { - break } - } }, // 鍥句功娣诲姞璐墿杞� -- Gitblit v1.9.1