From 6d8464c9524c1c8550450615bc9c47fb298d424d Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期三, 03 四月 2024 09:51:03 +0800 Subject: [PATCH] 图书详情页、答题器bug修改 --- packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml | 8 packageBookService/pages/bookServices/examination/questionList/index.wxml | 2 static/images/bookService/detail/link.png | 0 packageBookService/pages/bookServices/detail/buyResource/index.js | 434 ++-- packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxml | 8 packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxss | 1 packageBookService/pages/bookServices/detail/index.json | 1 packageBookService/pages/bookServices/detail/index.wxml | 267 ++ packageBookService/pages/bookServices/examination/questionOptions/index.wxss | 18 packageBookService/pages/bookServices/examination/questionOptions/index.wxml | 22 packageBookService/pages/bookServices/detail/components/tree/index.wxml | 4 packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js | 3 packageBookService/pages/bookServices/examination/examination.js | 1994 ++++++++++++++----------- packageBookService/pages/bookServices/detail/components/relatedBooks/index.json | 4 packageBookService/pages/bookServices/detail/components/tree/index.js | 357 ++-- static/images/bookService/detail/link-click.png | 0 packageBookService/pages/bookServices/detail/buyResource/index.wxml | 26 packageBookService/pages/bookServices/detail/index.js | 1499 ++++++++++-------- packageBookService/pages/bookServices/detail/components/relatedBooks/index.js | 22 packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml | 4 20 files changed, 2,684 insertions(+), 1,990 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/buyResource/index.js b/packageBookService/pages/bookServices/detail/buyResource/index.js index 07134d2..7395880 100644 --- a/packageBookService/pages/bookServices/detail/buyResource/index.js +++ b/packageBookService/pages/bookServices/detail/buyResource/index.js @@ -1,111 +1,102 @@ // packageBookService/pages/bookServices/detail/buyResource/index.js -const app = getApp() +const app = getApp(); Page({ - /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - barHeight: '', - navBarHeight: '', + barHeight: "", + navBarHeight: "", learn: [], openLearnids: [], - bookId: '', + bookId: "", loading: false, shoppingList: [], shoppingCartGetId: [], methodId: [], paymentPage: false, - superior: false + superior: false, + checkAllState: false, }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { - const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 - const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� + const navBarHeight = + (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� this.setData({ barHeight: systInfo.statusBarHeight, navBarHeight: navBarHeight, - bookId: options.bookId + bookId: options.bookId, }); - this.getResourceClass() + this.getResourceClass(); console.log(options); this.getResourceData({ productLinkPath: options.productLinkPath, - refCode: options.refCode - }) - this.getShoppingCartProductGet() - this.getBookInfo(options.bookId) + refCode: options.refCode, + }); + this.getShoppingCartProductGet(); + this.getBookInfo(options.bookId); }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 */ - onReady() { - - }, + onReady() {}, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ - onShow() { - - }, + onShow() {}, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 */ - onHide() { - - }, + onHide() {}, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 */ - onUnload() { - - }, + onUnload() {}, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ - onPullDownRefresh() { - - }, + onPullDownRefresh() {}, /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ - onReachBottom() { - - }, + onReachBottom() {}, /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ - onShareAppMessage() { - + onShareAppMessage() {}, + changeCheckAll(e) { + this.setData({ + checkAllState: e.detail.value, + }); }, goBack() { - wx.navigateBack() + wx.navigateBack(); }, // 鑾峰彇鏁欏璧勬簮 浜戝涔� 浜戞祴璇� getResourceData(type) { this.setData({ loading: true, - noResources: false - }) + noResources: false, + }); let query = { - path: '*', - queryType: '*', + path: "*", + queryType: "*", productId: this.data.bookId, cmsPath: type.productLinkPath, itemFields: { - SysType: 'CmsFolder', + SysType: "CmsFolder", // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁� selectType: [], freeFile: [], @@ -114,88 +105,90 @@ isDownload: [], jsek_resourceBrief: [], jsek_link: [], - jsek_questionBank: [] + jsek_questionBank: [], }, pading: { start: 0, - size: 999 + size: 999, }, - } + }; app.MG.store .getProductDetail(query) .then(async (res) => { if (!res.datas.cmsDatas[0].datas.length) { return this.setData({ noResources: true, - loading: false - }) + loading: false, + }); } //鏁欏璧勬簮 浜戝涔� - if (type.refCode == 'jsek_teachingResources' || type.refCode == 'jsek_cloudLearning') { + if ( + type.refCode == "jsek_teachingResources" || + type.refCode == "jsek_cloudLearning" + ) { if (res.datas.cmsDatas[0].datas.length > 0) { - res.datas.cmsDatas[0].datas.forEach(item => { - item.checked = false, - item.checkAll = true - }) - const list = await this.getAllResource(res.datas.cmsDatas[0].datas) - if (type.refCode == 'jsek_teachingResources') { + res.datas.cmsDatas[0].datas.forEach((item) => { + (item.checked = false), (item.checkAll = true); + }); + const list = await this.getAllResource(res.datas.cmsDatas[0].datas); + if (type.refCode == "jsek_teachingResources") { this.setData({ teach: list, - loading: false - }) - this.findChildIds(this.data.teach, this.data.openTeachids = []) - } else if (type.refCode == 'jsek_cloudLearning') { - const result = [] - res.datas.cmsDatas[0].datas.forEach(item => { - item.checked = false - }) - this.findChildIds(list, result) + loading: false, + }); + this.findChildIds(this.data.teach, (this.data.openTeachids = [])); + } else if (type.refCode == "jsek_cloudLearning") { + const result = []; + res.datas.cmsDatas[0].datas.forEach((item) => { + item.checked = false; + }); + this.findChildIds(list, result); this.setData({ learn: list, loading: false, - openLearnids: result - }) - console.log('鏁欏璧勬簮', list); + openLearnids: result, + }); + console.log("鏁欏璧勬簮", list); } } else { // 鏃犳暟鎹� } - } else if (type.refCode == 'jsek_questionBank') { + } else if (type.refCode == "jsek_questionBank") { // const list = await this.getAllResource(res.datas.cmsDatas[0].datas) this.setData({ test: res.datas.cmsDatas[0].datas, - loading: false - }) + loading: false, + }); } else { - console.log('鍏朵粬'); + console.log("鍏朵粬"); } }) .catch((e) => { - console.log(e) - }) + console.log(e); + }); }, // 鑾峰彇tag涓嬫墍鏈夎祫婧� async getAllResource(data) { - if (!data.length) return false + if (!data.length) return false; for (let i = 0; i < data.length; i++) { - let item = data[i] - if (item.sysType == 'CmsFolder' && item.childrenCount > 0) { - item.children = [] - item.children = await this.getFolderItem(item.productLinkPath) - await this.getAllResource(item.children) + let item = data[i]; + if (item.sysType == "CmsFolder" && item.childrenCount > 0) { + item.children = []; + item.children = await this.getFolderItem(item.productLinkPath); + await this.getAllResource(item.children); } } - return data + return data; }, // 鑾峰彇璧勬簮鎺ュ彛 async getFolderItem(path) { let query = { - path: '*', - queryType: '*', + path: "*", + queryType: "*", productId: this.data.bookId, cmsPath: path, itemFields: { - SysType: 'CmsFolder', + SysType: "CmsFolder", // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁� selectType: [], freeFile: [], @@ -205,52 +198,54 @@ isDownload: [], jsek_resourceBrief: [], jsek_link: [], - accessType: [] + accessType: [], }, pading: { start: 0, - size: 999 + size: 999, }, - } - const data = await app.MG.store.getProductDetail(query) + }; + const data = await app.MG.store.getProductDetail(query); data.datas.cmsDatas[0].datas.forEach((item) => { this.data.resourceClassList.forEach((type) => { - if (type.value == item.resourcesClassification) item.resourceClass = type.name - }) + if (type.value == item.resourcesClassification) + item.resourceClass = type.name; + }); // 缃戦〉 涓嶈兘涓嬭浇 绉佹湁鏂囦欢 - if (item.sysType == 'CmsItem') { - if (item.selectType == 'webpage') { - item.disabled = true + if (item.sysType == "CmsItem") { + if (item.selectType == "webpage") { + item.disabled = true; } else { if (item.isDownload != 1) { - item.disabled = true + item.disabled = true; } } if (item.file) { - if (item.fileMap[item.file].protectType == 'Private') item.disabled = true + if (item.fileMap[item.file].protectType == "Private") + item.disabled = true; } } - }) - data.datas.cmsDatas[0].datas.forEach(item => { - item.checked = false - item.isbuy = this.resourceIsBuy(item) - item.isShopCar = this.isShoppingCart(item) - }) - return data.datas.cmsDatas[0].datas + }); + data.datas.cmsDatas[0].datas.forEach((item) => { + item.checked = false; + item.isbuy = this.resourceIsBuy(item); + item.isShopCar = this.isShoppingCart(item); + }); + return data.datas.cmsDatas[0].datas; }, getBookInfo(id) { this.setData({ "mockData'.id": 0, "mockData.price": 0, - "mockData.count": 0 - }) + "mockData.count": 0, + }); const query = { - path: '*', - queryType: '*', + path: "*", + queryType: "*", productId: id, - favoriteTypes: 'FavoriteBookCity', + favoriteTypes: "FavoriteBookCity", itemFields: { - 'SysType=': 'CmsFolder', + "SysType=": "CmsFolder", }, coverSize: { height: 300, @@ -279,10 +274,9 @@ app.MG.store.getProductDetail(query).then(async (res) => { this.setData({ bookDetail: res.datas, - buyIdList: res.datas.purchasedSaleMethodIdList + buyIdList: res.datas.purchasedSaleMethodIdList, }); }); - }, // 鑾峰彇宸茶喘涔板晢鍝� getShoppingCartProductGet() { @@ -290,181 +284,193 @@ start: 0, size: 999, filterList: [], - searchList: [] - } + searchList: [], + }; app.MG.store.getShoppingCartProductList(query).then((res) => { - const list = [] + const list = []; res.datas.forEach((item) => { - list.push(item.saleMethod.id) - }) + list.push(item.saleMethod.id); + }); this.setData({ shoppingList: res.datas, - shoppingCartGetId: list - }) - }) + shoppingCartGetId: list, + }); + }); }, // 鍒ゆ柇璧勬簮鏄惁璐拱 resourceIsBuy(data) { if (data.saleMethod && data.saleMethod.length) { - const isSHow = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id) - return !isSHow + const isSHow = this.data.buyIdList.some( + (item) => item == data.saleMethod[0].Id + ); + return !isSHow; } else { - return false + return false; } }, // 鍒ゆ柇璧勬簮鍔犲叆璐墿杞︽寜閽槸鍚︽樉绀� isShoppingCart(data) { if (data.saleMethod && data.saleMethod.length) { - if (data.saleMethod[0].Price <= 0) return false + if (data.saleMethod[0].Price <= 0) return false; // 鍐嶅垽鏂槸鍚﹁喘涔� - const isBuy = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id) + const isBuy = this.data.buyIdList.some( + (item) => item == data.saleMethod[0].Id + ); if (isBuy) { // 璐拱浜� - return false + return false; } else { // 鍒ゆ柇鏄惁鍔犲叆璐墿杞� - const isSHow = this.data.shoppingCartGetId.some((item) => item == data.saleMethod[0].Id) - return !isSHow + const isSHow = this.data.shoppingCartGetId.some( + (item) => item == data.saleMethod[0].Id + ); + return !isSHow; } } else { - return false + return false; } }, // 鑾峰彇灞曞紑椤� findChildIds(data, result) { - let index = 0 + let index = 0; for (let i = 0; i < data.length; i++) { if (index < 3) { - const item = data[i] + const item = data[i]; if (item.children && item.children.length > 0) { - result.push(item.id) + result.push(item.id); for (let j = 0; j < item.children.length; j++) { if (index < 3) { - const childrenItme = item.children[j] + const childrenItme = item.children[j]; if (item.children && item.children.length > 0) { - result.push(childrenItme.id) - index += 1 + result.push(childrenItme.id); + index += 1; } } else { - break + break; } } } else if (item.children && item.children.length > 0) { - result.push(item.id) - index += 1 + result.push(item.id); + index += 1; } } else { - break + break; } } }, // 鑾峰彇璧勬簮鎵�灞炲垎绫� getResourceClass() { let query = { - refCodes: ['resourcesClassification'] - } + refCodes: ["resourcesClassification"], + }; app.MG.store.getProductTypeField(query).then((res) => { this.setData({ - resourceClassList: JSON.parse(res[0].config).option - }) - }) + resourceClassList: JSON.parse(res[0].config).option, + }); + }); }, checkAll() { - const child = this.selectComponent('#tree') - child.checkAll() - + const child = this.selectComponent("#tree"); + child.checkAll(); }, //璐拱鎸夐挳 batchPurchase() { + let saleMethodIds = []; + let requests = []; + let item = []; + let selectAllId = []; + const child = this.selectComponent("#tree"); - - - let saleMethodIds = [] - let requests = [] - 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.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 + item = child.data.superiorPurchaseSaleMethodId; + const sonItem = child.data.sonPurchaseSaleMethodId; + let selectAll = child.data.selectAll; if (selectAll) { // console.log(selectAll); - selectAll.forEach(item => { + selectAll.forEach((item) => { if (item.saleMethod != 0) { // console.log(item, 'item'); - selectAllId.push(item.saleMethod[0].Id) + selectAllId.push(item.saleMethod[0].Id); } - }) + }); console.log(selectAllId); - app.MG.store.initOrder({ - requests: selectAllId.map(id => ({ - saleMethodId: id, - count: 1, - })), - }).then(res => { - if (res) { - wx.navigateTo({ - url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber, - }) - selectAllId = [] - child.setData({ - selectAll: [] - }) - - } - }) + app.MG.store + .initOrder({ + requests: selectAllId.map((id) => ({ + saleMethodId: id, + count: 1, + })), + }) + .then((res) => { + if (res) { + wx.navigateTo({ + url: + "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, + }); + selectAllId = []; + child.setData({ + selectAll: [], + }); + } + }); } if (item) { - console.log(item, 'sadsdasd'); + console.log(item, "sadsdasd"); // 鎷垮埌id - item.forEach(items => { + item.forEach((items) => { if (items.saleMethod != 0) { - saleMethodIds.push(items.saleMethod[0].Id) + saleMethodIds.push(items.saleMethod[0].Id); } - }) - console.log(saleMethodIds, 'saleMethodIds'); + }); + console.log(saleMethodIds, "saleMethodIds"); - app.MG.store.initOrder({ - requests: saleMethodIds.map(id => ({ - saleMethodId: id, - count: 1, - })), - }).then(res => { - if (res) { - wx.navigateTo({ - url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber, - }) + app.MG.store + .initOrder({ + requests: saleMethodIds.map((id) => ({ + saleMethodId: id, + count: 1, + })), + }) + .then((res) => { + if (res) { + wx.navigateTo({ + url: + "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, + }); - child.setData({ - superiorPurchaseSaleMethodId: [] // 浣跨敤setData鏂规硶娓呯┖sonPurchaseSaleMethodId鏁版嵁 - }) - } - }) + child.setData({ + superiorPurchaseSaleMethodId: [], // 浣跨敤setData鏂规硶娓呯┖sonPurchaseSaleMethodId鏁版嵁 + }); + } + }); } if (item.length == 0 && sonItem) { - app.MG.store.initOrder({ - requests: sonItem.map(id => ({ - saleMethodId: id, - count: 1, - })), - }).then(res => { - if (res) { - wx.navigateTo({ - url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber, - }) - this.setData({ - paymentPage: true - }) - child.setData({ - sonPurchaseSaleMethodId: [] // 浣跨敤setData鏂规硶娓呯┖sonPurchaseSaleMethodId鏁版嵁 - }) - } - }) + app.MG.store + .initOrder({ + requests: sonItem.map((id) => ({ + saleMethodId: id, + count: 1, + })), + }) + .then((res) => { + if (res) { + wx.navigateTo({ + url: + "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, + }); + this.setData({ + paymentPage: true, + }); + child.setData({ + sonPurchaseSaleMethodId: [], // 浣跨敤setData鏂规硶娓呯┖sonPurchaseSaleMethodId鏁版嵁 + }); + } + }); } }, - -}) \ No newline at end of file +}); diff --git a/packageBookService/pages/bookServices/detail/buyResource/index.wxml b/packageBookService/pages/bookServices/detail/buyResource/index.wxml index 4c34e85..664b0c6 100644 --- a/packageBookService/pages/bookServices/detail/buyResource/index.wxml +++ b/packageBookService/pages/bookServices/detail/buyResource/index.wxml @@ -4,17 +4,31 @@ <view class="nacigationBar" style="width: 70%; height: {{navBarHeight}}px;"> <view class="flex"> <view> - <t-icon name="chevron-left" size="30" data-name="{{item}}" bind:click="goBack" /> + <t-icon + name="chevron-left" + size="30" + data-name="{{item}}" + bind:click="goBack" + /> </view> <view class="navbar-title">璧勬簮璐拱</view> </view> - <view bind:tap="checkAll"> 鍏ㄩ�� </view> + <view bind:tap="checkAll"> {{checkAllState ? '鍙栨秷' : '鍏ㄩ��'}} </view> </view> <!-- 鍐呭 --> <view class="buy-resource" wx:if="{{!loading}}"> - <tree id="tree" paymentPage="{{paymentPage}}" superior="{{superior}}" treeList="{{learn}}" tab="{{'jsek_cloudLearning'}}" isShowCheck="{{true}}" openIds="{{openLearnids}}" /> + <tree + id="tree" + paymentPage="{{paymentPage}}" + superior="{{superior}}" + treeList="{{learn}}" + tab="{{'jsek_cloudLearning'}}" + isShowCheck="{{true}}" + openIds="{{openLearnids}}" + bind:changeCheckAll="changeCheckAll" + /> </view> <view class="noData" wx:if="{{loading}}"> @@ -22,5 +36,7 @@ </view> <view class="page-bottom"> - <t-button theme="primary" size="large" class="btn-buy" bindtap="batchPurchase">鎵归噺璐拱</t-button> -</view> \ No newline at end of file + <t-button theme="primary" size="large" class="btn-buy" bindtap="batchPurchase" + >鎵归噺璐拱</t-button + > +</view> diff --git a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js index 9fbe534..259c5f3 100644 --- a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js +++ b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js @@ -9,6 +9,9 @@ }, bookId: { type: Number + }, + isshowDrawBtn:{ + type:Boolean } }, diff --git a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml index 45b7081..b8ee0b4 100644 --- a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml +++ b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml @@ -1,6 +1,11 @@ <!--pages/bookServices/detail/components/learnResource/learnResource.wxml--> -<view class="learnResource" theme="primary"> +<view + class="learnResource" + theme="primary" + style="justify-content: {{!isshowDrawBtn ? 'flex-end' : ''}};" +> <t-button + wx:if="{{isshowDrawBtn}}" loading="{{receive}}" class="btn" theme="primary" @@ -19,6 +24,7 @@ theme="primary" style="height: 72rpx; font-size: 28rpx" bind:tap="goBuyResource" + style="margin: {{!isshowDrawBtn ? '0 30rpx' : ''}}" > <view slot="content" class="btn-content"> <image src="/static/images/bookService/detail/yijiangoumai.png" /> diff --git a/packageBookService/pages/bookServices/detail/components/relatedBooks/index.js b/packageBookService/pages/bookServices/detail/components/relatedBooks/index.js new file mode 100644 index 0000000..a88e921 --- /dev/null +++ b/packageBookService/pages/bookServices/detail/components/relatedBooks/index.js @@ -0,0 +1,22 @@ +// packageBookService/pages/bookServices/detail/components/relatedBooks/index.js +Component({ + /** + * 缁勪欢鐨勫睘鎬у垪琛� + */ + properties: { + relatedBookData: { + type: Array, + value:[] + }, + }, + + /** + * 缁勪欢鐨勫垵濮嬫暟鎹� + */ + data: {}, + + /** + * 缁勪欢鐨勬柟娉曞垪琛� + */ + methods: {}, +}); diff --git a/packageBookService/pages/bookServices/detail/components/relatedBooks/index.json b/packageBookService/pages/bookServices/detail/components/relatedBooks/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/packageBookService/pages/bookServices/detail/components/relatedBooks/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxml b/packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxml new file mode 100644 index 0000000..556ddb0 --- /dev/null +++ b/packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxml @@ -0,0 +1,8 @@ +<!--packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxml--> +<view class="reletedBooks"> + <!-- <view wx:for="{{relatedBookData}}" wx:key="id" class="book-box"> + <image src="{{item.icon}}" /> + <text>{{item.name}}</text> + </view> --> + 鐩稿叧鍥句功 +</view> diff --git a/packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxss b/packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxss new file mode 100644 index 0000000..febb9ae --- /dev/null +++ b/packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxss @@ -0,0 +1 @@ +/* packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxss */ \ No newline at end of file diff --git a/packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml b/packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml index 9f8071f..cf0e3d4 100644 --- a/packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml +++ b/packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml @@ -66,12 +66,14 @@ wx:for="{{list}}" wx:key="id" wx:if="{{radioItem == 'test'}}" + bind:tap="goTest" + data-value="{{item}}" > <view class="list-title"> <image src="/static/images/bookService/detail/test-icon.png"></image> <text>{{item.name}}</text> </view> - <view class="practice" bind:tap="goTest" data-value="{{item}}"> + <view class="practice"> <image src="/static/images/bookService/detail/lianxi-icon.png"></image> </view> </view> diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js index 0ea1d2e..7aba5ed 100644 --- a/packageBookService/pages/bookServices/detail/components/tree/index.js +++ b/packageBookService/pages/bookServices/detail/components/tree/index.js @@ -1,31 +1,29 @@ -const util = require('./components/util') // 寮曞叆灏佽杩囩殑鍔犺浇鎻愮ず -import { - loginInfo -} from '../../../../../../assets/js/login' -const app = getApp() +const util = require("./components/util"); // 寮曞叆灏佽杩囩殑鍔犺浇鎻愮ず +import { loginInfo } from "../../../../../../assets/js/login"; +const app = getApp(); Component({ // checked: false, properties: { treeList: { type: Array, - value: [] + value: [], }, bookInfo: { type: Object, - value: {} + value: {}, }, buyIds: { type: Array, - value: [] + value: [], }, tab: { type: String, - value: '' + value: "", }, applyState: { type: String, - value: '' + value: "", }, openIds: { type: Array, @@ -42,33 +40,34 @@ superior: { type: Boolean, value: false, - } + }, }, data: { - sonPurchaseSaleMethodId: '', + sonPurchaseSaleMethodId: "", superiorPurchaseSaleMethodId: [], activeValues: [1, 2], - webpageSrc: '', + webpageSrc: "", cloudShoppingCart: [], selectAll: [], shoppingCart: true, stop: false, }, ready() { - this.setData({ - - }) - console.log('鍑嗗'); + this.setData({}); + console.log("鍑嗗"); }, onLoad() { this.setData({ - sonPurchaseSaleMethodId: [] - }) - console.log(this.data.sonPurchaseSaleMethodId, 'sonPurchaseSaleMethodId789'); + sonPurchaseSaleMethodId: [], + }); + console.log( + this.data.sonPurchaseSaleMethodId, + "sonPurchaseSaleMethodId789" + ); }, observers: { - 'openIds': function (newValue) { + openIds: function (newValue) { // var myEventDetail = { // } // var myEventOption = { @@ -76,18 +75,17 @@ // composed: true // } // this.triggerEvent('handleTree', myEventDetail, myEventOption) - } + }, }, methods: { handleList(tree) { for (let index = 0; index < tree.length; index++) { const item = tree[index]; - if (item.sysType == 'CmsItem' && !item.checked) { - + if (item.sysType == "CmsItem" && !item.checked) { } if (item.children && item.children.length > 0) { - this.handleList(item.children) + this.handleList(item.children); } } }, @@ -100,38 +98,39 @@ handleCheck(data) { for (let index = 0; index < data.length; index++) { const element = data[index]; - element.checked = true + element.checked = true; if (element.childrenCount && element.type == "productFolder") { - handleCheck(element.children) + handleCheck(element.children); } } }, downloadTeach(e) { - const value = e.currentTarget.dataset.value + const value = e.currentTarget.dataset.value; var myEventDetail = { value, - } // detail瀵硅薄锛屾彁渚涚粰浜嬩欢鐩戝惉鍑芥暟 + }; // detail瀵硅薄锛屾彁渚涚粰浜嬩欢鐩戝惉鍑芥暟 var myEventOption = { bubbles: true, - composed: true - } // 瑙﹀彂浜嬩欢鐨勯�夐」 - this.triggerEvent('downloadTeach', myEventDetail, myEventOption) - + composed: true, + }; // 瑙﹀彂浜嬩欢鐨勯�夐」 + this.triggerEvent("downloadTeach", myEventDetail, myEventOption); }, // 鍒ゆ柇璧勬簮鏄惁璐拱 resourceIsBuy(data) { if (data.saleMethod && data.saleMethod.length) { - if (data.saleMethod[0].State == 'Disable') return false - const isSHow = this.properties.buyIds.some((item) => item == data.saleMethod[0].Id) - return !isSHow + if (data.saleMethod[0].State == "Disable") return false; + const isSHow = this.properties.buyIds.some( + (item) => item == data.saleMethod[0].Id + ); + return !isSHow; } else { - return false + return false; } }, // 璺宠浆闊宠棰戞挱鏀惧櫒 goPlayer(e) { // 妫�鏌ョ櫥褰曠姸鎬� - const token = wx.getStorageSync(app.config.tokenKey) + const token = wx.getStorageSync(app.config.tokenKey); if (!token) { loginInfo(app, (data) => { // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� @@ -140,68 +139,72 @@ } else { // 鍑虹幇閿欒锛岃繑鍥瀎alse } - }) + }); } else { - const item = e.currentTarget.dataset.item - const parent = e.currentTarget.dataset.parent - let url + const item = e.currentTarget.dataset.item; + const parent = e.currentTarget.dataset.parent; + let url; if (this.properties.isShowCheck && this.resourceIsBuy(item)) { - return wx.showToast({ - icon: 'error', - title: "璇峰厛璐拱璧勬簮" - }) + return false; } - if (item.selectType == 'video' || item.learnSelectType == 'video') { - url = '/packageDomain/pages/resourceDetails/myVideo/index' - } else if (item.selectType == 'audio' || item.learnSelectType == 'audio') { - url = '/packageDomain/pages/resourceDetails/myAudio/index' - } else if (item.selectType == 'picture' || item.selectType == 'zip') { - url = '/packageDomain/pages/resourceDetails/document/index' + if (item.selectType == "video" || item.learnSelectType == "video") { + url = "/packageDomain/pages/resourceDetails/myVideo/index"; + } else if ( + item.selectType == "audio" || + item.learnSelectType == "audio" + ) { + url = "/packageDomain/pages/resourceDetails/myAudio/index"; + } else if (item.selectType == "picture" || item.selectType == "zip") { + url = "/packageDomain/pages/resourceDetails/document/index"; } - if (this.properties.tab == 'jsek_cloudLearning' && this.resourceIsBuy(item)) { + if ( + this.properties.tab == "jsek_cloudLearning" && + this.resourceIsBuy(item) + ) { return wx.showToast({ - icon: 'error', - title: '璇峰厛璐拱璇ヨ祫婧�', - }) + icon: "error", + title: "璇峰厛璐拱璇ヨ祫婧�", + }); } wx.navigateTo({ url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parent.productLinkPath}&parentName=${parent.name}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}`, - }) - if (item.selectType == 'document' || item.selectType == 'pdf') { - const fileLink = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file - console.log(fileLink, 'fileLink'); + }); + if (item.selectType == "document" || item.selectType == "pdf") { + const fileLink = + app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file; + console.log(fileLink, "fileLink"); //鎻愮ず鍔犺浇涓� - util.showLoading() + util.showLoading(); // 鍗曟涓嬭浇鍏佽鐨勬渶澶ф枃浠朵负 200MB wx.downloadFile({ url: fileLink, // 鍦板潃宸叉墦鐮侊紝鑷繁鎹釜鍏朵粬鐨勫湴鍧�锛�"https://www.xxxxx.com/file/娴嬭瘯閫氱煡.pdf"锛� success: function (res) { - console.log(res, "wx.downloadFile success res") + console.log(res, "wx.downloadFile success res"); if (res.statusCode != 200) { - util.hideLoadingWithErrorTips() - return false + util.hideLoadingWithErrorTips(); + return false; } - var Path = res.tempFilePath //杩斿洖鐨勬枃浠朵复鏃跺湴鍧�锛岀敤浜庡悗闈㈡墦寮�鏈湴棰勮鎵�鐢� + var Path = res.tempFilePath; //杩斿洖鐨勬枃浠朵复鏃跺湴鍧�锛岀敤浜庡悗闈㈡墦寮�鏈湴棰勮鎵�鐢� wx.openDocument({ filePath: Path, showMenu: true, success: function (res) { - console.log('鎵撳紑鎴愬姛'); - util.hideLoading() - } - }) + console.log("鎵撳紑鎴愬姛"); + util.hideLoading(); + }, + }); }, fail: function (err) { console.log(err, "wx.downloadFile fail err"); - util.hideLoadingWithErrorTips() - } - }) + util.hideLoadingWithErrorTips(); + }, + }); } - if (item.selectType == 'webpage') { + if (item.selectType == "webpage") { this.setData({ - webpageSrc: item.jsek_link - }) - console.log(this.data.webpageSrc, 'webpageSrc'); + webpageSrc: item.jsek_link, + }); + console.log(this.data.webpageSrc, "webpageSrc"); } } }, @@ -212,13 +215,13 @@ function findChildren(item) { if (item.id === id) { if (item.children && item.children.length > 0) { - item.children.forEach(child => { + item.children.forEach((child) => { findChildren(child); }); } } else { if (item.children && item.children.length > 0) { - item.children.forEach(child => { + item.children.forEach((child) => { findChildren(child); }); } @@ -227,8 +230,8 @@ result.push(...item.children); } } - console.log(this.properties.treeList, 'this.properties.treeList'); - this.properties.treeList.forEach(item => { + console.log(this.properties.treeList, "this.properties.treeList"); + this.properties.treeList.forEach((item) => { findChildren(item); }); return result; @@ -240,16 +243,16 @@ function flatten(node) { result.push(node); if (node.children && node.children.length > 0) { - node.children.forEach(child => { + node.children.forEach((child) => { flatten(child); }); } } - tree.forEach(node => { + tree.forEach((node) => { flatten(node); }); // console.log(result, 'result'); - return result + return result; }, // 鍙樹负true @@ -257,7 +260,7 @@ function findAndUpdate(node) { if (ids.includes(node.id)) { // console.log(node, 'node'); - node.checked = state // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true + node.checked = state; // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true } if (node.children && node.children.length > 0) { for (let child of node.children) { @@ -274,13 +277,13 @@ checkResoucrceInfo(tree, id) { function findAndUpdate(node) { - if (node.sysType == 'CmsFolder' && node.children.length > 0) { + if (node.sysType == "CmsFolder" && node.children.length > 0) { for (let index = 0; index < node.children.length; index++) { const element = node.children[index]; - findAndUpdate(element) + findAndUpdate(element); } } else if (id == node.id && node.sysType == "CmsItem") { - node.checked = !node.checked // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true + node.checked = !node.checked; // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true } } for (let node of tree) { @@ -290,142 +293,162 @@ }, // 鍏ㄩ�� checkAll() { - const ids = [] - const list = [] - let checked = '' - this.properties.treeList.forEach(item => { + const ids = []; + const list = []; + let checked = ""; + this.properties.treeList.forEach((item) => { if (item.children && item.children.length > 0) { - list.push(...this.flattenTree([item])) + list.push(...this.flattenTree([item])); } - }) - list.forEach(item => { - ids.push(item.id) - checked = item.checked - }) - const flag = list.findIndex(item => item.checked == false) > -1 ? true : false - const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids, flag); - console.log(checked, 'list'); + }); + list.forEach((item) => { + ids.push(item.id); + checked = item.checked; + }); + const flag = + list.findIndex((item) => item.checked == false) > -1 ? true : false; + var myEventDetail = { + value:flag, + }; // detail瀵硅薄锛屾彁渚涚粰浜嬩欢鐩戝惉鍑芥暟 + var myEventOption = { + bubbles: true, + composed: true, + }; // 瑙﹀彂浜嬩欢鐨勯�夐」 + this.triggerEvent('changeCheckAll',myEventDetail,myEventOption) + const updataList = this.findAndUpdateItemsByIds( + this.properties.treeList, + ids, + flag + ); + console.log(checked, "list"); if (!checked) { this.setData({ - selectAll: list - }) + selectAll: list, + }); } this.setData({ - treeList: updataList - }) + treeList: updataList, + }); }, // 绔犺妭鍕鹃�� checkResourceTitle(e) { - const flag = e.detail.checked - debugger + const flag = e.detail.checked; + debugger; // 杩欎釜鏃跺�檆hecked鐨勫�兼槸fals - let checkResourceTitleList = [] - const item = e.currentTarget.dataset.item + let checkResourceTitleList = []; + const item = e.currentTarget.dataset.item; // - let list = this.flattenTree([item]) - let ids = [] - list.forEach(item => { - ids.push(item.id) - }) - // console.log(list, 'list789'); - const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids, flag); - this.setData({ - treeList: updatedTreeList // 鏇存柊 treeList 鏁版嵁 + let list = this.flattenTree([item]); + let ids = []; + list.forEach((item) => { + ids.push(item.id); }); - console.log(list, 'list.checked'); + // console.log(list, 'list789'); + const updatedTreeList = this.findAndUpdateItemsByIds( + this.properties.treeList, + ids, + flag + ); + this.setData({ + treeList: updatedTreeList, // 鏇存柊 treeList 鏁版嵁 + }); + console.log(list, "list.checked"); if (!list.checked) { this.setData({ - superiorPurchaseSaleMethodId: list - }) + superiorPurchaseSaleMethodId: list, + }); } // console.log(this.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId'); - list.forEach(items => { - console.log(items.checked, 'itesasd'); + list.forEach((items) => { + console.log(items.checked, "itesasd"); if (!items.checked) { this.setData({ - cloudShoppingCart: items - }) + cloudShoppingCart: items, + }); } - }) + }); this.setData({ - openIds: this.data.openIds - }) + openIds: this.data.openIds, + }); }, // 瀛愰」鍕鹃�� checkResource(e) { - const citem = e.currentTarget.dataset.item - console.log(citem, '5648'); - const updataList = this.checkResoucrceInfo(this.properties.treeList, citem.id) - console.log(citem.checked, 'citem.checked'); + const citem = e.currentTarget.dataset.item; + console.log(citem, "5648"); + const updataList = this.checkResoucrceInfo( + this.properties.treeList, + citem.id + ); + console.log(citem.checked, "citem.checked"); if (!citem.checked) { //閫変腑鐨勬椂鍊欐坊鍔爄d - let sonPurchaseSaleMethodId = this.data.sonPurchaseSaleMethodId || [] - console.log(this.properties.paymentPage, 'this.properties.paymentPage'); + let sonPurchaseSaleMethodId = this.data.sonPurchaseSaleMethodId || []; + console.log(this.properties.paymentPage, "this.properties.paymentPage"); if (this.properties.paymentPage) { console.log(789987); - sonPurchaseSaleMethodId = [] - this.properties.paymentPage = false + sonPurchaseSaleMethodId = []; + this.properties.paymentPage = false; } if (!this.properties.paymentPage) { - sonPurchaseSaleMethodId.push(citem.saleMethod[0].Id) + sonPurchaseSaleMethodId.push(citem.saleMethod[0].Id); } this.setData({ - sonPurchaseSaleMethodId: sonPurchaseSaleMethodId - }) + sonPurchaseSaleMethodId: sonPurchaseSaleMethodId, + }); console.log(this.data.sonPurchaseSaleMethodId); } else { // 鍙栨秷閫変腑鐨勬椂鍊欏垹闄d } this.setData({ treeList: updataList, - }) + }); }, // 鍔犲叆璐墿杞� async onCloudShoppingCart(e) { - - let shoppingCartGetId = [] - const saleMethodId = e.currentTarget.dataset.item.saleMethod[0].Id + let shoppingCartGetId = []; + const saleMethodId = e.currentTarget.dataset.item.saleMethod[0].Id; console.log(saleMethodId); let query = { start: 0, size: 999, filterList: [], - searchList: [] - } + searchList: [], + }; - const res = await app.MG.store.getShoppingCartProductList(query) - res.datas.forEach(item => { - shoppingCartGetId.push(item.saleMethod.id) - }) + const res = await app.MG.store.getShoppingCartProductList(query); + res.datas.forEach((item) => { + shoppingCartGetId.push(item.saleMethod.id); + }); if (shoppingCartGetId.includes(saleMethodId)) { console.log(111); wx.showToast({ - icon: 'error', - title: '宸叉坊鍔�', - }) + icon: "error", + title: "宸叉坊鍔�", + }); this.setData({ - shoppingCart: false - }) + shoppingCart: false, + }); } else { let query = { - requests: [{ - saleMethodId: saleMethodId, - storeEventId: null, - // agentCode: '鐢靛瓙涔�' - }] - } - const addRes = await app.MG.store.addShoppingCart(query) - console.log(addRes, 'addRes'); + requests: [ + { + saleMethodId: saleMethodId, + storeEventId: null, + // agentCode: '鐢靛瓙涔�' + }, + ], + }; + const addRes = await app.MG.store.addShoppingCart(query); + console.log(addRes, "addRes"); wx.showToast({ - icon: 'success', - title: '娣诲姞鎴愬姛', - }) + icon: "success", + title: "娣诲姞鎴愬姛", + }); } - }, }, - catchtap() {} -}) \ No newline at end of file + catchtap() {}, +}); diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.wxml b/packageBookService/pages/bookServices/detail/components/tree/index.wxml index 4753100..ef9cd2b 100644 --- a/packageBookService/pages/bookServices/detail/components/tree/index.wxml +++ b/packageBookService/pages/bookServices/detail/components/tree/index.wxml @@ -132,12 +132,12 @@ wx:if="{{tab == 'jsek_teachingResources'}}" > <!-- 涓嬭浇鎸夐挳 --> - <image + <!-- <image src="/static/images/bookService/detail/download-icon.png" class="download-image" data-value="{{citem}}" catchtap="downloadTeach" - ></image> + ></image> --> </view> <view wx:if="{{tab == 'jsek_cloudLearning'}}"> <!-- 浜戝涔犺瘯鐪嬪浘鏍� --> diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index 180ae3b..16c9cf8 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -1,31 +1,29 @@ // pages/bookServices/detail/index.js -import Toast from 'tdesign-miniprogram/toast'; -import tool from '../../../../assets/js/toolClass'; -import { - loginInfo -} from '../../../../assets/js/login' +import Toast from "tdesign-miniprogram/toast"; +import tool from "../../../../assets/js/toolClass"; +import { loginInfo } from "../../../../assets/js/login"; const app = getApp(); Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - bookId: '', - barHeight: '', - navBarHeight: '', + bookId: "", + barHeight: "", + navBarHeight: "", options: { - id: '', - name: '', + id: "", + name: "", }, bookDetail: {}, bookItemDetail: {}, link: { - jd: '', - tamll: '', - dang: '', - micro: '', + jd: "", + tamll: "", + dang: "", + micro: "", }, - tabValue: 'brief', + tabValue: "brief", cmsDatas: [], // 璧勬簮refCode鍒楄〃 ids: [1], list: [], @@ -39,7 +37,8 @@ applyResourceState: false, // 鐢宠鏁欏璧勬簮鎸夐挳闃叉姈 resourceClassList: [], // 璧勬簮鎵�灞炲垎绫� applyState: "", // 鏁欏璧勬簮鐢宠鐘舵�� - deadline: "", // 鏁欏璧勬簮鐢宠鏈夋晥鏃ユ湡 + deadline: "", // 鏁欏璧勬簮鐢宠鏈夋晥鏃ユ湡, + isshowDrawBtn: true, // 浜戝涔犻鍙栨煡鐪嬫寜閽槸鍚︽樉绀� rejectCause: "", // 涓嬭浇鎷掔粷鍘熷洜 buyIdList: [], shoppingCartGetId: [], // 宸茶喘涔癷d鍒楄〃 @@ -47,8 +46,8 @@ loading: false, isShowTeachDownload: false, // 鎻愮ずPC涓嬭浇寮圭獥鐘舵�� confirmBtn: { - content: '鎴戠煡閬撲簡', - variant: 'base' + content: "鎴戠煡閬撲簡", + variant: "base", }, mockData: { id: 0, // 閿�鍞甶d @@ -56,8 +55,10 @@ count: 0, // 缁勫嵎宸茶喘涔版鏁� useCount: 0, // 缁勪欢宸蹭娇鐢ㄦ鏁� residue: 0, // 缁勫嵎鍓╀綑娆℃暟 - mockList: [] // 鐢ㄦ埛缁勫嵎鎻愪氦淇℃伅 + mockList: [], // 鐢ㄦ埛缁勫嵎鎻愪氦淇℃伅 }, + relatedBookPath: "", // 鐩稿叧鍥句功path + relatedBookData: [], // 鐩稿叧鍥句功鍒楄〃 flag: true, noResources: false, selectedIds: "", //鍟嗗搧鎴栧瓙鍟嗗搧閿�鍞柟寮� @@ -77,65 +78,69 @@ bookName: "", fileType: "", md5: "", - freePage: "" + freePage: "", }, //闃呰鍣ㄦ暟鎹� buyResourceData: { - productLinkPath: '', - refCode: '', + productLinkPath: "", + refCode: "", }, briefIcon: { - name: "/static/images/bookService/detail/tushujianjie-g.png" + name: "/static/images/bookService/detail/tushujianjie-g.png", }, briefIconClick: { - name: '/static/images/bookService/detail/tushujianjie-click.png' + name: "/static/images/bookService/detail/tushujianjie-click.png", }, eBookIcon: { - name: '/static/images/bookService/detail/ebook-g.png' + name: "/static/images/bookService/detail/ebook-g.png", }, eBookClickIcon: { - name: '/static/images/bookService/detail/ebook-click.png' + name: "/static/images/bookService/detail/ebook-click.png", }, teachResourcesIcon: { - name: '/static/images/bookService/detail/jiaoxueziyuan.png' + name: "/static/images/bookService/detail/jiaoxueziyuan.png", }, teachResourcesClickIcon: { - name: '/static/images/bookService/detail/jiaoxueziyuan-click.png' + name: "/static/images/bookService/detail/jiaoxueziyuan-click.png", }, learnResourceIcon: { - name: '/static/images/bookService/detail/yunxuexi.png' + name: "/static/images/bookService/detail/yunxuexi.png", }, learnResourceClickIcon: { - name: '/static/images/bookService/detail/yunxuexi-click.png' + name: "/static/images/bookService/detail/yunxuexi-click.png", }, testResourceIocn: { - name: '/static/images/bookService/detail/test-icon-g.png' + name: "/static/images/bookService/detail/test-icon-g.png", }, testResourceClickIocn: { - name: '/static/images/bookService/detail/test-click-icon.png' + name: "/static/images/bookService/detail/test-click-icon.png", }, noteIcon: { - name: '/static/images/bookService/detail/biji-icon-g.png' + name: "/static/images/bookService/detail/biji-icon-g.png", }, noteClickIcon: { - name: '/static/images/bookService/detail/biji-click-icon.png' + name: "/static/images/bookService/detail/biji-click-icon.png", + }, + linkIcon: { + name: "/static/images/bookService/detail/link.png", + }, + linkClickIcon: { + name: "/static/images/bookService/detail/link-click.png", }, icon1: { - name: "/static/images/bookService/detail/dangdang.png" - } + name: "/static/images/bookService/detail/dangdang.png", + }, }, - resetTree: function (e) { this.setData({ currentCheck: e.detail.checkedItem, - list: e.detail.changeList - }) + list: e.detail.changeList, + }); }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { - // 妫�鏌ョ櫥褰曠姸鎬� // const token = wx.getStorageSync(app.config.tokenKey) // if (!token) { @@ -153,7 +158,8 @@ const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 - const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� + const navBarHeight = + (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� this.setData({ bookId: options.id, barHeight: systInfo.statusBarHeight, @@ -167,32 +173,29 @@ }); this.getBookInfo(options.id); - this.getResourceClass() // 鑾峰彇璧勬簮鎵�灞炲垎绫� - const token = wx.getStorageSync(app.config.tokenKey) + this.getResourceClass(); // 鑾峰彇璧勬簮鎵�灞炲垎绫� + const token = wx.getStorageSync(app.config.tokenKey); if (token) { - this.getShoppingCartProductGet() - this.getApplyInfo(options.id) - this.getMockData() - this.getAlreadyPBookList() - this.getAlreadyEBookList() + this.getShoppingCartProductGet(); + this.getApplyInfo(options.id); + this.getMockData(); + this.getAlreadyPBookList(); + this.getAlreadyEBookList(); } if (wx.getStorageSync(app.config.userInfoKey)) { this.setData({ - userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)) - }) + userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), + }); // 鑾峰彇鐢宠娆℃暟 - this.getSelectPaperBookCount() - this.getSelectBookCount() + this.getSelectPaperBookCount(); + this.getSelectBookCount(); } - }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 */ - onReady() { - - }, + onReady() {}, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず @@ -201,16 +204,16 @@ if (wx.getStorageSync("paperBookList")) { this.setData({ paperBookList: wx.getStorageSync("paperBookList"), - }) + }); } if (wx.getStorageSync("electronicBookList")) { this.setData({ electronicBookList: wx.getStorageSync("electronicBookList"), - }) + }); } this.setData({ - num: this.data.paperBookList.length + this.data.electronicBookList.length - }) + num: this.data.paperBookList.length + this.data.electronicBookList.length, + }); }, /** @@ -226,18 +229,15 @@ /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ - onPullDownRefresh() { - - - }, + onPullDownRefresh() {}, /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ onReachBottom() { - if (this.data.tabValue == 'jsek_note') { - const child = this.selectComponent('#note') - child.onReachBottom() + if (this.data.tabValue == "jsek_note") { + const child = this.selectComponent("#note"); + child.onReachBottom(); } }, @@ -248,11 +248,13 @@ // 鏍煎紡鍖栨棩鏈� formatDate(dateString) { if (!dateString) { - return ''; + return ""; } - const match = dateString.match(/^(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/); + const match = dateString.match( + /^(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/ + ); if (!match) { - throw new Error('Invalid date format'); + throw new Error("Invalid date format"); } const [, year, month, day, hours, minutes, seconds] = match; @@ -262,11 +264,11 @@ parseInt(day, 10), parseInt(hours, 10), parseInt(minutes, 10), - parseInt(seconds, 10), + parseInt(seconds, 10) ); if (isNaN(date.getTime())) { - throw new Error('Invalid date'); + throw new Error("Invalid date"); } // 鐢变簬灏忕▼搴忕幆澧冨彲鑳戒笉鏀寔 Intl.DateTimeFormat锛屾垜浠娇鐢ㄧ畝鍖栫殑鏍煎紡鍖栨柟娉� @@ -275,17 +277,32 @@ }, // 绠�鍖栫殑鏈堜唤鏍煎紡鍖栧嚱鏁帮紝杩斿洖鏈堜唤鐨勪腑鏂囪〃杈� formatMonth(month) { - const months = ['1鏈�', '2鏈�', '3鏈�', '4鏈�', '5鏈�', '6鏈�', '7鏈�', '8鏈�', '9鏈�', '10鏈�', '11鏈�', '12鏈�']; + const months = [ + "1鏈�", + "2鏈�", + "3鏈�", + "4鏈�", + "5鏈�", + "6鏈�", + "7鏈�", + "8鏈�", + "9鏈�", + "10鏈�", + "11鏈�", + "12鏈�", + ]; return months[parseInt(month, 10) - 1]; }, // 閲戦鏄剧ず.00鏍煎紡 numFormat(value) { - if (!value) return '0.00'; + if (!value) return "0.00"; value = Number(value).toFixed(2); var intPart = Math.trunc(value); // 鑾峰彇鏁存暟閮ㄥ垎 - var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); // 灏嗘暣鏁伴儴鍒嗛�笁涓�鏂� - var floatPart = '.00'; // 棰勫畾涔夊皬鏁伴儴鍒� - var value2Array = value.split('.'); + var intPartFormat = intPart + .toString() + .replace(/(\d)(?=(?:\d{3})+$)/g, "$1,"); // 灏嗘暣鏁伴儴鍒嗛�笁涓�鏂� + var floatPart = ".00"; // 棰勫畾涔夊皬鏁伴儴鍒� + var value2Array = value.split("."); // =2琛ㄧず鏁版嵁鏈夊皬鏁颁綅 if (value2Array.length === 2) { floatPart = value2Array[1].toString(); // 鎷垮埌灏忔暟閮ㄥ垎 @@ -306,14 +323,14 @@ "mockData'.id": 0, "mockData.price": 0, "mockData.count": 0, - }) + }); const query = { - path: '*', - queryType: '*', + path: "*", + queryType: "*", productId: id, - favoriteTypes: 'FavoriteBookCity', + favoriteTypes: "FavoriteBookCity", itemFields: { - 'SysType=': 'CmsFolder', + "SysType=": "CmsFolder", }, coverSize: { height: 300, @@ -345,62 +362,73 @@ this.setData({ bookDetail: res.datas, cmsDatas: res.datas.cmsDatas[0].datas, - buyIdList: res.datas.purchasedSaleMethodIdList + buyIdList: res.datas.purchasedSaleMethodIdList, + relatedBookPath: JSON.parse(res.datas.datas.ProductLinkInfo)[0] + .LinkPath, }); this.getSubTtem(); // 鑾峰彇鍥句功鍒嗙被 - let className = '' - if (Array.isArray(res.datas.bookClassification) && res.datas.bookClassification.length) { + let className = ""; + if ( + Array.isArray(res.datas.bookClassification) && + res.datas.bookClassification.length + ) { const iconType = JSON.parse(res.datas.bookClassification)[0][0]; const classType = JSON.parse(res.datas.bookClassification)[0][1]; - className = await this.getBookClass(iconType, classType) + className = await this.getBookClass(iconType, classType); } // 鑾峰彇缁勫嵎閿�鍞甶d if (res.datas.saleMethod && res.datas.saleMethod.length) { res.datas.saleMethod.forEach((item) => { - if (item.SaleType == 'combinationTestPaper') { + if (item.SaleType == "combinationTestPaper") { this.setData({ - 'mockData.id': item.Id, - 'mockData.price': item.Price - }) + "mockData.id": item.Id, + "mockData.price": item.Price, + }); } - }) + }); } // 鑾峰彇缁勫嵎宸茶喘涔版鏁� - if (res.datas.purchasedSaleMethodIdList && res.datas.purchasedSaleMethodIdList.length) { + if ( + res.datas.purchasedSaleMethodIdList && + res.datas.purchasedSaleMethodIdList.length + ) { if (this.data.mockData.id) { let count = res.datas.purchasedSaleMethodIdList.filter( (item) => item == this.data.mockData.id - ).length + ).length; this.setData({ - 'mockData.count': count - }) + "mockData.count": count, + }); } } this.setData({ - 'bookDetail.publicationDate': this.formatDate(this.data.bookDetail.publicationDate), - 'bookDetail.class': className, - 'bookDetail.price': this.numFormat(this.data.bookDetail.price), - 'bookDetail.oldPrice': this.numFormat(this.data.bookDetail.oldPrice), - 'bookDetail.paperPrice': this.numFormat(this.data.bookDetail.paperPrice), - pageLoading: false + "bookDetail.publicationDate": this.formatDate( + this.data.bookDetail.publicationDate + ), + "bookDetail.class": className, + "bookDetail.price": this.numFormat(this.data.bookDetail.price), + "bookDetail.oldPrice": this.numFormat(this.data.bookDetail.oldPrice), + "bookDetail.paperPrice": this.numFormat( + this.data.bookDetail.paperPrice + ), + pageLoading: false, }); - console.log('鍥句功淇℃伅', this.data.bookDetail); + console.log("鍥句功淇℃伅", this.data.bookDetail); }); - }, //璇锋眰瀛愬晢鍝佺殑鏂囦欢 getSubTtem() { const obj = { - path: '*', - queryType: 'SubProduct', + path: "*", + queryType: "SubProduct", sort: { - type: 'Desc', - field: 'CreateDate' + type: "Desc", + field: "CreateDate", }, paging: { start: 0, - size: 6 + size: 6, }, mainProductId: this.data.bookDetail.id, fields: { @@ -408,43 +436,51 @@ bookshelf_pdf: [], bookshelf_protectedEpub: [], bookshelf_freeEpub: [], //epub璇曡鐧惧垎姣� - bookshelf_probationPage: [] //pdf璇曡椤垫暟 - } - } + bookshelf_probationPage: [], //pdf璇曡椤垫暟 + }, + }; app.MG.store.getProductList(obj).then((res) => { if (res.datas && res.datas.length > 0) { this.setData({ bookItemDetail: res.datas[0], selectedIds: res.datas[0].defaultSaleMethod.id, - bookBuy: res.datas[0].purchasedSaleMethodIdList.indexOf(res.datas[0].defaultSaleMethodId) > -1 + bookBuy: + res.datas[0].purchasedSaleMethodIdList.indexOf( + res.datas[0].defaultSaleMethodId + ) > -1, }); - let times = new Date(res.datas[0].defaultSaleMethod.endDate).getTime() - let startTime = new Date(res.datas[0].defaultSaleMethod.beginDate).getTime() + let times = new Date(res.datas[0].defaultSaleMethod.endDate).getTime(); + let startTime = new Date( + res.datas[0].defaultSaleMethod.beginDate + ).getTime(); if (times < new Date().getTime() || new Date().getTime() < startTime) { this.setData({ - expire: true + expire: true, }); } else { this.setData({ - expire: false + expire: false, }); } - if (res.datas[0].bookshelf_pdf || res.datas[0].bookshelf_protectedEpub) { + if ( + res.datas[0].bookshelf_pdf || + res.datas[0].bookshelf_protectedEpub + ) { this.setData({ - noFile: true + noFile: true, }); if (res.datas[0].bookshelf_pdf) { this.setData({ "fileInfo.bookName": this.data.bookDetail.name, - "fileInfo.fileType": 'pdf', + "fileInfo.fileType": "pdf", "fileInfo.md5": res.datas[0].bookshelf_pdf, "fileInfo.freePage": res.datas[0].bookshelf_probationPage, }); } else if (res.datas[0].bookshelf_protectedEpub) { this.setData({ "fileInfo.bookName": this.data.bookDetail.name, - "fileInfo.fileType": 'epub', + "fileInfo.fileType": "epub", "fileInfo.md5": res.datas[0].bookshelf_protectedEpub, "fileInfo.freePage": res.datas[0].bookshelf_freeEpub, }); @@ -453,19 +489,19 @@ } else { if (this.data.bookDetail.pdf || this.data.bookDetail.protectedEpub) { this.setData({ - noFile: true + noFile: true, }); if (this.data.bookDetail.pdf) { this.setData({ "fileInfo.bookName": this.data.bookDetail.name, - "fileInfo.fileType": 'pdf', + "fileInfo.fileType": "pdf", "fileInfo.md5": this.data.bookDetail.pdf, "fileInfo.freePage": this.data.bookDetail.probationPage, }); } else if (this.data.bookDetail.protectedEpub) { this.setData({ "fileInfo.bookName": this.data.bookDetail.name, - "fileInfo.fileType": 'epub', + "fileInfo.fileType": "epub", "fileInfo.md5": this.data.bookDetail.protectedEpub, "fileInfo.freePage": this.data.bookDetail.freeEpubPage, }); @@ -473,27 +509,34 @@ } this.setData({ selectedIds: this.data.bookDetail.defaultSaleMethodId, - bookBuy: this.data.bookDetail.purchasedSaleMethodIdList.indexOf(this.data.bookDetail.defaultSaleMethodId) > -1 + bookBuy: + this.data.bookDetail.purchasedSaleMethodIdList.indexOf( + this.data.bookDetail.defaultSaleMethodId + ) > -1, }); - let times = new Date(this.data.bookDetail.defaultSaleMethod.endDate).getTime() - let startTime = new Date(this.data.bookDetail.defaultSaleMethod.beginDate).getTime() + let times = new Date( + this.data.bookDetail.defaultSaleMethod.endDate + ).getTime(); + let startTime = new Date( + this.data.bookDetail.defaultSaleMethod.beginDate + ).getTime(); if (times < new Date().getTime() || new Date().getTime() < startTime) { this.setData({ - expire: true + expire: true, }); } else { this.setData({ - expire: false + expire: false, }); } } - }) + }); }, // 鑾峰彇鍥句功鍒嗙被 async getBookClass(iconType, classType) { - let name = ''; + let name = ""; const query = { - refCodes: ['bookClassification'], + refCodes: ["bookClassification"], }; await app.MG.store.getProductTypeField(query).then((res) => { JSON.parse(res[0].config).option.forEach((item) => { @@ -510,140 +553,149 @@ }, // 鏀惰棌 setCollect() { - const token = wx.getStorageSync(app.config.tokenKey) + const token = wx.getStorageSync(app.config.tokenKey); if (!token) { // 妫�鏌ョ櫥褰曠姸鎬� loginInfo(app, (data) => { // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� if (data) { // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue - this.getBookInfo(this.data.bookId) + this.getBookInfo(this.data.bookId); } else { // 鍑虹幇閿欒锛岃繑鍥瀎alse } - }) + }); } else { if (this.data.bookDetail.isFavourite) { app.MG.store .delProductLink({ productIds: [this.data.bookDetail.id], - linkType: 'FavoriteBookCity', + linkType: "FavoriteBookCity", }) .then(() => { this.setData({ - 'bookDetail.isFavourite': false - }) + "bookDetail.isFavourite": false, + }); }); } else { const params = { productIds: [this.data.bookDetail.id], - linkType: 'FavoriteBookCity', + linkType: "FavoriteBookCity", }; app.MG.store.addProductLink(params).then((res) => { this.setData({ - 'bookDetail.isFavourite': true - }) + "bookDetail.isFavourite": true, + }); }); } } - }, // 鎴戣寤鸿 suggestBtn() { // 妫�鏌ョ櫥褰曠姸鎬� - const token = wx.getStorageSync(app.config.tokenKey) - const child = this.selectComponent('#suggest-component') + const token = wx.getStorageSync(app.config.tokenKey); + const child = this.selectComponent("#suggest-component"); if (!token) { wx.showLoading({ - title: '鍔犺浇涓�', - }) + title: "鍔犺浇涓�", + }); loginInfo(app, (data) => { // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� if (data) { // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue - child.showDialog() - wx.hideLoading() + child.showDialog(); + wx.hideLoading(); } else { // 鍑虹幇閿欒锛岃繑鍥瀎alse } - }) + }); } else { // 濡傛灉鏄涓�娆$櫥褰曪紝浼氳烦杞嚦缁戝畾鐢ㄦ埛淇℃伅椤甸潰锛屽~鍐欏畬鐢ㄦ埛淇℃伅鍚庤繘琛岀櫥褰曞苟鍌ㄥ瓨token鍜岀敤鎴蜂俊鎭紝缁撴潫鍚庤烦杞洖褰撳墠椤甸潰锛堟惡甯﹂〉闈㈠弬鏁帮級 - child.showDialog() + child.showDialog(); } }, // 璺宠浆缃戝簵 goShop(e) { - const { - link - } = e.currentTarget.dataset; + const { link } = e.currentTarget.dataset; wx.navigateTo({ url: `/packageBookService/pages/bookServices/webpage/index?url=${link}`, - }) + }); }, + // tag鍒囨崲 onTabsChange(e) { this.setData({ tabValue: e.detail.value, - noResources: false - }) - if (e.detail.label == '鏁欏璧勬簮' || e.detail.label == '浜戝涔�' || e.detail.label == '浜戞祴璇�') { - const checkData = this.data.cmsDatas.find(item => item.refCode == e.detail.value) + noResources: false, + }); + if ( + e.detail.label == "鏁欏璧勬簮" || + e.detail.label == "浜戝涔�" || + e.detail.label == "浜戞祴璇�" + ) { + const checkData = this.data.cmsDatas.find( + (item) => item.refCode == e.detail.value + ); if (checkData) { - if (e.detail.value == 'jsek_cloudLearning') { + if (e.detail.value == "jsek_cloudLearning") { this.setData({ - 'buyResourceData.productLinkPath': checkData.productLinkPath, - 'buyResourceData.refCode': checkData.refCode - }) + "buyResourceData.productLinkPath": checkData.productLinkPath, + "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)) { - this.getResourceData(checkData) + 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) + ) { + this.getResourceData(checkData); } } else { this.setData({ - noResources: true - }) + noResources: true, + }); } - } else if (e.detail.label == '浜戠瑪璁�') { - const token = wx.getStorageSync(app.config.tokenKey) - const child = this.selectComponent('#note') - child.handleSubmitTitle() + } else if (e.detail.label == "浜戠瑪璁�") { + const token = wx.getStorageSync(app.config.tokenKey); + const child = this.selectComponent("#note"); + child.handleSubmitTitle(); if (token) { - child.changeLoading() - child.getNoteList() + child.changeLoading(); + child.getNoteList(); } - } else if (e.detail.label == '鐢靛瓙涔�') { - const child = this.selectComponent('#eBook') + } else if (e.detail.label == "鐢靛瓙涔�") { + const child = this.selectComponent("#eBook"); if (child) { - child.getProgress() + child.getProgress(); } + } else if (e.detail.label == "鐩稿叧鍥句功") { + this.getAboutBook(this.data.relatedBookPath); } }, // 鑾峰彇璧勬簮鎵�灞炲垎绫� getResourceClass() { let query = { - refCodes: ['resourcesClassification'] - } + refCodes: ["resourcesClassification"], + }; app.MG.store.getProductTypeField(query).then((res) => { this.setData({ - resourceClassList: JSON.parse(res[0].config).option - }) - }) + resourceClassList: JSON.parse(res[0].config).option, + }); + }); }, // 鑾峰彇鏁欏璧勬簮 浜戝涔� 浜戞祴璇� getResourceData(type) { this.setData({ loading: true, - noResources: false - }) + noResources: false, + }); let query = { - path: '*', - queryType: '*', + path: "*", + queryType: "*", productId: this.data.bookDetail.id, cmsPath: type.productLinkPath, itemFields: { - SysType: 'CmsFolder', + SysType: "CmsFolder", // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁� selectType: [], freeFile: [], @@ -652,96 +704,106 @@ isDownload: [], jsek_resourceBrief: [], jsek_link: [], - jsek_questionBank: [] + jsek_questionBank: [], }, pading: { start: 0, - size: 999 + size: 999, }, - } + }; app.MG.store .getProductDetail(query) .then(async (res) => { if (!res.datas.cmsDatas[0].datas.length) { return this.setData({ noResources: true, - loading: false - }) + loading: false, + }); } // 浜戞祴璇曪紝閫掑綊璇锋眰閲屽眰鏁版嵁 - if (type.refCode == 'questionBank') { + if (type.refCode == "questionBank") { const data = res.datas.cmsDatas[0].datas.filter( - (item) => item.refCode == 'jsek_questionBank' - ) - if (data.length) return this.getResourceData(data[0]) + (item) => item.refCode == "jsek_questionBank" + ); + if (data.length) return this.getResourceData(data[0]); } //鏁欏璧勬簮 浜戝涔� - if (type.refCode == 'jsek_teachingResources' || type.refCode == 'jsek_cloudLearning') { + if ( + type.refCode == "jsek_teachingResources" || + type.refCode == "jsek_cloudLearning" + ) { if (res.datas.cmsDatas[0].datas.length > 0) { - res.datas.cmsDatas[0].datas.forEach(item => { - item.checked = false - }) - const list = await this.getAllResource(res.datas.cmsDatas[0].datas) - let result = [] - if (type.refCode == 'jsek_teachingResources') { - this.findChildIds(list, result) + res.datas.cmsDatas[0].datas.forEach((item) => { + item.checked = false; + }); + const list = await this.getAllResource(res.datas.cmsDatas[0].datas); + let result = []; + if (type.refCode == "jsek_teachingResources") { + console.log("鏁欏璧勬簮", list); + this.findChildIds(list, result); this.setData({ teach: list, loading: false, - openTeachids: result - }) - console.log('鏁欏璧勬簮', this.data.teach, this.data.applyState); - } else if (type.refCode == 'jsek_cloudLearning') { - // res.datas.cmsDatas[0].datas.forEach(item => { - // item.checked = false - // }) - // const list = await this.getAllResource(res.datas.cmsDatas[0].datas) - this.findChildIds(list, result) + openTeachids: result, + }); + } else if (type.refCode == "jsek_cloudLearning") { + let arr = this.handleTreeData(list).filter((item) => + this.resourceIsBuy(item) + ); + let freeIds = arr.filter((item) => { + return item.saleMethod[0].Price == 0; + }); + if (!freeIds.length) + this.setData({ + isshowDrawBtn: false, + }); + debugger; + this.findChildIds(list, result); this.setData({ learn: list, loading: false, - openLearnids: result - }) + openLearnids: result, + }); } } else { // 鏃犳暟鎹� } - } else if (type.refCode == 'jsek_questionBank') { + } else if (type.refCode == "jsek_questionBank") { // const list = await this.getAllResource(res.datas.cmsDatas[0].datas) this.setData({ test: res.datas.cmsDatas[0].datas, - loading: false - }) + loading: false, + }); } else { - console.log('鍏朵粬'); + console.log("鍏朵粬"); } }) .catch((e) => { - console.log(e) - }) + console.log(e); + }); }, // 鑾峰彇tag涓嬫墍鏈夎祫婧� async getAllResource(data) { - if (!data.length) return false + if (!data.length) return false; for (let i = 0; i < data.length; i++) { - let item = data[i] - if (item.sysType == 'CmsFolder' && item.childrenCount > 0) { - item.children = [] - item.children = await this.getFolderItem(item.productLinkPath) - await this.getAllResource(item.children) + let item = data[i]; + if (item.sysType == "CmsFolder" && item.childrenCount > 0) { + item.children = []; + item.children = await this.getFolderItem(item.productLinkPath); + await this.getAllResource(item.children); } } - return data + return data; }, // 鑾峰彇璧勬簮鎺ュ彛 async getFolderItem(path) { let query = { - path: '*', - queryType: '*', + path: "*", + queryType: "*", productId: this.data.bookDetail.id, cmsPath: path, itemFields: { - SysType: 'CmsFolder', + SysType: "CmsFolder", // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁� selectType: [], freeFile: [], @@ -752,68 +814,70 @@ jsek_resourceBrief: [], jsek_link: [], accessType: [], - learnSelectType: [] + learnSelectType: [], }, pading: { start: 0, - size: 999 + size: 999, }, - } - const data = await app.MG.store.getProductDetail(query) + }; + const data = await app.MG.store.getProductDetail(query); data.datas.cmsDatas[0].datas.forEach((item) => { this.data.resourceClassList.forEach((type) => { - if (type.value == item.resourcesClassification) item.resourceClass = type.name - }) + if (type.value == item.resourcesClassification) + item.resourceClass = type.name; + }); // 缃戦〉 涓嶈兘涓嬭浇 绉佹湁鏂囦欢 - if (item.sysType == 'CmsItem') { - if (item.selectType == 'webpage') { - item.disabled = true + if (item.sysType == "CmsItem") { + if (item.selectType == "webpage") { + item.disabled = true; } else { if (item.isDownload != 1) { - item.disabled = true + item.disabled = true; } } if (item.file) { - if (item.fileMap[item.file].protectType == 'Private') item.disabled = true + if (item.fileMap[item.file].protectType == "Private") + item.disabled = true; } } - }) - data.datas.cmsDatas[0].datas.forEach(item => { - if (this.data.tabValue == 'jsek_teachingResources') { - item.checked = false - } else if (this.data.tabValue == 'jsek_cloudLearning') { - item.checked = false - item.isbuy = this.resourceIsBuy(item) - item.isShopCar = this.isShoppingCart(item) + }); + data.datas.cmsDatas[0].datas.forEach((item) => { + if (this.data.tabValue == "jsek_teachingResources") { + item.checked = false; + } else if (this.data.tabValue == "jsek_cloudLearning") { + item.checked = false; + item.isbuy = this.resourceIsBuy(item); + item.isShopCar = this.isShoppingCart(item); } - }) - return data.datas.cmsDatas[0].datas + }); + return data.datas.cmsDatas[0].datas; }, // 鑾峰彇灞曞紑椤� findChildIds(data, result) { - let index = 0 + let index = 0; for (let i = 0; i < data.length; i++) { if (index < 3) { - const item = data[i] + const item = data[i]; if (item.children && item.children.length > 0) { - result.push(item.id) + result.push(item.id); for (let j = 0; j < item.children.length; j++) { if (index < 3) { - const childrenItme = item.children[j] + const childrenItme = item.children[j]; if (item.children && item.children.length > 0) { - result.push(childrenItme.id) - index += 1 + result.push(childrenItme.id); + index += 1; } } else { - break + break; } } } else if (item.children && item.children.length > 0) { - result.push(item.id) - index += 1 + result.push(item.id); + index += 1; } } else { - break + break; } } }, @@ -821,281 +885,279 @@ // 鍥句功娣诲姞璐墿杞� async addBookShopcCar() { if (!this.data.expire) { - - - const shoppingCartGetId = [] - + const shoppingCartGetId = []; let query = { start: 0, size: 9999, filterList: [], - searchList: [] - } - const res = await app.MG.store.getShoppingCartProductList(query) + searchList: [], + }; + const res = await app.MG.store.getShoppingCartProductList(query); res.datas.forEach((item) => { - shoppingCartGetId.push(item.saleMethod.id) - }) - console.log(shoppingCartGetId, 'shoppingCartGetId'); - console.log(this.data.selectedIds, '閿�鍞柟寮廼d'); - const determine = shoppingCartGetId.some((item) => item == this.data.selectedIds) + shoppingCartGetId.push(item.saleMethod.id); + }); + console.log(shoppingCartGetId, "shoppingCartGetId"); + console.log(this.data.selectedIds, "閿�鍞柟寮廼d"); + const determine = shoppingCartGetId.some( + (item) => item == this.data.selectedIds + ); console.log(determine); if (!determine) { let query = { - requests: [{ - saleMethodId: this.data.selectedIds, - storeEventId: null, - agentCode: '鐢靛瓙涔�' - }] - } - const addRes = app.MG.store.addShoppingCart(query) - this.showSuccessToast() - console.log(addRes, 'addRes'); - wx.switchTab({ - url: '/pages/cart/index', - - }) - + 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', + selector: "#t-toast", + message: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞", + theme: "warning", + direction: "column", }); } } else { wx.showToast({ title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", - icon: 'none', + icon: "none", duration: 1000, - }) + }); } - - }, showSuccessToast() { Toast({ context: this, - selector: '#t-toast', - message: '娣诲姞鎴愬姛', - theme: 'success', - direction: 'column', + selector: "#t-toast", + message: "娣诲姞鎴愬姛", + theme: "success", + direction: "column", }); - }, async buyBook() { - console.log(this.data.bookItemDetail.defaultSaleMethodId, 'this.data.bookItemDetail.defaultSaleMethodId'); + console.log( + this.data.bookItemDetail.defaultSaleMethodId, + "this.data.bookItemDetail.defaultSaleMethodId" + ); if (!this.data.expire) { - let bookOrdersId = '' - let pBookInfo = { - type: "鐢靛瓙涔�", - pId: this.data.bookItemDetail ? this.data.bookDetail.id : '' - } + let bookOrdersId = ""; let query = { - remarks: JSON.stringify(pBookInfo), - requests: [{ - saleMethodId: this.data.bookItemDetail.defaultSaleMethodId ? this.data.bookItemDetail.defaultSaleMethodId : this.data.bookDetail.defaultSaleMethodId, - count: 1 - }] - } + remarks: "鐢靛瓙涔�", + requests: [ + { + saleMethodId: this.data.bookItemDetail.defaultSaleMethodId + ? this.data.bookItemDetail.defaultSaleMethodId + : this.data.bookDetail.defaultSaleMethodId, + count: 1, + }, + ], + }; // 鍙戣捣璁㈠崟鍒濆鍖栬姹傚苟绛夊緟缁撴灉 - const res = await app.MG.store.initOrder(query) + const res = await app.MG.store.initOrder(query); // 鑾峰彇璁㈠崟鍙峰苟璧嬪�肩粰 orderNumber.value - bookOrdersId = res.orderNumber + bookOrdersId = res.orderNumber; console.log(bookOrdersId); // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 if (bookOrdersId) { - const url = '/pages/cart/paymentPage/index?orderNumber=' + bookOrdersId + const url = "/pages/cart/paymentPage/index?orderNumber=" + bookOrdersId; wx.navigateTo({ - url - }) + url, + }); } else { console.log(222); } } else { wx.showToast({ title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", - icon: 'none', + icon: "none", duration: 1000, - }) + }); } }, // 鑾峰彇鏁欏璧勬簮涓嬭浇鏄惁鐢宠閫氳繃 async getApplyInfo(id) { // 鑾峰彇褰撳墠鏃堕棿 - const currentDate = new Date() + const currentDate = new Date(); let query = { sort: { - type: 'Desc', - field: 'CreateDate' + type: "Desc", + field: "CreateDate", }, start: 0, size: 99999, appRefCode: app.config.appRefCode, - topicIdOrRefCode: 'productDownLoad' - } + topicIdOrRefCode: "productDownLoad", + }; await app.MG.ugc.getTopicMessageList(query).then((res) => { const applyResource = res.datas.find((item) => { - let content = [] + let content = []; try { - content = JSON.parse(item.content) + content = JSON.parse(item.content); } catch (error) { - content = [] + content = []; } - if (Array.isArray(content)) return content.find((citem) => citem.id == id) - return false - }) + if (Array.isArray(content)) + return content.find((citem) => citem.id == id); + return false; + }); // 鏈夌敵璇疯褰� if (applyResource) { - if (applyResource.state == 'Reject') { + if (applyResource.state == "Reject") { this.setData({ rejectCause: JSON.parse(applyResource.feedBack).reason, - applyState: 'Reject' - }) - } else if (applyResource.state == 'Normal') { - const endDate = JSON.parse(applyResource.feedBack).endDate + applyState: "Reject", + }); + } else if (applyResource.state == "Normal") { + const endDate = JSON.parse(applyResource.feedBack).endDate; // const endDate = new Date(JSON.parse(applyResource.feedBack).endDate + ' 23:59:59').getTime() - if (endDate == '姘镐箙') { + if (endDate == "姘镐箙") { this.setData({ - applyState: 'Normal', - deadline: '姘镐箙', - }) - console.log('鏈夋晥鏃ユ湡', this.data.deadline); + applyState: "Normal", + deadline: "姘镐箙", + }); + console.log("鏈夋晥鏃ユ湡", this.data.deadline); } else { - - let endTime = new Date(endDate + ' 23:59:59').getTime() + let endTime = new Date(endDate + " 23:59:59").getTime(); this.setData({ - deadline: endDate + ' 23:59:59' - }) + deadline: endDate + " 23:59:59", + }); if (currentDate.getTime() < endTime) { // 鏈秴鏃� this.setData({ - applyState: 'Normal' - }) + applyState: "Normal", + }); } else { this.setData({ - applyState: 'none' - }) + applyState: "none", + }); } } } else { this.setData({ - applyState: applyResource.state - }) + applyState: applyResource.state, + }); } } else { this.setData({ - applyState: 'none' - }) + applyState: "none", + }); } - }) + }); this.setData({ applyResourceState: false, - }) - wx.hideLoading() + }); + wx.hideLoading(); }, // 鐢宠鏁欏璧勬簮 applyResource() { if (this.data.applyResourceState) { return wx.showToast({ - icon: 'error', - title: '璇峰嬁閲嶅鐐瑰嚮', - }) + icon: "error", + title: "璇峰嬁閲嶅鐐瑰嚮", + }); } this.setData({ - applyResourceState: true - }) - let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role + applyResourceState: true, + }); + let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role; if (role) { - if (role == 'Teacher') { + if (role == "Teacher") { wx.showLoading({ - title: '鍔犺浇涓�', - }) + title: "鍔犺浇涓�", + }); // 鐢宠鏁欏璧勬簮 let query = { - topicIdOrRefCode: 'productDownLoad', - type: 'applyForDownload', - state: 'WaitAudit', - cmsTypeRefCode: '', + topicIdOrRefCode: "productDownLoad", + type: "applyForDownload", + state: "WaitAudit", + cmsTypeRefCode: "", newDataListRequest: [], name: this.data.bookDetail.name, // name涓虹敵璇风殑涔︽湰鍚嶇О - content: JSON.stringify([{ - name: this.data.bookDetail.name, - id: this.data.bookDetail.id, - // defaultSaleMethodId: bookData.value.defaultSaleMethodId, - icon: this.data.bookDetail.icon - }]) - } + content: JSON.stringify([ + { + name: this.data.bookDetail.name, + id: this.data.bookDetail.id, + // defaultSaleMethodId: bookData.value.defaultSaleMethodId, + icon: this.data.bookDetail.icon, + }, + ]), + }; app.MG.ugc.newTopicMessage(query).then(async (res) => { if (res) { wx.showToast({ - title: '鐢宠宸叉彁浜�', + title: "鐢宠宸叉彁浜�", duration: 2000, - }) + }); } - await this.getApplyInfo(this.data.bookDetail.id) - }) + await this.getApplyInfo(this.data.bookDetail.id); + }); } else { wx.showModal({ - title: '灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�', - content: '璇峰厛杩涜鏁欏笀璁よ瘉锛�', + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", complete: (res) => { - if (res.cancel) {} + if (res.cancel) { + } if (res.confirm) { wx.navigateTo({ - url: '/packageDomain/pages/teacherCertification/index', - }) + url: "/packageDomain/pages/teacherCertification/index", + }); } - } - }) + }, + }); } } else { wx.showModal({ - title: '灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�', - content: '璇峰厛杩涜鏁欏笀璁よ瘉锛�', + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", complete: (res) => { - if (res.cancel) {} + if (res.cancel) { + } if (res.confirm) { wx.navigateTo({ - url: '/packageDomain/pages/teacherCertification/index', - }) + url: "/packageDomain/pages/teacherCertification/index", + }); } - } - }) + }, + }); } }, // 鏁欏璧勬簮涓嬭浇鍓嶅線PC鎻愮ずDiialog closeTeachDownload() { this.setData({ - isShowTeachDownload: false - }) + isShowTeachDownload: false, + }); }, // 涓嬭浇鍔熻兘 downloadTeach(e) { - let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role - if (role && role == 'Teacher') { + let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role; + if (role && role == "Teacher") { this.setData({ - isShowTeachDownload: true - }) + isShowTeachDownload: true, + }); } else { wx.showModal({ - title: '灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�', - content: '璇峰厛杩涜鏁欏笀璁よ瘉锛�', + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", complete: (res) => { if (res.cancel) { - } if (res.confirm) { wx.navigateTo({ - url: '/packageDomain/pages/teacherCertification/index', - }) + url: "/packageDomain/pages/teacherCertification/index", + }); } - } - }) + }, + }); } // const data = e.detail.value // // const data @@ -1191,33 +1253,35 @@ tempFilePath: res.tempFilePath, success: function (res) { wx.showToast({ - title: '涓嬭浇鎴愬姛', - icon: 'success' - }) + title: "涓嬭浇鎴愬姛", + icon: "success", + }); }, fail: function (res) { wx.showToast({ - title: '涓嬭浇澶辫触', - icon: 'none' - }) - } - }) + title: "涓嬭浇澶辫触", + icon: "none", + }); + }, + }); }, fail: function (res) { wx.showToast({ - title: '涓嬭浇澶辫触', - icon: 'none' - }) - } - }) + title: "涓嬭浇澶辫触", + icon: "none", + }); + }, + }); }, // 鍒ゆ柇璧勬簮鏄惁璐拱 resourceIsBuy(data) { if (data.saleMethod && data.saleMethod.length) { - const isSHow = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id) - return !isSHow + const isSHow = this.data.buyIdList.some( + (item) => item == data.saleMethod[0].Id + ); + return !isSHow; } else { - return false + return false; } }, // 鑾峰彇宸茶喘涔板晢鍝� @@ -1226,55 +1290,59 @@ start: 0, size: 999, filterList: [], - searchList: [] - } + searchList: [], + }; app.MG.store.getShoppingCartProductList(query).then((res) => { - const list = [] + const list = []; res.datas.forEach((item) => { - list.push(item.saleMethod.id) - }) + list.push(item.saleMethod.id); + }); this.setData({ shoppingList: res.datas, - shoppingCartGetId: list - }) - }) + shoppingCartGetId: list, + }); + }); }, // 鍒ゆ柇璧勬簮鍔犲叆璐墿杞︽寜閽槸鍚︽樉绀� isShoppingCart(data) { if (data.saleMethod && data.saleMethod.length) { - if (data.saleMethod[0].Price <= 0) return false + if (data.saleMethod[0].Price <= 0) return false; // 鍐嶅垽鏂槸鍚﹁喘涔� - const isBuy = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id) + const isBuy = this.data.buyIdList.some( + (item) => item == data.saleMethod[0].Id + ); if (isBuy) { // 璐拱浜� - return false + return false; } else { // 鍒ゆ柇鏄惁鍔犲叆璐墿杞� - const isSHow = this.data.shoppingCartGetId.some((item) => item == data.saleMethod[0].Id) - return !isSHow + const isSHow = this.data.shoppingCartGetId.some( + (item) => item == data.saleMethod[0].Id + ); + return !isSHow; } } else { - return false + return false; } }, // 閬嶅巻鏍戠粨鏋勮浆鎹负鏁扮粍鏂规硶 handleTreeData(array) { - const flattenedArray = [] + const flattenedArray = []; array.forEach((node) => { // 灏嗗綋鍓嶈妭鐐规坊鍔犲埌灞曞紑鐨勬暟缁勪腑 - flattenedArray.push(node) + flattenedArray.push(node); // 閫掑綊澶勭悊瀛愯妭鐐� if (node.children && node.children.length > 0) { - const childrenArray = this.handleTreeData(node.children) - flattenedArray.push(...childrenArray) + const childrenArray = this.handleTreeData(node.children); + flattenedArray.push(...childrenArray); } - }) - return flattenedArray.filter((item) => item.sysType == 'CmsItem') + }); + return flattenedArray.filter((item) => item.sysType == "CmsItem"); }, // 浜戝涔犱竴閿鍙� async getFreeResource() { - const child = this.selectComponent('#learn-resource') - const token = wx.getStorageSync(app.config.tokenKey) + const child = this.selectComponent("#learn-resource"); + const token = wx.getStorageSync(app.config.tokenKey); if (!token) { loginInfo(app, (data) => { // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� @@ -1283,95 +1351,99 @@ } else { // 鍑虹幇閿欒锛岃繑鍥瀎alse } - }) + }); } else { - let arr = this.handleTreeData(this.data.learn).filter((item) => this.resourceIsBuy(item)) + let arr = this.handleTreeData(this.data.learn).filter((item) => + this.resourceIsBuy(item) + ); let freeIds = arr.filter((item) => { - return item.saleMethod[0].Price == 0 - }) - debugger - if (!freeIds.length) return wx.showToast({ - icon: "error", - title: '鏆傛棤鍏嶈垂璧勬簮', - }) - child.changeReceive(true) - let requests = [] + return item.saleMethod[0].Price == 0; + }); + if (!freeIds.length) + return wx.showToast({ + icon: "error", + title: "鏆傛棤鍏嶈垂璧勬簮", + }); + child.changeReceive(true); + let requests = []; freeIds.forEach((item, index) => { if (this.resourceIsBuy(item)) { requests.push({ saleMethodId: item.saleMethod[0].Id, - count: 1 - }) + count: 1, + }); } - }) - debugger + }); let query = { - remarks: '浜戝涔�', + remarks: "浜戝涔�", requests, - } + }; try { - const initOrderRes = await app.MG.store.initOrder(query) + const initOrderRes = await app.MG.store.initOrder(query); let parameter = { - orderNum: initOrderRes.orderNumber - } + orderNum: initOrderRes.orderNumber, + }; // 纭璁㈠崟 - const confirmOrderRes = await app.MG.store.confirmOrder(parameter) + const confirmOrderRes = await app.MG.store.confirmOrder(parameter); if (confirmOrderRes.orderNumber) { - child.changeReceive(false) + child.changeReceive(false); wx.showToast({ - title: '棰嗗彇鎴愬姛', - }) - this.getBookInfo(this.data.bookId) + title: "棰嗗彇鎴愬姛", + }); + this.getBookInfo(this.data.bookId); } } catch (error) { - console.log(error) + console.log(error); } } }, // 浜戝涔犱竴閿喘涔� async allAddShoppiingCar() { - const child = this.selectComponent('#learn-resource') - const token = wx.getStorageSync('jsek-token') + const child = this.selectComponent("#learn-resource"); + const token = wx.getStorageSync("jsek-token"); if (!token) { return wx.getUserProfile({ - desc: '鐢ㄦ埛鐧诲綍', + desc: "鐢ㄦ埛鐧诲綍", success: (res) => { console.log(res); - } - }) + }, + }); } - let shopList = this.handleTreeData(this.data.learn).filter((item) => this.resourceIsBuy(item)) - this.getShoppingCartProductGet() - if (!shopList.length) return wx.showToast({ - icon: "error", - title: '宸插叏閮ㄨ喘涔�', - }) - child.changeBuy(true) - let requests = [] + let shopList = this.handleTreeData(this.data.learn).filter((item) => + this.resourceIsBuy(item) + ); + this.getShoppingCartProductGet(); + if (!shopList.length) + return wx.showToast({ + icon: "error", + title: "宸插叏閮ㄨ喘涔�", + }); + child.changeBuy(true); + let requests = []; shopList.forEach((item) => { requests.push({ saleMethodId: item.saleMethod[0].Id, count: 1, - }) - }) + }); + }); let query = { - remarks: '浜戝涔�', + remarks: "浜戝涔�", requests, - } - const initOrderRes = await app.MG.store.initOrder(query) - child.changeBuy(false) + }; + const initOrderRes = await app.MG.store.initOrder(query); + child.changeBuy(false); // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 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: '璇烽噸璇�', - }) + title: "璇烽噸璇�", + }); } }, // 鍙樹负鎵�鏈塩heck true @@ -1398,145 +1470,196 @@ // 缁勫嵎鏍煎紡鍖栨棩鏈熸樉绀� DateFormat(date, fmt) { if (date && fmt) { - let _date = new Date(date) + let _date = new Date(date); var o = { - 'M+': _date.getMonth() + 1, //鏈堜唤 - 'd+': _date.getDate(), //鏃� - 'h+': _date.getHours(), //灏忔椂 - 'm+': _date.getMinutes(), //鍒� - 's+': _date.getSeconds(), //绉� - 'q+': Math.floor((_date.getMonth() + 3) / 3), //瀛e害 - S: _date.getMilliseconds() //姣 - } + "M+": _date.getMonth() + 1, //鏈堜唤 + "d+": _date.getDate(), //鏃� + "h+": _date.getHours(), //灏忔椂 + "m+": _date.getMinutes(), //鍒� + "s+": _date.getSeconds(), //绉� + "q+": Math.floor((_date.getMonth() + 3) / 3), //瀛e害 + S: _date.getMilliseconds(), //姣 + }; if (/(y+)/.test(fmt)) { - fmt = fmt.replace(RegExp.$1, (_date.getFullYear() + '').substr(4 - RegExp.$1.length)) + fmt = fmt.replace( + RegExp.$1, + (_date.getFullYear() + "").substr(4 - RegExp.$1.length) + ); } for (var k in o) { - if (new RegExp('(' + k + ')').test(fmt)) { + if (new RegExp("(" + k + ")").test(fmt)) { fmt = fmt.replace( RegExp.$1, - RegExp.$1.length == 1 ? - (o)[k] : - ('00' + (o)[k]).substr(('' + (o)[k]).length) - ) + RegExp.$1.length == 1 + ? o[k] + : ("00" + o[k]).substr(("" + o[k]).length) + ); } } - return fmt + return fmt; } else { - return '' + return ""; } }, // 鑾峰彇缁勫嵎绛旈鏁版嵁 getMockData() { this.setData({ - 'mockData.useCount': 0, - 'mockData.mockList': [] - }) + "mockData.useCount": 0, + "mockData.mockList": [], + }); app.MG.identity .getUserKey({ - domain: 'mockData', - keys: [this.data.bookId] + domain: "mockData", + keys: [this.data.bookId], }) .then((res) => { if (res && res.length) { - const mock = JSON.parse(res[0].value) - mock.forEach(item => { - item.createDate = this.DateFormat(item.createDate, 'yyyy-MM-dd') - }) + const mock = JSON.parse(res[0].value); + mock.forEach((item) => { + item.createDate = this.DateFormat(item.createDate, "yyyy-MM-dd"); + }); this.setData({ - 'mockData.mockList': mock - }) + "mockData.mockList": mock, + }); // 缁勫嵎宸蹭娇鐢ㄦ鏁� res.forEach((item) => { // 宸茬粡鏈夌瓟棰樺垎鏁扮瓑鏁版嵁锛岃瘉鏄庣粍鍗峰凡缁忎娇鐢ㄥ畬姣� if (item.resultData) { this.setData({ - 'mockData.useCount': this.data.mockData.useCount + 1 - }) + "mockData.useCount": this.data.mockData.useCount + 1, + }); } - }) + }); } - }) + }); }, // 璐拱缁勫嵎 async buyMock() { - let res - if (!this.data.mockData.id) return wx.showToast({ - icon: "error", - title: '鏆傛棤缁勫嵎', - mask: true - }) + 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 - }] - } + remarks: "缁勫嵎", + requests: [ + { + saleMethodId: this.data.mockData.id, + count: 1, + }, + ], + }; if (this.data.flag) { this.setData({ - flag: false - }) - res = await app.MG.store.initOrder(query) + flag: false, + }); + 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 - }) + orderNum: res.orderNumber, + }); if (confirmOrderRes) { wx.showToast({ icon: "success", - title: '棰嗗彇鎴愬姛', - }) + title: "棰嗗彇鎴愬姛", + }); this.setData({ - flag: true - }) - await this.recordBuyMock() // 璁板綍璐拱鏃堕棿 + flag: true, + }); + await this.recordBuyMock(); // 璁板綍璐拱鏃堕棿 } } } catch (error) { - console.log(error) + console.log(error); } }, // 璁板綍璐拱缁勫嵎鏃堕棿 recordBuyMock() { - const num = this.data.mockData.mockList.length - const id = tool.uuid(8) - const createDate = this.DateFormat(new Date().getTime(), 'yyyy-MM-dd') - const mockList = this.data.mockData.mockList + const num = this.data.mockData.mockList.length; + const id = tool.uuid(8); + const createDate = this.DateFormat(new Date().getTime(), "yyyy-MM-dd"); + const mockList = this.data.mockData.mockList; mockList.push({ id, createDate, name: `绗�${num + 1}濂楄瘯鍗穈, - state: '0' - }) + state: "0", + }); this.setData({ - 'mockData.mockList': mockList - }) + "mockData.mockList": mockList, + }); // 璁板綍璐拱鏃堕棿锛屽苟璁剧姸鎬乻tate涓�1锛岃〃绀哄垰璐拱瀹屾垚缁勫嵎 app.MG.identity.setUserKey({ - setKeyRequests: [{ - domain: 'mockData', - key: this.data.bookDetail.id + '', - value: JSON.stringify(this.data.mockData.mockList) - }] - }) + setKeyRequests: [ + { + domain: "mockData", + key: this.data.bookDetail.id + "", + value: JSON.stringify(this.data.mockData.mockList), + }, + ], + }); + }, + // 鑾峰彇鐩稿叧鍥句功 + getAboutBook(path) { + // loadings.value.aboutBook = true + let query = { + path, + queryType: "*", + coverSize: { + height: 243, + }, + paging: { + start: 0, + size: 99, + }, + fields: { + author: [], + publicationDate: [], + }, + }; + app.MG.store.getProductList(query).then((res) => { + console.log("瀹屾暣鐩稿叧鍥句功", res.datas); + const Arr = res.datas.filter( + (item) => item.id != this.data.bookDetail.id + ); + let bookArr = []; + if (Arr.length) { + if (Arr.length > 3) { + for (var i = 0; i < 3; i++) { + var _num = Math.floor(Math.random() * Arr.length); + var mm = Arr[_num]; + Arr.splice(_num, 1); + bookArr.push(mm); + } + } else { + bookArr = Arr; + } + this.setData({ + relatedBookData: bookArr, + }); + console.log("鐩稿叧鍥句功", this.data.relatedBookData); + } + }); + // loadings.value.aboutBook = false }, // 搴曢儴璐拱鎸夐挳 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() + 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); } @@ -1545,16 +1668,27 @@ goRead() { if (!this.data.noFile) { wx.showToast({ - title: '鏆傛棤闃呰鏂囦欢', - icon: 'none', - duration: 2000 - }) + 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=' + this.data.bookBuy + '&bookId=' + this.data.bookDetail.id - }) - + 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, + }); }, //鏍蜂功鐢宠 @@ -1563,114 +1697,119 @@ const data = { start: 0, size: 9999, - topicIdOrRefCode: 'applyEntityBook', + topicIdOrRefCode: "applyEntityBook", appRefCode: app.config.appRefCode, sort: { - type: 'Desc', - field: 'CreateDate' - } - } + type: "Desc", + field: "CreateDate", + }, + }; app.MG.ugc.getTopicMessageList(data).then((res) => { let list = []; res.datas.map((item) => { if (item.content) { - item.content = JSON.parse(item.content) + item.content = JSON.parse(item.content); } - list.push(item) - }) + list.push(item); + }); this.setData({ alreadyPaperBookList: list, }); - }) + }); }, //鑾峰彇宸茬敵璇风數瀛愭牱涔� getAlreadyEBookList() { const data = { start: 0, size: 9999, - topicIdOrRefCode: 'applyBook', + topicIdOrRefCode: "applyBook", appRefCode: app.config.appRefCode, sort: { - type: 'Desc', - field: 'CreateDate' - } - } + type: "Desc", + field: "CreateDate", + }, + }; app.MG.ugc.getTopicMessageList(data).then((res) => { - let list = [] + let list = []; if (res.datas.length > 0) { res.datas.map((item) => { if (item.feedBack) { - item.feedBack = JSON.parse(item.feedBack) + item.feedBack = JSON.parse(item.feedBack); if (item.feedBack.endDate) { - let times = new Date(item.feedBack.endDate + ' 23:59:59').getTime() - let currentDate = new Date().getTime() + let times = new Date( + item.feedBack.endDate + " 23:59:59" + ).getTime(); + let currentDate = new Date().getTime(); if (times < currentDate) { - item.isExpiry = true + item.isExpiry = true; } } } if (item.content) { - item.content = JSON.parse(item.content) + item.content = JSON.parse(item.content); } - if (item.state != 'Reject') { - list.push(item) + if (item.state != "Reject") { + list.push(item); } - }) + }); this.setData({ alreadyElectronicBookList: list, }); } - }) + }); }, //鑾峰彇褰撳墠宸茬敵璇锋鏁帮紙绾歌川锛� getSelectPaperBookCount() { app.MG.app .getTicketResult({ - ticketRefCodeOrGuid: 'paperSampleBookapplyNum', - roleId: this.data.userInfo.roleId + ticketRefCodeOrGuid: "paperSampleBookapplyNum", + roleId: this.data.userInfo.roleId, }) .then((res) => { this.setData({ - paperBookCount: res.totalCount - res.usedCount - }) - }) + paperBookCount: res.totalCount - res.usedCount, + }); + }); }, //鑾峰彇褰撳墠宸茬敵璇锋鏁帮紙鐢靛瓙锛� getSelectBookCount() { app.MG.app .getTicketResult({ - ticketRefCodeOrGuid: 'electronicSampleBookapplyNum', - roleId: this.data.userInfo.roleId + ticketRefCodeOrGuid: "electronicSampleBookapplyNum", + roleId: this.data.userInfo.roleId, }) .then((res) => { this.setData({ - ebookCount: res.totalCount - res.usedCount - }) - }) + ebookCount: res.totalCount - res.usedCount, + }); + }); }, //鐢宠鐢靛瓙鏍蜂功 appplyElectronicBook() { - console.log(this.data.bookDetail) - if (this.data.bookDetail.isApplyBook == 2 || this.data.bookDetail.isApplyBook == 4) { - let role = this.data.userInfo != null ? this.data.userInfo.role : null + console.log(this.data.bookDetail); + if ( + this.data.bookDetail.isApplyBook == 2 || + this.data.bookDetail.isApplyBook == 4 + ) { + let role = this.data.userInfo != null ? this.data.userInfo.role : null; if (role) { - if (role == 'Teacher') { + if (role == "Teacher") { if (!this.data.noFile) { wx.showToast({ title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!", - icon: 'none', + icon: "none", duration: 1000, - }) - return + }); + return; } if (this.data.ebookCount == 0) { wx.showToast({ title: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", icon: "none", duration: 1000, - }) + }); return false; } if (this.data.electronicBookList.length >= 2) { @@ -1678,63 +1817,71 @@ title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", icon: "none", duration: 1000, - }) + }); return false; } - let isHas = this.data.electronicBookList.find((eitem) => eitem.id == this.data.bookDetail.id) + 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.id == this.data.bookDetail.id) + let isApply = this.data.alreadyElectronicBookList.find( + (eitem) => eitem.id == this.data.bookDetail.id + ); if (isApply) { wx.showToast({ title: "璇ヤ功宸茬敵璇凤紒", icon: "none", duration: 1000, - }) + }); return false; } - this.addBookFun(this.data.bookDetail, "eBook") + this.addBookFun(this.data.bookDetail, "eBook"); } else { wx.showModal({ - title: '灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�', //鎻愮ず鐨勬爣棰� - content: '璇峰厛杩涜鏁欏笀璁よ瘉锛�', //鎻愮ず鐨勫唴瀹� + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� success: function (res) { if (res.confirm) { wx.navigateTo({ url: "/packageDomain/pages/teacherCertification/index", }); - } else if (res.cancel) {} - } - }) + } else if (res.cancel) { + } + }, + }); } } } else { wx.showToast({ title: "璇ヤ功涓嶈兘鐢宠鐢靛瓙鏍蜂功", - icon: 'none', + icon: "none", duration: 1000, - }) + }); } }, //鐢宠绾歌川鏍蜂功 appplyPaperBook() { - if (this.data.bookDetail.isApplyBook == 3 || this.data.bookDetail.isApplyBook == 4) { - let role = this.data.userInfo != null ? this.data.userInfo.role : null + if ( + this.data.bookDetail.isApplyBook == 3 || + this.data.bookDetail.isApplyBook == 4 + ) { + let role = this.data.userInfo != null ? this.data.userInfo.role : null; if (role) { - if (role == 'Teacher') { + if (role == "Teacher") { // 鐐瑰嚮閫変腑 if (this.data.paperBookCount == 0) { wx.showToast({ title: "鎮ㄧ殑绾歌川鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", icon: "none", duration: 1000, - }) + }); return false; } if (this.data.paperBookList.length >= 2) { @@ -1742,88 +1889,93 @@ title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", icon: "none", duration: 1000, - }) + }); return false; } - let isHas = this.data.paperBookList.find((pitem) => pitem.id == this.data.bookDetail.id) + let isHas = this.data.paperBookList.find( + (pitem) => pitem.id == this.data.bookDetail.id + ); if (isHas) { wx.showToast({ title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", icon: "none", duration: 1000, - }) + }); return false; } - let isApply = this.data.alreadyPaperBookList.find((pitem) => pitem.id == this.data.bookDetail.id) + let isApply = this.data.alreadyPaperBookList.find( + (pitem) => pitem.id == this.data.bookDetail.id + ); if (isApply) { wx.showToast({ title: "璇ヤ功宸茬敵璇凤紒", icon: "none", duration: 1000, - }) + }); return false; } - this.addBookFun(this.data.bookDetail, "pBook") + this.addBookFun(this.data.bookDetail, "pBook"); } else { wx.showModal({ - title: '灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�', //鎻愮ず鐨勬爣棰� - content: '璇峰厛杩涜鏁欏笀璁よ瘉锛�', //鎻愮ず鐨勫唴瀹� + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� success: function (res) { if (res.confirm) { wx.navigateTo({ url: "/packageDomain/pages/teacherCertification/index", }); - } else if (res.cancel) {} - } - }) + } else if (res.cancel) { + } + }, + }); } } } else { wx.showToast({ title: "璇ヤ功涓嶈兘鐢宠绾歌川鏍蜂功", - icon: 'none', + icon: "none", duration: 1000, - }) + }); } }, // 娣诲姞鏍蜂功 addBookFun(item, type) { - let itemAttr = null + let itemAttr = null; const eList = this.data.electronicBookList; const pList = this.data.paperBookList; itemAttr = { id: item.id, - title: item.name || '-', + title: item.name || "-", icon: item.icon, checked: false, defaultSaleMethodId: item.defaultSaleMethodId, md5: item.datas.Icon, - author: item.author || '-', - price: item.price || '-', - isbn: item.isbn || '-', - publicationDate: item.publicationDate - } - if (type == 'eBook') { - eList.push(itemAttr) + author: item.author || "-", + price: item.price || "-", + isbn: item.isbn || "-", + publicationDate: item.publicationDate, + }; + if (type == "eBook") { + eList.push(itemAttr); this.setData({ electronicBookList: eList, - }) + }); wx.setStorageSync("electronicBookList", eList); } else { - pList.push(itemAttr) + pList.push(itemAttr); this.setData({ paperBookList: pList, - }) + }); wx.setStorageSync("paperBookList", pList); } this.setData({ - num: this.data.num + 1 - }) + num: this.data.num + 1, + }); wx.showToast({ title: "娣诲姞鎴愬姛锛屽湪鏍蜂功鐢宠鍗曠瓑鎮ㄥ摝~", icon: "none", duration: 1000, - }) + }); }, //鍘绘牱涔︾敵璇峰崟 @@ -1834,28 +1986,29 @@ }, handleTree() { // const child = this.selectComponent('#teach-tree') - let tree + let tree; // let openIds = child.data.openIds - if (this.data.tabValue == 'jsek_teachingResources') { - tree = this.data.teach + if (this.data.tabValue == "jsek_teachingResources") { + tree = this.data.teach; } else { - tree = this.data.learn + tree = this.data.learn; } for (let index = 0; index < tree.length; index++) { const item = tree[index]; if (item.children && item.children.length > 0) { - const num = this.data.openTeachids.findIndex(citem => item.id == citem) + const num = this.data.openTeachids.findIndex( + (citem) => item.id == citem + ); if (num >= 0) { - item.open = true + item.open = true; } else { - item.open = false + item.open = false; } - this.handleTree(item.children) + this.handleTree(item.children); } } this.setData({ - teach: tree - }) + teach: tree, + }); }, - -}) \ No newline at end of file +}); diff --git a/packageBookService/pages/bookServices/detail/index.json b/packageBookService/pages/bookServices/detail/index.json index ebf04fd..44199c1 100644 --- a/packageBookService/pages/bookServices/detail/index.json +++ b/packageBookService/pages/bookServices/detail/index.json @@ -10,6 +10,7 @@ "teach-resource": "/packageBookService/pages/bookServices/detail/components/teachResource/index", "learn-resource": "/packageBookService/pages/bookServices/detail/components/learnResource/learnResource", "test-resource": "/packageBookService/pages/bookServices/detail/components/testResource/testResource", + "related-books": "/packageBookService/pages/bookServices/detail/components/relatedBooks/index", "note": "/packageBookService/pages/bookServices/detail/components/note/note", "tree": "/packageBookService/pages/bookServices/detail/components/tree/index", "suggest": "/packageBookService/pages/bookServices/detail/components/suggest/suggest", diff --git a/packageBookService/pages/bookServices/detail/index.wxml b/packageBookService/pages/bookServices/detail/index.wxml index 1461b12..981e948 100644 --- a/packageBookService/pages/bookServices/detail/index.wxml +++ b/packageBookService/pages/bookServices/detail/index.wxml @@ -4,30 +4,55 @@ <view style="width: 100%; height: {{barHeight}}px; "></view> <view class="nacigationBar" style="width: 70%; height: {{navBarHeight}}px;"> <view> - <t-icon name="chevron-left" size="30" data-name="{{item}}" bind:click="goBack" /> + <t-icon + name="chevron-left" + size="30" + data-name="{{item}}" + bind:click="goBack" + /> </view> <view class="navbar-title">{{options.name}}</view> </view> <t-toast id="t-toast" /> - <scroll-view scroll-y="{{true}}" class="book" bindscrolltolower="onReachBottom"> + <scroll-view + scroll-y="{{true}}" + class="book" + bindscrolltolower="onReachBottom" + > <!-- 鍥句功璇︽儏 --> <view class="book-box"> <view class="book-detail"> <view class="detail-left"> <view class="book-img"> - <image loading="" src="{{bookDetail.icon ? bookDetail.icon : '/static/images/default-book-img.png'}}" mode="aspectFill" aria-label="{{bookDetail.name}}" /> + <image + loading="" + src="{{bookDetail.icon ? bookDetail.icon : '/static/images/default-book-img.png'}}" + mode="aspectFill" + aria-label="{{bookDetail.name}}" + /> </view> <view class="book-use"> <view class="collect" bind:tap="setCollect"> <view> - <image loading="" src="/static/images/bookService/detail/collect.png" wx:if="{{!bookDetail.isFavourite}}" /> - <image loading="" src="/static/images/bookService/detail/collecting.png" wx:if="{{bookDetail.isFavourite}}" /> + <image + loading="" + src="/static/images/bookService/detail/collect.png" + wx:if="{{!bookDetail.isFavourite}}" + /> + <image + loading="" + src="/static/images/bookService/detail/collecting.png" + wx:if="{{bookDetail.isFavourite}}" + /> </view> <view class="use-title">鏀惰棌</view> </view> <view class="suggest" bind:tap="suggestBtn"> <view> - <image loading="" src="/static/images/bookService/detail/suggest.png" /> + <image + loading="" + src="/static/images/bookService/detail/suggest.png" + /> </view> <view class="use-title">鎴戣寤鸿</view> </view> @@ -49,15 +74,24 @@ <view class="li-content">{{bookDetail.isbn}}</view> </view> <view class="message-li"> - <view class="li-title" wx:if="{{bookDetail.publicationDate}}">鍑虹増鏃堕棿锛�</view> + <view class="li-title" wx:if="{{bookDetail.publicationDate}}" + >鍑虹増鏃堕棿锛�</view + > <view class="li-content">{{bookDetail.publicationDate}}</view> </view> - <view class="message-li" wx:if="{{bookDetail.class}}" style="height: 80rpx"> + <view + class="message-li" + wx:if="{{bookDetail.class}}" + style="height: 80rpx" + > <view class="li-title">鍥句功鍒嗙被锛�</view> <view class="class-name showTow">{{bookDetail.class}}</view> </view> </view> - <image src="/static/images/bookService/detail/square.png" class="right-background" /> + <image + src="/static/images/bookService/detail/square.png" + class="right-background" + /> </view> </view> <!-- 閿�鍞俊鎭� --> @@ -66,12 +100,17 @@ <!-- 鐢靛瓙涔﹀敭浠� --> <view class="electron-price" wx:if="{{bookDetail.price}}"> <view> - <image src="/static/images/bookService/detail/electon-price.png" /> + <image + src="/static/images/bookService/detail/electon-price.png" + /> </view> <view class="price"> - <view class="price-text">{{bookDetail.price == '0.00' ? '鍏嶈垂' : '楼'+ - bookDetail.price}}</view> - <view class="price-old" wx:if="{{bookDetail.oldPrice != '0.00'}}">楼{{bookDetail.oldPrice}} + <view class="price-text" + >{{bookDetail.price == '0.00' ? '鍏嶈垂' : '楼'+ + bookDetail.price}}</view + > + <view class="price-old" wx:if="{{bookDetail.oldPrice != '0.00'}}" + >楼{{bookDetail.oldPrice}} </view> </view> <view> </view> @@ -81,24 +120,66 @@ <view> <image src="/static/images/bookService/detail/paper-price.png" /> </view> - <view class="price">{{bookDetail.paperPrice == '0.00' ? '鍏嶈垂' : - '楼'+bookDetail.paperPrice}}</view> + <view class="price" + >{{bookDetail.paperPrice == '0.00' ? '鍏嶈垂' : + '楼'+bookDetail.paperPrice}}</view + > </view> </view> <!-- 缃戝簵 --> <view class="book-web"> - <image src="/static/images/bookService/detail/jd.png" wx:if="{{bookDetail.JDLink}}" bind:tap="goShop" data-link="{{bookDetail.JDLink}}" data-type="jd" /> - <image class="tmall-image" src="/static/images/bookService/detail/tmall.png" bind:tap="goShop" data-link="{{bookDetail.tmallLink}}" wx:if="{{bookDetail.tmallLink}}" /> - <image src="/static/images/bookService/detail/dangdang.png" bind:tap="goShop" data-link="{{bookDetail.dangdangLink}}" wx:if="{{bookDetail.dangdangLink}}" /> - <image src="/static/images/bookService/detail/weidian.png" bind:tap="goShop" data-link="{{bookDetail.weidianLink}}" wx:if="{{bookDetail.weidianLink}}" /> + <image + src="/static/images/bookService/detail/jd.png" + wx:if="{{bookDetail.JDLink}}" + bind:tap="goShop" + data-link="{{bookDetail.JDLink}}" + data-type="jd" + /> + <image + class="tmall-image" + src="/static/images/bookService/detail/tmall.png" + bind:tap="goShop" + data-link="{{bookDetail.tmallLink}}" + wx:if="{{bookDetail.tmallLink}}" + /> + <image + src="/static/images/bookService/detail/dangdang.png" + bind:tap="goShop" + data-link="{{bookDetail.dangdangLink}}" + wx:if="{{bookDetail.dangdangLink}}" + /> + <image + src="/static/images/bookService/detail/weidian.png" + bind:tap="goShop" + data-link="{{bookDetail.weidianLink}}" + wx:if="{{bookDetail.weidianLink}}" + /> </view> </view> </view> <view class="book-resource"> - <t-tabs defaultValue="{{tabValue}}" bind:change="onTabsChange" t-class="custom-tabs" t-class-content="custom-panel" class="tab-class"> - <t-tab-panel label="鍥句功绠�浠�" icon="{{ tabValue == 'brief' ? briefIconClick : briefIcon}}" value="brief" style="{{tabPanelstyle}}"> - <book-brief content="{{bookDetail.content}}" authorIntroduction="{{bookDetail.authorIntroduction}}" wx:if="{{bookDetail.content || bookDetail.authorIntroduction}}"></book-brief> - <view wx:if="{{!bookDetail.content && !bookDetail.authorIntroduction}}" class="noData"> + <t-tabs + defaultValue="{{tabValue}}" + bind:change="onTabsChange" + t-class="custom-tabs" + t-class-content="custom-panel" + class="tab-class" + > + <t-tab-panel + label="鍥句功绠�浠�" + icon="{{ tabValue == 'brief' ? briefIconClick : briefIcon}}" + value="brief" + style="{{tabPanelstyle}}" + > + <book-brief + content="{{bookDetail.content}}" + authorIntroduction="{{bookDetail.authorIntroduction}}" + wx:if="{{bookDetail.content || bookDetail.authorIntroduction}}" + ></book-brief> + <view + wx:if="{{!bookDetail.content && !bookDetail.authorIntroduction}}" + class="noData" + > <t-empty icon="folder-open" description="鏆傛棤鏁版嵁" /> </view> </t-tab-panel> @@ -109,44 +190,132 @@ style="{{tabPanelstyle}}" > </t-tab-panel> --> - <t-tab-panel label="鏁欏璧勬簮" icon="{{tabValue == 'jsek_teachingResources' ? teachResourcesClickIcon : teachResourcesIcon}}" value="jsek_teachingResources" class="{{loading ? 'loading': ''}}"> - <view wx:if="{{!loading && teach.length && !noResources && applyState}}"> - <teach-resource applyState="{{applyState}}" rejectCause="{{rejectCause}}" deadline="{{deadline}}" bind:applyResource="applyResource" applyResourceLoading="{{applyResourceLoading}}"></teach-resource> - <tree id="teach-tree" openIds="{{openTeachids}}" bookInfo="{{bookDetail}}" treeList="{{teach}}" tab="{{tabValue}}" applyState="{{applyState}}" bind:downloadTeach="downloadTeach" bind:handleTree="handleTree" openTeachids="{{openTeachids}}" wx:if="{{teach.length}}"></tree> + <t-tab-panel + label="鏁欏璧勬簮" + icon="{{tabValue == 'jsek_teachingResources' ? teachResourcesClickIcon : teachResourcesIcon}}" + value="jsek_teachingResources" + class="{{loading ? 'loading': ''}}" + > + <view + wx:if="{{!loading && teach.length && !noResources && applyState}}" + > + <teach-resource + applyState="{{applyState}}" + rejectCause="{{rejectCause}}" + deadline="{{deadline}}" + bind:applyResource="applyResource" + applyResourceLoading="{{applyResourceLoading}}" + ></teach-resource> + <tree + id="teach-tree" + openIds="{{openTeachids}}" + bookInfo="{{bookDetail}}" + treeList="{{teach}}" + tab="{{tabValue}}" + applyState="{{applyState}}" + bind:downloadTeach="downloadTeach" + bind:handleTree="handleTree" + openTeachids="{{openTeachids}}" + wx:if="{{teach.length}}" + ></tree> </view> - <t-loading theme="circular" size="60rpx" class="loading" loading="{{loading }}" /> + <t-loading + theme="circular" + size="60rpx" + class="loading" + loading="{{loading }}" + /> <view wx:if="{{noResources}}" class="noData"> <t-empty icon="folder-open" description="鏆傛棤鏁版嵁" /> </view> </t-tab-panel> - <t-tab-panel label="浜戝涔�" icon="{{tabValue == 'jsek_cloudLearning' ? learnResourceClickIcon : learnResourceIcon}}" value="jsek_cloudLearning" style="{{tabPanelstyle}}"> + <t-tab-panel + label="浜戝涔�" + icon="{{tabValue == 'jsek_cloudLearning' ? learnResourceClickIcon : learnResourceIcon}}" + value="jsek_cloudLearning" + style="{{tabPanelstyle}}" + > <view wx:if="{{!loading && learn.length}}"> - <learn-resource bind:getFreeResource="getFreeResource" bind:allAddShoppiingCar="allAddShoppiingCar" id="learn-resource" buyResourceData="{{buyResourceData}}" bookId="{{bookDetail.id}}"></learn-resource> - <tree id="tree" openIds="{{openLearnids}}" bookInfo="{{bookDetail}}" tab="{{tabValue}}" treeList="{{learn}}" buyIds="{{buyIdList}}" openLearnids="{{openLearnids}}"></tree> + <learn-resource + bind:getFreeResource="getFreeResource" + bind:allAddShoppiingCar="allAddShoppiingCar" + id="learn-resource" + buyResourceData="{{buyResourceData}}" + bookId="{{bookDetail.id}}" + isshowDrawBtn="{{isshowDrawBtn}}" + ></learn-resource> + <tree + id="tree" + openIds="{{openLearnids}}" + bookInfo="{{bookDetail}}" + tab="{{tabValue}}" + treeList="{{learn}}" + buyIds="{{buyIdList}}" + openLearnids="{{openLearnids}}" + ></tree> </view> <view wx:if="{{noResources}}" class="noData"> <t-empty icon="folder-open" description="鏆傛棤鏁版嵁" /> </view> </t-tab-panel> - <t-tab-panel label="浜戞祴璇�" icon="{{tabValue == 'questionBank' ? testResourceClickIocn : testResourceIocn}}" value="questionBank" style="{{tabPanelstyle}}"> + <t-tab-panel + label="浜戞祴璇�" + icon="{{tabValue == 'questionBank' ? testResourceClickIocn : testResourceIocn}}" + value="questionBank" + style="{{tabPanelstyle}}" + > <view wx:if="{{!loading}}"> - <test-resource list="{{test}}" bookInfo="{{bookDetail}}" mockData="{{mockData}}" bind:buyMock="buyMock"></test-resource> + <test-resource + list="{{test}}" + bookInfo="{{bookDetail}}" + mockData="{{mockData}}" + bind:buyMock="buyMock" + ></test-resource> </view> </t-tab-panel> - <t-tab-panel label="浜戠瑪璁�" icon="{{tabValue == 'jsek_note' ? noteClickIcon: noteIcon}}" value="jsek_note" style="{{tabPanelstyle}}"> + <t-tab-panel + label="浜戠瑪璁�" + icon="{{tabValue == 'jsek_note' ? noteClickIcon: noteIcon}}" + value="jsek_note" + style="{{tabPanelstyle}}" + > <note bookInfo="{{bookDetail}}" id="note" class="note-list"></note> + </t-tab-panel> + <t-tab-panel + label="鐩稿叧鍥句功" + icon="{{tabValue == 'related_books' ? linkClickIcon: linkIcon}}" + value="related_books" + style="{{tabPanelstyle}}" + > + <related-books relatedBookData="{{relatedBookData}}"></related-books> </t-tab-panel> </t-tabs> </view> </scroll-view> <!-- 鎴戣寤鸿寮圭獥 --> - <suggest class="suggest-component" id="suggest-component" bookIcon="{{bookDetail.icon}}" bookName="{{bookDetail.name}}"></suggest> + <suggest + class="suggest-component" + id="suggest-component" + bookIcon="{{bookDetail.icon}}" + bookName="{{bookDetail.name}}" + ></suggest> <!-- 鏁欏璧勬簮涓嬭浇鎻愮ず寮圭獥 --> - <t-dialog class="teachDownloadDialog" visible="{{isShowTeachDownload}}" title="鎻愮ず" content="璇峰墠寰�PC绔笅杞�" confirm-btn="{{ confirmBtn }}" bind:confirm="closeTeachDownload" /> + <t-dialog + class="teachDownloadDialog" + visible="{{isShowTeachDownload}}" + title="鎻愮ず" + content="璇峰墠寰�PC绔笅杞�" + confirm-btn="{{ confirmBtn }}" + bind:confirm="closeTeachDownload" + /> <view class="applyBox" bindtap="goApply"> <view class="box"> - <t-image src="/static/images/home/yangshuForm1.png" mode="heightFix" class="img" /> + <t-image + src="/static/images/home/yangshuForm1.png" + mode="heightFix" + class="img" + /> <view class="num" wx:if="{{num > 0}}">{{num}}</view> </view> </view> @@ -154,13 +323,18 @@ <view class="box-bottom"> <view class="bottom-btn" bind:tap="appplyElectronicBook"> <view> - <t-image loading="" src="/static/images/bookService/detail/ebook.png"></t-image> + <t-image + loading="" + src="/static/images/bookService/detail/ebook.png" + ></t-image> </view> <view class="btn-text">鐢靛瓙鏍蜂功鐢宠</view> </view> <view class="bottom-btn" bind:tap="appplyPaperBook"> <view> - <t-image src="/static/images/bookService/detail/paper-book.png"></t-image> + <t-image + src="/static/images/bookService/detail/paper-book.png" + ></t-image> </view> <view class="btn-text">绾歌川鏍蜂功鐢宠</view> </view> @@ -171,12 +345,19 @@ <view class="btn-text">璇曡</view> </view> - <view class="shopCar shopCarColor" bind:tap="addBookShopcCar" wx:if="{{!bookBuy}}">鍔犲叆璐墿杞�</view> - <view class="buy buyColor" bind:tap="buyBtn" wx:if="{{!bookBuy}}">绔嬪嵆璐拱</view> - <view class="buy read " bind:tap="goRead" wx:if="{{bookBuy}}">绔嬪嵆鏌ョ湅</view> + <view + class="shopCar shopCarColor" + bind:tap="addBookShopcCar" + wx:if="{{!bookBuy}}" + >鍔犲叆璐墿杞�</view + > + <view class="buy buyColor" bind:tap="buyBtn" wx:if="{{!bookBuy}}" + >绔嬪嵆璐拱</view + > + <view class="buy read" bind:tap="goRead" wx:if="{{bookBuy}}">绔嬪嵆鏌ョ湅</view> </view> </view> <view class="loading" wx:if="{{pageLoading}}"> <t-loading loading="{{pageLoading}}" size="40"></t-loading> -</view> \ No newline at end of file +</view> diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index 1baf9aa..d864f29 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -1,9 +1,6 @@ -import { - getPublicImage -} from '../../../../assets/js/middleGround/tool' -const app = getApp() +import { getPublicImage } from "../../../../assets/js/middleGround/tool"; +const app = getApp(); Page({ - /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ @@ -22,7 +19,7 @@ answerType: "", // 绛旈妯″紡 submitStatus: false, // 鎻愪氦鐘舵�� currentIndex: 0, // 褰撳墠鏄剧ず鐨勯鍙� - collectList: [], // 鏀惰棌棰樼洰鍒楄〃 + collectList: [], // 鏀惰棌棰樼洰鍒楄〃 errorList: [], // 閿欓鍒楄〃 subjectiveTotal: 0, // 瀹㈣棰樻�绘暟 subjectiveNum: 0, // 瀹㈣棰樺緱鍒� @@ -35,18 +32,18 @@ uuid: 0, mockData: { // 缁勫嵎淇℃伅 - state: '0', + state: "0", score: 0, // 鎬诲垎 sumTime: 0, time: 0, // 绛旈鍓╀綑鏃堕棿 datas: [], // 鎵�鏈夋ā鑰冭褰曟暟鎹�(棰樼洰鍒楄〃锛岀敤鎴风瓟棰橈紝鑰冭瘯鎶ュ憡) - answer: [] + answer: [], }, saveTime: 20, isNight: false, sliderValue: 0, // 瀛椾綋婊戝潡 startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿 - pauseTime: 0 //鏆傚仠鏃堕棿 + pauseTime: 0, //鏆傚仠鏃堕棿 }, /** @@ -64,25 +61,26 @@ // }); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 - const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� + const navBarHeight = + (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� this.setData({ barHeight: systInfo.statusBarHeight, navBarHeight: navBarHeight, answerTitle: options.answerTitle, bookId: options.bookId, - productLinkPath: options.productLinkPath ? options.productLinkPath : '', + productLinkPath: options.productLinkPath ? options.productLinkPath : "", rootCmsItemId: options.rootCmsItemId, idPathList: options.idPathList ? JSON.parse(options.idPathList) : [], answerType: options.answerType, }); - if (this.data.answerType == 'mock') { + if (this.data.answerType == "mock") { this.setData({ uuid: options.uuid, - mockid: options.mockid - }) + mockid: options.mockid, + }); } - this.init() - console.log('浼犲弬', options); + this.init(); + console.log("浼犲弬", options); }, /** @@ -94,27 +92,27 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ onShow() { - if (this.data.answerType != 'mock') { + if (this.data.answerType != "mock") { if (wx.timer) { - clearInterval(wx.timer) + clearInterval(wx.timer); } } - if (this.data.answerType == 'mock') { + if (this.data.answerType == "mock") { if (wx.timer) { - clearInterval(wx.timer) + clearInterval(wx.timer); } wx.timer = setInterval(() => { this.setData({ - saveTime: this.data.saveTime - 1 - }) + saveTime: this.data.saveTime - 1, + }); if (this.data.saveTime == 0) { - this.saveMockData() + this.saveMockData(); } - }, 1000) + }, 1000); } this.setData({ - startTime: Date.now() - }) + startTime: Date.now(), + }); }, /** @@ -122,14 +120,14 @@ */ onHide() { if (wx.timer) { - clearInterval(wx.timer) + clearInterval(wx.timer); } this.setData({ - pauseTime: Date.now() - }) + pauseTime: Date.now(), + }); if (wx.getStorageSync(app.config.tokenKey)) { - let duration = this.data.pauseTime - this.data.startTime - this.count(duration) + let duration = this.data.pauseTime - this.data.startTime; + this.count(duration); } }, @@ -138,52 +136,48 @@ */ onUnload(e) { if (wx.timer) { - clearInterval(wx.timer) + clearInterval(wx.timer); } if (this.data.countdownInterval !== null) { - clearInterval(this.data.countdownInterval) + clearInterval(this.data.countdownInterval); } this.setData({ - pauseTime: Date.now() - }) + pauseTime: Date.now(), + }); if (wx.getStorageSync(app.config.tokenKey)) { - let duration = this.data.pauseTime - this.data.startTime - this.count(duration) + let duration = this.data.pauseTime - this.data.startTime; + this.count(duration); } }, count(timeStr) { const data = { appRefCode: app.config.appRefCode, - type: 'LearningTime', //缁熻绫诲瀷--闃呰鏃堕暱 - data: timeStr + '', //缁熻鍐呭--鏃堕暱姣 - event: 'LearningTime', - sysType: 'App' - } + type: "LearningTime", //缁熻绫诲瀷--闃呰鏃堕暱 + data: timeStr + "", //缁熻鍐呭--鏃堕暱姣 + event: "LearningTime", + sysType: "App", + }; //闃呰鍟嗗搧鐨刬d if (this.data.bookId) { - data.productId = this.data.bookId + data.productId = this.data.bookId; } //闃呰璧勬簮鐨刬d // if (product.cmsItemId) { // data.cmsItemId = product.cmsItemId // } - app.MG.job.newJobWithApiNewEvent(data).then((res) => {}) + app.MG.job.newJobWithApiNewEvent(data).then((res) => {}); }, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ - onPullDownRefresh() { - - }, + onPullDownRefresh() {}, /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ - onReachBottom() { - - }, + onReachBottom() {}, /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� @@ -205,13 +199,13 @@ const oldVal = value; // 璁板綍灞炴�х殑鏃у�� value = newVal; // 鏇存柊灞炴�х殑鍊� callback.call(context, newVal, oldVal); // 璋冪敤鍥炶皟鍑芥暟锛屼紶閫掓柊鍊煎拰鏃у�� - } + }, }); }, onChangeSlider(e) { this.setData({ - sliderValue: e.detail.value - }) + sliderValue: e.detail.value, + }); console.log(e.detail.value); }, // 杩斿洖 @@ -222,109 +216,122 @@ //璁剧疆鑳屾櫙鑹� changeBGColor(e) { this.setData({ - isNight: e.detail.value - }) + isNight: e.detail.value, + }); }, // 鑾峰彇淇濆瓨鐨勫�掕鏃舵椂闂� getSavedTime() { - const savedTime = wx.getStorageSync('countdownTime') - return savedTime ? parseInt(savedTime) : null + const savedTime = wx.getStorageSync("countdownTime"); + return savedTime ? parseInt(savedTime) : null; }, // 淇濆瓨鍊掕鏃舵椂闂村埌鏈湴瀛樺偍 saveTime() { - wx.setStorageSync('countdownTime', this.data.countdownTime.toString()) + wx.setStorageSync("countdownTime", this.data.countdownTime.toString()); }, clearTime() { this.setData({ - countdownTime: 2 * 60 * 60 * 1000 - }) + countdownTime: 2 * 60 * 60 * 1000, + }); }, // 鏆傚仠鎴栫户缁�掕鏃� toggleCountdown() { if (this.data.countdownInterval) { - clearInterval(this.data.countdownInterval) + clearInterval(this.data.countdownInterval); this.setData({ countdownInterval: null, - isCountdownRunning: false - }) + isCountdownRunning: false, + }); } else { - this.startCountdown() + this.startCountdown(); this.setData({ - isCountdownRunning: true - }) + isCountdownRunning: true, + }); } }, // 寮�濮嬪�掕鏃� startCountdown() { // 濡傛灉璁℃椂鍣ㄥ凡缁忓瓨鍦紝鍏堟竻闄や箣鍓嶇殑璁℃椂鍣� if (this.data.countdownInterval) { - clearInterval(this.data.countdownInterval) + clearInterval(this.data.countdownInterval); this.setData({ - countdownInterval: null - }) + countdownInterval: null, + }); } this.setData({ countdownInterval: setInterval(() => { this.setData({ - countdownTime: this.data.countdownTime - 1000 - }) + countdownTime: this.data.countdownTime - 1000, + }); if (this.data.countdownTime <= 0) { - clearInterval(this.data.countdownInterval) + clearInterval(this.data.countdownInterval); this.setData({ countdownTime: 0, - isCountdownRunning: false - }) + isCountdownRunning: false, + }); } - this.saveTime() - }, 1000) - }) + this.saveTime(); + }, 1000), + }); }, // 鍒囨崲棰樼洰 changeSwiper(e) { this.setData({ - currentIndex: e.detail.index - }) - let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0 - const item = this.data.questionDataList[index] - if ((this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { - let flag = this.isHaveAnswer(item.userAnswer) - if (flag) this.handleQuestion(index) + currentIndex: e.detail.index, + }); + let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0; + const item = this.data.questionDataList[index]; + if ( + (this.data.answerType == "collectQuestion" || + this.data.answerType == "errorQuestion") && + !item.isComplete + ) { + let flag = this.isHaveAnswer(item.userAnswer); + if (flag) this.handleQuestion(index); } }, // 鎴戠殑閿欓锛屾敹钘忔煡鐪嬭В鏋愭寜閽� viewParsing() { - if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') { - const item = this.data.questionDataList[this.data.currentIndex] + if ( + this.data.answerType == "collectQuestion" || + this.data.answerType == "errorQuestion" + ) { + const item = this.data.questionDataList[this.data.currentIndex]; if (!item.isComplete) { - this.handleQuestion(this.data.currentIndex) + this.handleQuestion(this.data.currentIndex); } } }, // 鐐瑰嚮绛旈鍗¤烦杞鐩� goQuestion(e) { - const id = e.detail.id + const id = e.detail.id; this.data.questionDataList.forEach((item, index) => { if (item.id == id) { this.setData({ - currentIndex: index - }) + currentIndex: index, + }); } - }) + }); }, // 鍗曢�� 澶氶�� 瑙﹀彂 onChangeRadio(e) { - const radioData = e.detail.value.currentTarget.dataset.value - const id = e.detail.value.currentTarget.dataset.id - const radioChecked = e.detail.value.detail.value - const questionList = this.data.questionDataList + const radioData = e.detail.value.currentTarget.dataset.value; + const id = e.detail.value.currentTarget.dataset.id; + const radioChecked = e.detail.value.detail.value; + const questionList = this.data.questionDataList; // 鎴戠殑閿欓鍜屾垜鐨勬敹钘忔ā寮忎笅锛屽崟閫夐閫夋嫨浜嗙洿鎺ユ壒鏀� for (let index = 0; index < questionList.length; index++) { const item = questionList[index]; if (item.id == id && !item.isComplete) { - item.userAnswer = radioChecked - item.isUserAnswer = this.isHaveAnswer(radioChecked) - if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { - this.handleQuestion(this.data.currentIndex) + item.userAnswer = radioChecked; + item.isUserAnswer = this.isHaveAnswer(radioChecked); + if ( + (item.questionType == "singleChoice" || + item.questionType == "judge") && + (this.data.answerType == "collectQuestion" || + this.data.answerType == "errorQuestion") && + !item.isComplete + ) { + this.handleQuestion(this.data.currentIndex); } } } @@ -337,14 +344,14 @@ // } // } // }) - const cardListUpdata = this.data.cardList + const cardListUpdata = this.data.cardList; for (let index = 0; index < cardListUpdata.length; index++) { const item = cardListUpdata[index]; for (let cindex = 0; cindex < item.infoList.length; cindex++) { const citem = item.infoList[cindex]; if (citem.id == id && !citem.isComplete) { - citem.userAnswer = radioChecked - citem.isUserAnswer = this.isHaveAnswer(radioChecked) + citem.userAnswer = radioChecked; + citem.isUserAnswer = this.isHaveAnswer(radioChecked); } } } @@ -358,44 +365,44 @@ // }) this.setData({ questionDataList: questionList, - cardList: cardListUpdata - }) - if (this.data.answerType == 'mock') { + cardList: cardListUpdata, + }); + if (this.data.answerType == "mock") { this.setData({ - saveTime: 20 - }) + saveTime: 20, + }); } }, // 杈撳叆妗嗚Е鍙� onChangeInput(e) { - const inputData = e.detail.value.detail.value - const id = e.detail.value.currentTarget.dataset.id - const index = Number(e.detail.value.currentTarget.dataset.index) + const inputData = e.detail.value.detail.value; + const id = e.detail.value.currentTarget.dataset.id; + const index = Number(e.detail.value.currentTarget.dataset.index); console.log(index); - const questionList = this.data.questionDataList - questionList.forEach(item => { + const questionList = this.data.questionDataList; + questionList.forEach((item) => { if (item.id == id) { - item.userAnswer[index] = inputData - return item.isUserAnswer = this.isHaveAnswer(inputData) + item.userAnswer[index] = inputData; + return (item.isUserAnswer = this.isHaveAnswer(inputData)); } - }) - const cardListUpdata = this.data.cardList - cardListUpdata.forEach(item => { - item.infoList.forEach(citem => { + }); + const cardListUpdata = this.data.cardList; + cardListUpdata.forEach((item) => { + item.infoList.forEach((citem) => { if (citem.id == id) { - citem.userAnswer[index] = inputData - return citem.isUserAnswer = this.isHaveAnswer(inputData) + citem.userAnswer[index] = inputData; + return (citem.isUserAnswer = this.isHaveAnswer(inputData)); } - }) - }) + }); + }); this.setData({ questionDataList: questionList, cardList: cardListUpdata, - }) - if (this.data.answerType == 'mock') { + }); + if (this.data.answerType == "mock") { this.setData({ - saveTime: 20 - }) + saveTime: 20, + }); } }, // 鏁扮粍杞负瀛楃涓叉柟娉� @@ -403,100 +410,109 @@ // 妫�鏌ユ槸鍚︿负鏁扮粍 if (Array.isArray(data)) { // 浣跨敤 join 鏂规硶灏嗘暟缁勮浆鎹负瀛楃涓诧紝榛樿浣跨敤閫楀彿鍒嗛殧 - return data.join(',').replace(/<[^>]*>/g, '') + return data.join(",").replace(/<[^>]*>/g, ""); } else { // 濡傛灉涓嶆槸鏁扮粍锛岀洿鎺ヨ繑鍥炲師濮嬪�� - return data.replace(/<[^>]*>/g, '') + return data.replace(/<[^>]*>/g, ""); } }, // 鍒ゆ柇鏄惁鏈夌敤鎴风瓟妗� isHaveAnswer(data) { - if (typeof data == 'string') { + if (typeof data == "string") { data = data - .replace(/<[^>]*>/g, '') - .replace(/ /g, '') - .trim() + .replace(/<[^>]*>/g, "") + .replace(/ /g, "") + .trim(); if (data.length) { - return true + return true; } else { - return false + return false; } - } else if (typeof data == 'object') { - const answer = data.find((item) => item.length > 0) + } else if (typeof data == "object") { + const answer = data.find((item) => item.length > 0); if (answer) { - return true + return true; } else { - return false + return false; } } else { - return false + return false; } }, // 鎻愪氦閫昏緫 submitPaper() { // 鍏抽棴閫�鍑洪〉闈㈢洃鍚� - wx.disableAlertBeforeUnload() + wx.disableAlertBeforeUnload(); this.setData({ submitStatus: true, - loading: true - }) - const child = this.selectComponent('#question-options') - if (this.data.answerType == 'option' || this.data.answerType == 'errorQuestion' || this.data.answerType == 'mock') { + loading: true, + }); + const child = this.selectComponent("#question-options"); + if ( + this.data.answerType == "option" || + this.data.answerType == "errorQuestion" || + this.data.answerType == "mock" + ) { // 鍏堥亶鍘嗘墍鏈夐鐩紝灏嗘湭鎵规敼鐨勯鐩壒鏀� - const qustionList = this.data.questionDataList + const qustionList = this.data.questionDataList; for (let index = 0; index < qustionList.length; index++) { const item = qustionList[index]; - if (!item.isComplete) this.handleQuestion(index) + if (!item.isComplete) this.handleQuestion(index); } } - if (this.data.answerType == 'option') { - this.toggleCountdown() - this.recordAnswerData() - child.openTestReportDialog() - } else if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') { - this.goBack() - } else if (this.data.answerType == 'mock') { - this.toggleCountdown() + if (this.data.answerType == "option") { + this.toggleCountdown(); + this.recordAnswerData(); + child.openTestReportDialog(); + } else if ( + this.data.answerType == "collectQuestion" || + this.data.answerType == "errorQuestion" + ) { + this.goBack(); + } else if (this.data.answerType == "mock") { + this.toggleCountdown(); // 璁剧疆妯¤�冪姸鎬佷负宸插畬鎴� - const mockData = this.data.mockData + const mockData = this.data.mockData; mockData.datas.forEach((item) => { if (item.id == this.data.uuid) { - item.state = '3' + item.state = "3"; item.report = { - userScore: this.data.subjectiveNum - } + userScore: this.data.subjectiveNum, + }; } - }) + }); this.setData({ mockData: mockData, - submitStatus: true - }) - this.setMockInfo(mockData.datas) + submitStatus: true, + }); + this.setMockInfo(mockData.datas); // 璁板綍鐢ㄦ埛绛旈鏁版嵁 - let saveData = [] + let saveData = []; for (let index = 0; index < this.data.questionDataList.length; index++) { const item = this.data.questionDataList[index]; saveData.push({ id: item.id, answer: item.userAnswer, - isRight: item.isRight - }) + isRight: item.isRight, + }); } app.MG.identity.setUserKey({ - setKeyRequests: [{ - domain: 'mockAnswerData', - key: this.data.uuid, - value: JSON.stringify({ - time: this.data.countdownTime, - answerData: saveData - }) - }] - }) - child.openTestReportDialog() + setKeyRequests: [ + { + domain: "mockAnswerData", + key: this.data.uuid, + value: JSON.stringify({ + time: this.data.countdownTime, + answerData: saveData, + }), + }, + ], + }); + child.openTestReportDialog(); } this.setData({ - loading: false - }) + loading: false, + }); }, // 鍒濆鍖栧嚱鏁� async init() { @@ -504,77 +520,87 @@ loading: true, subjectiveTotal: 0, subjectiveNum: 0, - subjectiveGrade: 0 - }) - if (this.data.answerType == 'option') { + subjectiveGrade: 0, + }); + if (this.data.answerType == "option") { if (this.data) // this.startCountdown() this.setData({ - countdownTime: 2 * 60 * 60 * 1000 - }) + countdownTime: 2 * 60 * 60 * 1000, + }); // 娴嬭瘯绛旈 - await this.getCollectIdList() // 鑾峰彇鏀惰棌id鍒楄〃 - await this.getErrorList() // 鑾峰彇閿欓id鍒楄〃 - } else if (this.data.answerType == 'collectQuestion') { + await this.getCollectIdList(); // 鑾峰彇鏀惰棌id鍒楄〃 + await this.getErrorList(); // 鑾峰彇閿欓id鍒楄〃 + } else if (this.data.answerType == "collectQuestion") { this.setData({ - submitStatus: true - }) + submitStatus: true, + }); // 鎴戠殑鏀惰棌 - await this.getcollectId() // 鑾峰彇鏀惰棌棰樼洰 - } else if (this.data.answerType == 'errorQuestion') { + await this.getcollectId(); // 鑾峰彇鏀惰棌棰樼洰 + } else if (this.data.answerType == "errorQuestion") { this.setData({ - submitStatus: true - }) + submitStatus: true, + }); // 鎴戠殑閿欓 // loadings.value = true - await this.getErrorIdList() - await this.getCollectIdList() // 鑾峰彇鏀惰棌id鍒楄〃 - } else if (this.data.answerType == 'mock') { - this.getErrorList() - this.getCollectIdList() + await this.getErrorIdList(); + await this.getCollectIdList(); // 鑾峰彇鏀惰棌id鍒楄〃 + } else if (this.data.answerType == "mock") { + this.getErrorList(); + this.getCollectIdList(); this.getMockInfo(async (res) => { - let mocklist + let mocklist; try { - mocklist = JSON.parse(res[0].value) + mocklist = JSON.parse(res[0].value); } catch (error) { - mocklist = [] + mocklist = []; } if (mocklist.length && this.data.uuid) { - const oldMockData = mocklist.find((mockItem) => mockItem.id == this.data.uuid) + const oldMockData = mocklist.find( + (mockItem) => mockItem.id == this.data.uuid + ); this.setData({ - 'mockData.state': oldMockData.state, - 'mockData.score': oldMockData.score, - 'mockData.datas': mocklist, - }) - if (oldMockData.state == '0') { + "mockData.state": oldMockData.state, + "mockData.score": oldMockData.score, + "mockData.datas": mocklist, + }); + if (oldMockData.state == "0") { // 缁勫嵎璐拱浜嗭紝浣嗘湭杩涘叆椤甸潰 - await this.getEduQuizConfig() - } else if (oldMockData.state == '1' || oldMockData.state == '2' || oldMockData.state == '3') { + await this.getEduQuizConfig(); + } else if ( + oldMockData.state == "1" || + oldMockData.state == "2" || + oldMockData.state == "3" + ) { // 缁勫嵎鍚庤繘鍏ヨ繃椤甸潰锛屼絾鏄湭绛旇繃棰� - let oldQuestionList = [] - oldQuestionList = await this.getMockQuestionList() - const userAnswerList = await this.getMockAnswer() + let oldQuestionList = []; + oldQuestionList = await this.getMockQuestionList(); + const userAnswerList = await this.getMockAnswer(); this.setData({ - 'mockData.sumTime': oldMockData.time, - cardList: oldQuestionList - }) - await this.getMockDataList(oldQuestionList, userAnswerList) + "mockData.sumTime": oldMockData.time, + cardList: oldQuestionList, + }); + await this.getMockDataList(oldQuestionList, userAnswerList); } - if (oldMockData.state == '0' || oldMockData.state == '1' || oldMockData.state == '2') { - this.startCountdown() + if ( + oldMockData.state == "0" || + oldMockData.state == "1" || + oldMockData.state == "2" + ) { + this.startCountdown(); } - if (oldMockData.state == '3') { + if (oldMockData.state == "3") { this.setData({ submitStatus: true, - subjectiveNum: oldMockData.report.userScore - }) + subjectiveNum: oldMockData.report.userScore, + }); } } - }) + }); } }, async restart() { - const countDownRef = this.selectComponent('#countDownRef') + const countDownRef = this.selectComponent("#countDownRef"); this.setData({ loading: true, total: 0, @@ -582,38 +608,40 @@ subjectiveTotal: 0, subjectiveNum: 0, currentIndex: 0, - submitStatus: false - }) - if (this.data.answerType == 'option') { + submitStatus: false, + }); + if (this.data.answerType == "option") { this.setData({ - countdownTime: 2 * 60 * 60 * 1000 - }) + countdownTime: 2 * 60 * 60 * 1000, + }); this.delAnswerInfo(() => { - this.getQuestionList() - this.clearTime() - }) + this.getQuestionList(); + this.clearTime(); + }); if (!this.data.submitStatus) { - this.startCountdown() + this.startCountdown(); } - } else if (this.data.answerType == 'mock') { + } else if (this.data.answerType == "mock") { // 缁勫嵎妯″紡 // 娓呯┖绛旈璁板綍 await app.MG.identity.setUserKey({ - setKeyRequests: [{ - domain: 'mockAnswerData', - key: this.data.uuid, - value: JSON.stringify({ - time: this.data.countdownTime, - answerData: [] - }) - }] - }) - this.init() + setKeyRequests: [ + { + domain: "mockAnswerData", + key: this.data.uuid, + value: JSON.stringify({ + time: this.data.countdownTime, + answerData: [], + }), + }, + ], + }); + this.init(); } else { - this.init() - this.clearTime() + this.init(); + this.clearTime(); if (submitStatus.value) { - this.startCountdown() + this.startCountdown(); } } }, @@ -621,64 +649,67 @@ getCollectIdList() { app.MG.identity .getUserKey({ - domain: 'collectData', - keys: [this.data.rootCmsItemId] + domain: "collectData", + keys: [this.data.rootCmsItemId], }) .then((res) => { try { this.setData({ - collectList: JSON.parse(res[0].value) - }) + collectList: JSON.parse(res[0].value), + }); } catch (error) {} - if (this.data.answerType == 'option') { + if (this.data.answerType == "option") { // 鍏堣幏鍙栫敤鎴风瓟棰樿褰� this.getAnswerInfo(async (res) => { if (res.length) { // 鏈夎褰曪紝涓嶈兘绛旈锛岀姸鎬佽涓哄凡鎻愪氦 this.setData({ - submitStatus: true - }) - let value = JSON.parse(res[0].value) + submitStatus: true, + }); + let value = JSON.parse(res[0].value); // 鏈夌瓟棰樿褰曪紝寰楀垎璧嬪�� if (value) { - wx.disableAlertBeforeUnload() + wx.disableAlertBeforeUnload(); this.setData({ - submitStatus: true - }) + submitStatus: true, + }); value.dataList.forEach((item) => { - if (item.name == '瀹㈣棰樺緱鍒�' && item.path == this.data.productLinkPath) + if ( + item.name == "瀹㈣棰樺緱鍒�" && + item.path == this.data.productLinkPath + ) this.setData({ - subjectiveNum: item.score - }) - }) + subjectiveNum: item.score, + }); + }); } this.setData({ - currentIndex: value.currentIndex - }) + currentIndex: value.currentIndex, + }); console.log(this.data.submitStatus); // 鎼哄甫绛旈璁板綍 鑾峰彇棰樼洰 - await this.getQuestionList(value.dataList) + await this.getQuestionList(value.dataList); } else { - await this.getQuestionList() // 鑾峰彇棰樺簱棰樼洰 + await this.getQuestionList(); // 鑾峰彇棰樺簱棰樼洰 } - }) + }); } - }) + }); }, // 鑾峰彇閿欓id鍒楄〃 getErrorList() { app.MG.identity .getUserKey({ - domain: 'errorData', - keys: [this.data.rootCmsItemId] + domain: "errorData", + keys: [this.data.rootCmsItemId], }) .then((res) => { try { this.setData({ - errorList: JSON.parse(res[0].value) - }) + errorList: JSON.parse(res[0].value), + }); } catch (error) {} - }) + }); }, // 鑾峰彇棰樺簱棰樼洰 async getQuestionList(oldData) { @@ -686,23 +717,23 @@ this.setData({ cardList: [], correctNum: 0, - }) - let flag = 0 + }); + let flag = 0; for (let index = 0; index < this.data.idPathList.length; index++) { const pathitem = this.data.idPathList[index]; - const pathList = this.data.cardList + const pathList = this.data.cardList; pathList.push({ path: pathitem.productLinkPath, catalogName: pathitem.name, - infoList: [] - }) + infoList: [], + }); this.setData({ - cardList: pathList - }) + cardList: pathList, + }); // 鑾峰彇棰樼洰 let query = { - path: '*', - queryType: '*', + path: "*", + queryType: "*", productId: this.data.bookId, cmsPath: pathitem.productLinkPath, itemFields: { @@ -715,110 +746,150 @@ Embedded_QuestionBank_StemStyle: [], Embedded_QuestionBank_OptionStyle: [], Embedded_QuestionBank_KnowledgePoint: [], - Embedded_QuestionBank_Difficulty: [] + Embedded_QuestionBank_Difficulty: [], }, pading: { start: 0, - size: 999 - } - } + size: 999, + }, + }; await app.MG.store.getProductDetail(query).then((res) => { this.setData({ - total: res.datas.cmsDatas[0].datas.length - }) + total: res.datas.cmsDatas[0].datas.length, + }); // total.value += res.datas.cmsDatas[0].datas.length - let oldList + let oldList; if (oldData) { // 鎻愪氦杩囷紝瀛樺湪绛旈璁板綍 - oldList = oldData.find((item) => item.path == pathitem.productLinkPath).infoList + oldList = oldData.find( + (item) => item.path == pathitem.productLinkPath + ).infoList; this.setData({ - submitStatus: true - }) + submitStatus: true, + }); } res.datas.cmsDatas[0].datas.forEach((item, index) => { - let oldObj = '' - if (oldList) oldObj = oldList.find((oldItem) => oldItem.id == item.id) + let oldObj = ""; + if (oldList) + oldObj = oldList.find((oldItem) => oldItem.id == item.id); let questionObj = { // num: index, // 棰樺彿 id: item.id, type: pathitem.name, - stem: item.Embedded_QuestionBank_QuestionType == 'completion' ? - JSON.parse(item.Embedded_QuestionBank_Stem) - .stemTxt.replaceAll('<vacancy>', ',input,') - .split(',') : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 + stem: + item.Embedded_QuestionBank_QuestionType == "completion" + ? JSON.parse(item.Embedded_QuestionBank_Stem) + .stemTxt.replaceAll("<vacancy>", ",input,") + .split(",") + : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 answer: item.Embedded_QuestionBank_Answer, // 绛旀 - option: item.Embedded_QuestionBank_Option ? - JSON.parse(item.Embedded_QuestionBank_Option) : '', // 閫夋嫨棰橀�夐」 + option: item.Embedded_QuestionBank_Option + ? JSON.parse(item.Embedded_QuestionBank_Option) + : "", // 閫夋嫨棰橀�夐」 analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽 questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷 optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷 stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷 - difficulty: item.Embedded_QuestionBank_Difficulty ? - 4 - item.Embedded_QuestionBank_Difficulty : 0, // 闅惧害绛夌骇 - userAnswer: oldObj ? - oldObj.userAnswer : item.Embedded_QuestionBank_QuestionType == 'completion' || - item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '', + difficulty: item.Embedded_QuestionBank_Difficulty + ? 4 - item.Embedded_QuestionBank_Difficulty + : 0, // 闅惧害绛夌骇 + userAnswer: oldObj + ? oldObj.userAnswer + : item.Embedded_QuestionBank_QuestionType == "completion" || + item.Embedded_QuestionBank_QuestionType == "multipleChoice" + ? [] + : "", isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false, isRight: oldObj ? oldObj.isRight : null, isComplete: oldObj ? oldObj.isComplete : false, - isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false, - isUnfold: '' // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� - } + isCollect: + this.data.collectList.indexOf(item.id) > -1 ? true : false, + isUnfold: "", // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� + }; // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 if ( - questionObj.questionType == 'completion' || - questionObj.questionType == 'multipleChoice' + questionObj.questionType == "completion" || + questionObj.questionType == "multipleChoice" ) { try { - questionObj.answer = JSON.parse(questionObj.answer).toString() + questionObj.answer = JSON.parse(questionObj.answer).toString(); } catch (error) { - questionObj.answer = item.Embedded_QuestionBank_Answer + questionObj.answer = item.Embedded_QuestionBank_Answer; } } // 濉┖棰樻敼閫� - if (questionObj.questionType == 'completion') { - let index = 0 + if (questionObj.questionType == "completion") { + let index = 0; for (let i = 0; i < questionObj.stem.length; i++) { - const item = questionObj.stem[i] - if (item == 'input') { + const item = questionObj.stem[i]; + if (item == "input") { questionObj.stem[i] = { num: index, - data: 'input' - } - if (!oldObj) questionObj.userAnswer[index] = '' - index++ + data: "input", + }; + if (!oldObj) questionObj.userAnswer[index] = ""; + index++; } } } // 棰樺共瀵屾枃鏈鐞� - if (questionObj.stemStyle == 'RichText') { + if (questionObj.stemStyle == "RichText") { // questionObj.option.txt = '' - questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ').replace(/\<p/gi, '<p class="stem-rich-p"') + questionObj.stem.stemTxt = questionObj.stem.stemTxt + .replace( + /\<img/gi, + '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' + ) + .replace(/\<p/gi, '<p class="stem-rich-p"'); } // 閫夐」瀵屾枃鏈鐞� - if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) { - questionObj.option.forEach(item => { - if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"') - }) + if ( + questionObj.optionStyle == "RichText" && + (questionObj.questionType == "singleChoice" || + questionObj.questionType == "judge" || + questionObj.questionType == "multipleChoice") + ) { + questionObj.option.forEach((item) => { + if (item.txt) + item.txt = item.txt + .replace(/\<img/gi, '<img class="option-rich-img"') + .replace(/\<p/gi, '<p class="stem-rich-p"'); + }); } - // 瑙f瀽瀵屾枃鏈鐞� - if (questionObj.analysisCon && typeof questionObj.analysisCon == 'string') { - questionObj.analysisCon = questionObj.analysisCon.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ') + // 瑙f瀽瀵屾枃鏈鐞� + if ( + questionObj.analysisCon && + typeof questionObj.analysisCon == "string" + ) { + questionObj.analysisCon = questionObj.analysisCon.replace( + /\<img/gi, + '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' + ); } // 鑾峰彇鍥剧墖 - if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { - questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) + if ( + questionObj.stemStyle == "Image" || + questionObj.stemStyle == "TxtAndImage" + ) { + questionObj.stem.stemImage = getPublicImage( + questionObj.stem.stemImage, + 150 + ); } - if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { - questionObj.option.forEach(optionItem => { - if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) - }) + if ( + questionObj.optionStyle == "Image" || + questionObj.optionStyle == "TxtAndImage" + ) { + questionObj.option.forEach((optionItem) => { + if (optionItem.img) + optionItem.img = getPublicImage(optionItem.img, 150); + }); } // 瀹㈣棰樻�诲垎璧嬪�� - if (questionObj.questionType !== 'shortAnswer') { + if (questionObj.questionType !== "shortAnswer") { this.setData({ - subjectiveGrade: this.data.subjectiveGrade + 2 - }) + subjectiveGrade: this.data.subjectiveGrade + 2, + }); } // if (questionObj.optionStyle == 'RichText') { // questionObj.option.forEach(optionItem => { @@ -828,144 +899,164 @@ // 鏃ф暟鎹噷 棰樼洰姝g‘ 璁板綍姝g‘鏁伴噺 if (questionObj.isRight) { this.setData({ - correctNum: this.data.correctNum + 1 - }) + correctNum: this.data.correctNum + 1, + }); } - if (pathitem.name == '鍒ゆ柇棰�' || pathitem.name == '濉┖棰�' || pathitem.name == '澶氶�夐' || pathitem.name == '鍗曢�夐' || pathitem.name == '鍚姏棰�') { + if ( + pathitem.name == "鍒ゆ柇棰�" || + pathitem.name == "濉┖棰�" || + pathitem.name == "澶氶�夐" || + pathitem.name == "鍗曢�夐" || + pathitem.name == "鍚姏棰�" + ) { if (oldObj) { this.setData({ - subjectiveTotal: this.data.subjectiveTotal + 1 - }) + subjectiveTotal: this.data.subjectiveTotal + 1, + }); } } // cardList璧嬪�� - let cardIndex = this.data.cardList.findIndex((item) => item.path == pathitem.productLinkPath) - let infoList = this.data.cardList[cardIndex].infoList - infoList.push(questionObj) + let cardIndex = this.data.cardList.findIndex( + (item) => item.path == pathitem.productLinkPath + ); + let infoList = this.data.cardList[cardIndex].infoList; + infoList.push(questionObj); this.setData({ - [`cardList[${cardIndex}].infoList`]: infoList - }) + [`cardList[${cardIndex}].infoList`]: infoList, + }); flag++; - let questionList = [] - let grade = 0 - const cardUpdatedList = this.data.cardList + let questionList = []; + let grade = 0; + const cardUpdatedList = this.data.cardList; // if (flag == this.data.idPathList.length) { - cardUpdatedList.forEach(aitem => { + cardUpdatedList.forEach((aitem) => { aitem.infoList.forEach((bitem, bindex) => { - questionList.push(bitem) - bitem.number = bindex + 1 - bitem.score = 2 - }) - }) + questionList.push(bitem); + bitem.number = bindex + 1; + bitem.score = 2; + }); + }); this.setData({ questionDataList: questionList, cardList: cardUpdatedList, - }) - }) - }) + }); + }); + }); } // 鏈夐鐩啀寮�濮嬪�掕鏃� - if (this.data.questionDataList.length) this.startCountdown() + if (this.data.questionDataList.length) this.startCountdown(); this.setData({ - loading: false - }) + loading: false, + }); }, // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級 handleQuestion(index) { - const questionList = this.data.questionDataList + const questionList = this.data.questionDataList; if (questionList[index].isComplete) { // 棰樼洰宸插畬鎴愶紝璺宠繃 - return true + return true; } - questionList[index].isComplete = true - const item = questionList[index] + questionList[index].isComplete = true; + const item = questionList[index]; // 鎵规敼棰樼洰 - if (item.questionType == 'multipleChoice') { + if (item.questionType == "multipleChoice") { // 澶氶�夐 if (item.answer.length == item.userAnswer.length) { - const sortedArr1 = item.answer.slice().sort() - const sortedArr2 = item.userAnswer.slice().sort() + const sortedArr1 = item.answer.slice().sort(); + const sortedArr2 = item.userAnswer.slice().sort(); questionList[index].isRight = sortedArr1.every( (value, valueIndex) => value === sortedArr2[valueIndex] - ) + ); } else { - questionList[index].isRight = false + questionList[index].isRight = false; } - } else if (item.questionType == 'singleChoice' || item.questionType == 'judge') { + } else if ( + item.questionType == "singleChoice" || + item.questionType == "judge" + ) { // 鍗曢�� 鍒ゆ柇 - questionList[index].isRight = item.answer == item.userAnswer - } else if (item.questionType == 'shortAnswer') { + questionList[index].isRight = item.answer == item.userAnswer; + } else if (item.questionType == "shortAnswer") { // 绠�绛� 缈昏瘧 - questionList[index].isRight = null - } else if (item.questionType == 'completion') { - if (item.answer == 'string') { - item.isRight = item.answer == item.userAnswer[0] + questionList[index].isRight = null; + } else if (item.questionType == "completion") { + if (item.answer == "string") { + item.isRight = item.answer == item.userAnswer[0]; } else { if (item.answer.length != item.userAnswer.length) { - item.isRight = false + item.isRight = false; } else { item.isRight = item.answer.every( (value, index) => value === item.userAnswer[index] - ) + ); } } - if (typeof item.answer == 'string') { - questionList[index].isRight = item.answer == item.userAnswer[0] + if (typeof item.answer == "string") { + questionList[index].isRight = item.answer == item.userAnswer[0]; } else { if (item.answer.length != item.userAnswer.length) { - questionList[index].isRight = false + questionList[index].isRight = false; } else { questionList[index].isRight = item.answer.every( (value, valueIndex) => value === item.userAnswer[valueIndex] - ) + ); } } } - if (item.questionType != 'shortAnswer') { + if (item.questionType != "shortAnswer") { this.setData({ subjectiveTotal: this.data.subjectiveTotal + 1, - }) + }); } - if (questionList[index].isRight && item.questionType != 'shortAnswer') { + if (questionList[index].isRight && item.questionType != "shortAnswer") { // 瀹㈣棰樺洖绛旀纭� this.setData({ subjectiveNum: this.data.subjectiveNum + item.score, - correctNum: this.data.correctNum + 1 - }) + correctNum: this.data.correctNum + 1, + }); } - if (!questionList[index].isRight && item.questionType != 'shortAnswer') { + if (!questionList[index].isRight && item.questionType != "shortAnswer") { // 瀹㈣棰樺洖绛旈敊璇� 璁板綍閿欓 - if (this.data.errorList.findIndex((errorItem) => errorItem == item.id) == -1) { - this.data.errorList.push(item.id) + if ( + this.data.errorList.findIndex((errorItem) => errorItem == item.id) == -1 + ) { + this.data.errorList.push(item.id); } } else { - if (this.data.answerType == 'errorQuestion' || this.data.answerType == 'option') { + if ( + this.data.answerType == "errorQuestion" || + this.data.answerType == "option" + ) { // 浠庨敊棰橀泦涓Щ闄� - let errorIndex = this.data.errorList.findIndex((erroritem) => erroritem == item.id) + let errorIndex = this.data.errorList.findIndex( + (erroritem) => erroritem == item.id + ); if (errorIndex > -1) { - this.data.errorList.splice(errorIndex, 1) + this.data.errorList.splice(errorIndex, 1); } } } - if (this.data.answerType != 'collectQuestion') { + if (this.data.answerType != "collectQuestion") { // 璁板綍閿欓 app.MG.identity .setUserKey({ - setKeyRequests: [{ - domain: 'errorData', - key: this.data.rootCmsItemId, - value: JSON.stringify(this.data.errorList) - }] + setKeyRequests: [ + { + domain: "errorData", + key: this.data.rootCmsItemId, + value: JSON.stringify(this.data.errorList), + }, + ], }) .then((res) => { - console.log(res) - }) + console.log(res); + }); } this.setData({ - questionDataList: questionList - }) - const cardUpdatedList = this.data.cardList + questionDataList: questionList, + }); + const cardUpdatedList = this.data.cardList; cardUpdatedList.forEach((item) => { item.infoList.forEach((citem) => { if (citem.id == questionList[index].id) { @@ -974,188 +1065,199 @@ }); }); this.setData({ - cardList: cardUpdatedList - }) + cardList: cardUpdatedList, + }); }, // 棰樼洰鏀惰棌鎸夐挳,鏀惰棌鍜屽彇娑堝悓涓�鎺ュ彛锛屽彇娑堟暟缁勫噺鍘昏椤筰d setCollect() { - const citem = this.data.questionDataList[this.data.currentIndex] - const questionList = this.data.questionDataList + const citem = this.data.questionDataList[this.data.currentIndex]; + const questionList = this.data.questionDataList; for (let index = 0; index < questionList.length; index++) { const item = questionList[index]; if (item.id == citem.id) { - item.isCollect = !item.isCollect + item.isCollect = !item.isCollect; } } this.setData({ - questionDataList: questionList - }) + questionDataList: questionList, + }); if (this.data.collectList.length == 0) { this.setData({ - collectList: [citem.id] - }) + collectList: [citem.id], + }); } else { - const collectItme = this.data.collectList.filter((item) => item == citem.id) + const collectItme = this.data.collectList.filter( + (item) => item == citem.id + ); if (collectItme.length) { - const arr = this.data.collectList.filter((item) => item != citem.id) + const arr = this.data.collectList.filter((item) => item != citem.id); this.setData({ - collectList: arr - }) + collectList: arr, + }); } else { - const collectArr = this.data.collectList - collectArr.push(citem.id) + const collectArr = this.data.collectList; + collectArr.push(citem.id); this.setData({ - collectList: collectArr - }) + collectList: collectArr, + }); } } app.MG.identity .setUserKey({ - setKeyRequests: [{ - domain: 'collectData', - key: this.data.rootCmsItemId, - value: JSON.stringify(this.data.collectList) - }] + setKeyRequests: [ + { + domain: "collectData", + key: this.data.rootCmsItemId, + value: JSON.stringify(this.data.collectList), + }, + ], }) - .then((res) => {}) + .then((res) => {}); }, // 澶勭悊绛旈鏁版嵁 recordAnswerData() { this.data.cardList.push({ - name: '瀹㈣棰樺緱鍒�', + name: "瀹㈣棰樺緱鍒�", score: this.data.subjectiveNum, path: this.data.productLinkPath, // infoList: [], // catalogName: '' - }) + }); let setInfoData = { currentIndex: this.data.currentIndex, - dataList: JSON.parse(JSON.stringify(this.data.cardList)) - } + dataList: JSON.parse(JSON.stringify(this.data.cardList)), + }; for (let i = 0; i < setInfoData.dataList.length; i++) { - const item = setInfoData.dataList[i] - if (!item.name && !item.name == '瀹㈣棰樺緱鍒�') { + const item = setInfoData.dataList[i]; + if (!item.name && !item.name == "瀹㈣棰樺緱鍒�") { for (let j = 0; j < item.infoList.length; j++) { let obj = { id: item.infoList[j].id, userAnswer: item.infoList[j].userAnswer, isComplete: item.infoList[j].isComplete, isRight: item.infoList[j].isRight, - isCollect: item.infoList[j].isCollect - } - item.infoList[j] = obj + isCollect: item.infoList[j].isCollect, + }; + item.infoList[j] = obj; } } } - this.setAnswerInfo(setInfoData) + this.setAnswerInfo(setInfoData); }, // 鎻愪氦绛旈鏁版嵁 setAnswerInfo(data) { app.MG.identity .setUserKey({ - setKeyRequests: [{ - domain: 'answerData', - key: this.data.productLinkPath, - value: JSON.stringify(data) - }] + setKeyRequests: [ + { + domain: "answerData", + key: this.data.productLinkPath, + value: JSON.stringify(data), + }, + ], }) - .then((res) => {}) + .then((res) => {}); }, // 鑾峰彇绛旈鏁版嵁 getAnswerInfo(callback) { app.MG.identity .getUserKey({ - domain: 'answerData', - keys: [this.data.productLinkPath] + domain: "answerData", + keys: [this.data.productLinkPath], }) .then((res) => { - if (callback) callback(res) - }) + if (callback) callback(res); + }); }, // 鍒犻櫎绛旈鏁版嵁 delAnswerInfo(callback) { app.MG.identity .delUserKey({ - domain: 'answerData', - keys: [this.data.productLinkPath] + domain: "answerData", + keys: [this.data.productLinkPath], }) .then((res) => { - if (callback) callback() - }) + if (callback) callback(); + }); }, // 鎴戠殑鏀惰棌妯″紡涓嬭幏鍙栨敹钘忛鐩甶d async getcollectId() { app.MG.identity .getUserKey({ - domain: 'collectData', - keys: [this.data.rootCmsItemId] + domain: "collectData", + keys: [this.data.rootCmsItemId], }) .then(async (res) => { try { this.setData({ - collectList: JSON.parse(res[0].value) - }) + collectList: JSON.parse(res[0].value), + }); } catch (error) {} if (this.data.collectList && this.data.collectList.length) { - await this.getCollectDataList() + await this.getCollectDataList(); } else { this.setData({ - loading: false - }) + loading: false, + }); wx.showModal({ - title: '鎻愮ず', - content: '鏀惰棌澶规殏鏃犳暟鎹�', //editable濡傛灉涓簍rue锛岃繖灏辨槸杈撳叆妗嗙殑鍐呭 + title: "鎻愮ず", + content: "鏀惰棌澶规殏鏃犳暟鎹�", //editable濡傛灉涓簍rue锛岃繖灏辨槸杈撳叆妗嗙殑鍐呭 editable: false, //鏄惁鏄剧ず杈撳叆妗� showCancel: false, success: (res) => { if (res.confirm) { this.setData({ - submitStatus: true - }) - this.goBack() + submitStatus: true, + }); + this.goBack(); } - - } - }) + }, + }); } - }) + }); }, // 鑾峰彇鏀惰棌澶� async getCollectDataList() { - let questionArr = [] + let questionArr = []; this.setData({ - cardList: [{ - catalogName: '鍗曢�夐', - infoList: [] - }, { - catalogName: '鍒ゆ柇棰�', - infoList: [] - }, { - catalogName: '澶氶�夐', - infoList: [] - }, { - catalogName: '濉┖棰�', - infoList: [] - }, { - catalogName: '绠�绛旈', - infoList: [] - }] - }) - let singleChoiceArr = [] // 鍗曢�� - let judgeArr = [] // 鍒ゆ柇 - let shortArr = [] // 绠�绛� - let multipleChoiceArr = [] // 澶氶�� - let completionArr = [] // 濉┖ + cardList: [ + { + catalogName: "鍗曢�夐", + infoList: [], + }, + { + catalogName: "鍒ゆ柇棰�", + infoList: [], + }, + { + catalogName: "澶氶�夐", + infoList: [], + }, + { + catalogName: "濉┖棰�", + infoList: [], + }, + { + catalogName: "绠�绛旈", + infoList: [], + }, + ], + }); + let singleChoiceArr = []; // 鍗曢�� + let judgeArr = []; // 鍒ゆ柇 + let shortArr = []; // 绠�绛� + let multipleChoiceArr = []; // 澶氶�� + let completionArr = []; // 濉┖ for (let qindex = 0; qindex < this.data.collectList.length; qindex++) { const qitem = this.data.collectList[qindex]; let query = { - path: '*', + path: "*", cmsPath: this.data.rootCmsItemId, - cmsType: '*', + cmsType: "*", productId: this.data.bookId, - queryType: '*', - itemIds: qitem + '', + queryType: "*", + itemIds: qitem + "", itemFields: { Embedded_QuestionBank_Stem: [], Embedded_QuestionBank_AnalysisCon: [], @@ -1165,191 +1267,230 @@ Embedded_QuestionBank_StemStyle: [], Embedded_QuestionBank_OptionStyle: [], Embedded_QuestionBank_KnowledgePoint: [], - Embedded_QuestionBank_Difficulty: [] - } - } + Embedded_QuestionBank_Difficulty: [], + }, + }; await app.MG.store.getProductDetail(query).then((res) => { - let questionArr = [] + let questionArr = []; res.datas.cmsDatas[0].datas.forEach((item, index) => { const questionObj = { number: index + 1, // 棰樺彿 id: item.id, - stem: item.Embedded_QuestionBank_QuestionType == 'completion' ? - JSON.parse(item.Embedded_QuestionBank_Stem) - .stemTxt.replaceAll('<vacancy>', ',input,') - .split(',') : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 + stem: + item.Embedded_QuestionBank_QuestionType == "completion" + ? JSON.parse(item.Embedded_QuestionBank_Stem) + .stemTxt.replaceAll("<vacancy>", ",input,") + .split(",") + : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 answer: item.Embedded_QuestionBank_Answer, // 绛旀 - option: item.Embedded_QuestionBank_Option ? - JSON.parse(item.Embedded_QuestionBank_Option) : '', // 閫夋嫨棰橀�夐」 + option: item.Embedded_QuestionBank_Option + ? JSON.parse(item.Embedded_QuestionBank_Option) + : "", // 閫夋嫨棰橀�夐」 analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽 questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷 optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷 stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷 - difficulty: item.Embedded_QuestionBank_Difficulty ? - 4 - item.Embedded_QuestionBank_Difficulty : 0, // 闅惧害绛夌骇 - userAnswer: item.Embedded_QuestionBank_QuestionType == 'completion' || - item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '', + difficulty: item.Embedded_QuestionBank_Difficulty + ? 4 - item.Embedded_QuestionBank_Difficulty + : 0, // 闅惧害绛夌骇 + userAnswer: + item.Embedded_QuestionBank_QuestionType == "completion" || + item.Embedded_QuestionBank_QuestionType == "multipleChoice" + ? [] + : "", isSubmit: false, // 鏌ョ湅瑙f瀽 isRight: null, // 鏄惁姝g‘ isComplete: false, - isCollect: true - } + isCollect: true, + }; // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 if ( - questionObj.questionType == 'completion' || - questionObj.questionType == 'multipleChoice' + questionObj.questionType == "completion" || + questionObj.questionType == "multipleChoice" ) { try { - questionObj.answer = JSON.parse(questionObj.answer).toString() + questionObj.answer = JSON.parse(questionObj.answer).toString(); } catch (error) { - questionObj.answer = item.Embedded_QuestionBank_Answer + questionObj.answer = item.Embedded_QuestionBank_Answer; } } // 濉┖棰樻敼閫� - if (questionObj.questionType == 'completion') { - let index = 0 + if (questionObj.questionType == "completion") { + let index = 0; for (let i = 0; i < questionObj.stem.length; i++) { - const item = questionObj.stem[i] - if (item == 'input') { + const item = questionObj.stem[i]; + if (item == "input") { questionObj.stem[i] = { num: index, - data: 'input' - } - questionObj.userAnswer[index] = '' - index++ + data: "input", + }; + questionObj.userAnswer[index] = ""; + index++; } } } // 鑾峰彇鍥剧墖 - if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { - questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) + if ( + questionObj.stemStyle == "Image" || + questionObj.stemStyle == "TxtAndImage" + ) { + questionObj.stem.stemImage = getPublicImage( + questionObj.stem.stemImage, + 150 + ); } - if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { - questionObj.option.forEach(optionItem => { - if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) - }) + if ( + questionObj.optionStyle == "Image" || + questionObj.optionStyle == "TxtAndImage" + ) { + questionObj.option.forEach((optionItem) => { + if (optionItem.img) + optionItem.img = getPublicImage(optionItem.img, 150); + }); } // 棰樺共瀵屾枃鏈鐞� - if (questionObj.stemStyle == 'RichText') { + if (questionObj.stemStyle == "RichText") { // questionObj.option.txt = '' - questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ').replace(/\<p/gi, '<p class="stem-rich-p"') - + questionObj.stem.stemTxt = questionObj.stem.stemTxt + .replace( + /\<img/gi, + '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' + ) + .replace(/\<p/gi, '<p class="stem-rich-p"'); } // 閫夐」瀵屾枃鏈鐞� - if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) { - questionObj.option.forEach(item => { - if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"') - }) + if ( + questionObj.optionStyle == "RichText" && + (questionObj.questionType == "singleChoice" || + questionObj.questionType == "judge" || + questionObj.questionType == "multipleChoice") + ) { + questionObj.option.forEach((item) => { + if (item.txt) + item.txt = item.txt + .replace(/\<img/gi, '<img class="option-rich-img"') + .replace(/\<p/gi, '<p class="stem-rich-p"'); + }); } - if (item.Embedded_QuestionBank_QuestionType == 'judge') { - questionObj.type = '鍒ゆ柇棰�' - judgeArr.push(questionObj) - } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { - questionObj.type = '鍗曢�夐' - singleChoiceArr.push(questionObj) - } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') { - questionObj.type = '澶氶�夐' - multipleChoiceArr.push(questionObj) - } else if (item.Embedded_QuestionBank_QuestionType == 'completion') { - questionObj.type = '濉┖棰�' - completionArr.push(questionObj) - } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { - questionObj.type = '绠�绛旈' - shortArr.push(questionObj) + if (item.Embedded_QuestionBank_QuestionType == "judge") { + questionObj.type = "鍒ゆ柇棰�"; + judgeArr.push(questionObj); + } else if ( + item.Embedded_QuestionBank_QuestionType == "singleChoice" + ) { + questionObj.type = "鍗曢�夐"; + singleChoiceArr.push(questionObj); + } else if ( + item.Embedded_QuestionBank_QuestionType == "multipleChoice" + ) { + questionObj.type = "澶氶�夐"; + multipleChoiceArr.push(questionObj); + } else if (item.Embedded_QuestionBank_QuestionType == "completion") { + questionObj.type = "濉┖棰�"; + completionArr.push(questionObj); + } else if (item.Embedded_QuestionBank_QuestionType == "shortAnswer") { + questionObj.type = "绠�绛旈"; + shortArr.push(questionObj); } - }) - }) + }); + }); } this.setData({ - ['cardList[0].infoList']: singleChoiceArr, - ['cardList[1].infoList']: judgeArr, - ['cardList[2].infoList']: multipleChoiceArr, - ['cardList[3].infoList']: completionArr, - ['cardList[3].infoList']: shortArr, - }) - const cardList = this.data.cardList + ["cardList[0].infoList"]: singleChoiceArr, + ["cardList[1].infoList"]: judgeArr, + ["cardList[2].infoList"]: multipleChoiceArr, + ["cardList[3].infoList"]: completionArr, + ["cardList[4].infoList"]: shortArr, + }); + const cardList = this.data.cardList; for (let index = 0; index < cardList.length; index++) { const item = cardList[index]; for (let cindex = 0; cindex < item.infoList.length; cindex++) { - const citem = item.infoList[cindex] - citem.number = cindex + 1 - questionArr.push(citem) + const citem = item.infoList[cindex]; + citem.number = cindex + 1; + questionArr.push(citem); } } this.setData({ questionDataList: questionArr, cardList: cardList, - loading: false - }) + loading: false, + }); }, // 鎴戠殑閿欓妯″紡涓嬭幏鍙栭敊棰榠d鍒楄〃 async getErrorIdList() { await app.MG.identity .getUserKey({ - domain: 'errorData', - keys: [this.data.rootCmsItemId] + domain: "errorData", + keys: [this.data.rootCmsItemId], }) .then((res) => { try { this.setData({ - errorList: JSON.parse(res[0].value) - }) + errorList: JSON.parse(res[0].value), + }); } catch (error) {} if (this.data.errorList && this.data.errorList.length) { - this.getErrorDataList() + this.getErrorDataList(); } else { this.setData({ - loading: true - }) + loading: true, + }); wx.showModal({ - title: '鎻愮ず', - content: '閿欓闆嗘殏鏃犳暟鎹�', //editable濡傛灉涓簍rue锛岃繖灏辨槸杈撳叆妗嗙殑鍐呭 + title: "鎻愮ず", + content: "閿欓闆嗘殏鏃犳暟鎹�", //editable濡傛灉涓簍rue锛岃繖灏辨槸杈撳叆妗嗙殑鍐呭 editable: false, //鏄惁鏄剧ず杈撳叆妗� showCancel: false, success: (res) => { if (res.confirm) { this.setData({ - submitStatus: true - }) - this.goBack() + submitStatus: true, + }); + this.goBack(); } - } - }) + }, + }); } - }) + }); }, // 鑾峰彇閿欓闆� async getErrorDataList() { this.setData({ - cardList: [{ - catalogName: '鍗曢�夐', - infoList: [] - }, { - catalogName: '鍒ゆ柇棰�', - infoList: [] - }, { - catalogName: '澶氶�夐', - infoList: [] - }, { - catalogName: '濉┖棰�', - infoList: [] - }, { - catalogName: '绠�绛旈', - infoList: [] - }] - }) - let singleChoiceArr = [] // 鍗曢�� - let judgeArr = [] // 鍒ゆ柇 - let shortArr = [] // 绠�绛� - let multipleChoiceArr = [] // 澶氶�� - let completionArr = [] // 濉┖ + cardList: [ + { + catalogName: "鍗曢�夐", + infoList: [], + }, + { + catalogName: "鍒ゆ柇棰�", + infoList: [], + }, + { + catalogName: "澶氶�夐", + infoList: [], + }, + { + catalogName: "濉┖棰�", + infoList: [], + }, + { + catalogName: "绠�绛旈", + infoList: [], + }, + ], + }); + let singleChoiceArr = []; // 鍗曢�� + let judgeArr = []; // 鍒ゆ柇 + let shortArr = []; // 绠�绛� + let multipleChoiceArr = []; // 澶氶�� + let completionArr = []; // 濉┖ let query = { - path: '*', + path: "*", cmsPath: this.data.rootCmsItemId, - cmsType: '*', + cmsType: "*", productId: this.data.bookId, - queryType: '*', - itemIds: this.data.errorList.map((item) => item + ''), + queryType: "*", + itemIds: this.data.errorList.map((item) => item + ""), itemFields: { Embedded_QuestionBank_Stem: [], Embedded_QuestionBank_AnalysisCon: [], @@ -1359,234 +1500,269 @@ Embedded_QuestionBank_StemStyle: [], Embedded_QuestionBank_OptionStyle: [], Embedded_QuestionBank_KnowledgePoint: [], - Embedded_QuestionBank_Difficulty: [] - } - } + Embedded_QuestionBank_Difficulty: [], + }, + }; await app.MG.store.getProductDetail(query).then((res) => { - let questionArr = [] + let questionArr = []; res.datas.cmsDatas[0].datas.forEach((item, index) => { const questionObj = { number: index + 1, // 棰樺彿 id: item.id, - stem: item.Embedded_QuestionBank_QuestionType == 'completion' ? - JSON.parse(item.Embedded_QuestionBank_Stem) - .stemTxt.replaceAll('<vacancy>', ',input,') - .split(',') : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 + stem: + item.Embedded_QuestionBank_QuestionType == "completion" + ? JSON.parse(item.Embedded_QuestionBank_Stem) + .stemTxt.replaceAll("<vacancy>", ",input,") + .split(",") + : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 answer: item.Embedded_QuestionBank_Answer, // 绛旀 - option: item.Embedded_QuestionBank_Option ? - JSON.parse(item.Embedded_QuestionBank_Option) : '', // 閫夋嫨棰橀�夐」 + option: item.Embedded_QuestionBank_Option + ? JSON.parse(item.Embedded_QuestionBank_Option) + : "", // 閫夋嫨棰橀�夐」 analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽 questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷 optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷 stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷 - difficulty: item.Embedded_QuestionBank_Difficulty ? - 4 - item.Embedded_QuestionBank_Difficulty : 0, // 闅惧害绛夌骇 - userAnswer: item.Embedded_QuestionBank_QuestionType == 'completion' || - item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '', + difficulty: item.Embedded_QuestionBank_Difficulty + ? 4 - item.Embedded_QuestionBank_Difficulty + : 0, // 闅惧害绛夌骇 + userAnswer: + item.Embedded_QuestionBank_QuestionType == "completion" || + item.Embedded_QuestionBank_QuestionType == "multipleChoice" + ? [] + : "", isSubmit: false, // 鏌ョ湅瑙f瀽 isRight: null, // 鏄惁姝g‘ isComplete: false, - isCollect: this.data.collectList.some((collectItem) => collectItem == item.id) - } + isCollect: this.data.collectList.some( + (collectItem) => collectItem == item.id + ), + }; // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 if ( - questionObj.questionType == 'completion' || - questionObj.questionType == 'multipleChoice' + questionObj.questionType == "completion" || + questionObj.questionType == "multipleChoice" ) { try { - questionObj.answer = JSON.parse(questionObj.answer).toString() + questionObj.answer = JSON.parse(questionObj.answer).toString(); } catch (error) { - questionObj.answer = item.Embedded_QuestionBank_Answer + questionObj.answer = item.Embedded_QuestionBank_Answer; } } // 濉┖棰樻敼閫� - if (questionObj.questionType == 'completion') { - let index = 0 + if (questionObj.questionType == "completion") { + let index = 0; for (let i = 0; i < questionObj.stem.length; i++) { - const item = questionObj.stem[i] - if (item == 'input') { + const item = questionObj.stem[i]; + if (item == "input") { questionObj.stem[i] = { num: index, - data: 'input' - } - questionObj.userAnswer[index] = '' - index++ + data: "input", + }; + questionObj.userAnswer[index] = ""; + index++; } } } // 鑾峰彇鍥剧墖 - if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { - questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) + if ( + questionObj.stemStyle == "Image" || + questionObj.stemStyle == "TxtAndImage" + ) { + questionObj.stem.stemImage = getPublicImage( + questionObj.stem.stemImage, + 150 + ); } - if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { - questionObj.option.forEach(optionItem => { - if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) - }) + if ( + questionObj.optionStyle == "Image" || + questionObj.optionStyle == "TxtAndImage" + ) { + questionObj.option.forEach((optionItem) => { + if (optionItem.img) + optionItem.img = getPublicImage(optionItem.img, 150); + }); } // 棰樺共瀵屾枃鏈鐞� - if (questionObj.stemStyle == 'RichText') { + if (questionObj.stemStyle == "RichText") { // questionObj.option.txt = '' - questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ').replace(/\<p/gi, '<p class="stem-rich-p"') - + questionObj.stem.stemTxt = questionObj.stem.stemTxt + .replace( + /\<img/gi, + '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' + ) + .replace(/\<p/gi, '<p class="stem-rich-p"'); } // 閫夐」瀵屾枃鏈鐞� - if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) { - questionObj.option.forEach(item => { - if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"') - }) + if ( + questionObj.optionStyle == "RichText" && + (questionObj.questionType == "singleChoice" || + questionObj.questionType == "judge" || + questionObj.questionType == "multipleChoice") + ) { + questionObj.option.forEach((item) => { + if (item.txt) + item.txt = item.txt + .replace(/\<img/gi, '<img class="option-rich-img"') + .replace(/\<p/gi, '<p class="stem-rich-p"'); + }); } - if (item.Embedded_QuestionBank_QuestionType == 'judge') { - questionObj.type = '鍒ゆ柇棰�' - judgeArr.push(questionObj) - } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { - questionObj.type = '鍗曢�夐' - singleChoiceArr.push(questionObj) - } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') { - questionObj.type = '澶氶�夐' - multipleChoiceArr.push(questionObj) - } else if (item.Embedded_QuestionBank_QuestionType == 'completion') { - questionObj.type = '濉┖棰�' - completionArr.push(questionObj) - } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { - questionObj.type = '绠�绛旈' - shortArr.push(questionObj) + if (item.Embedded_QuestionBank_QuestionType == "judge") { + questionObj.type = "鍒ゆ柇棰�"; + judgeArr.push(questionObj); + } else if (item.Embedded_QuestionBank_QuestionType == "singleChoice") { + questionObj.type = "鍗曢�夐"; + singleChoiceArr.push(questionObj); + } else if ( + item.Embedded_QuestionBank_QuestionType == "multipleChoice" + ) { + questionObj.type = "澶氶�夐"; + multipleChoiceArr.push(questionObj); + } else if (item.Embedded_QuestionBank_QuestionType == "completion") { + questionObj.type = "濉┖棰�"; + completionArr.push(questionObj); + } else if (item.Embedded_QuestionBank_QuestionType == "shortAnswer") { + questionObj.type = "绠�绛旈"; + shortArr.push(questionObj); } // questionArr.push(questionObj) - }) + }); this.setData({ // questionDataList: questionArr, - ['cardList[0].infoList']: singleChoiceArr, - ['cardList[1].infoList']: judgeArr, - ['cardList[2].infoList']: multipleChoiceArr, - ['cardList[3].infoList']: completionArr, - ['cardList[3].infoList']: shortArr, + ["cardList[0].infoList"]: singleChoiceArr, + ["cardList[1].infoList"]: judgeArr, + ["cardList[2].infoList"]: multipleChoiceArr, + ["cardList[3].infoList"]: completionArr, + ["cardList[4].infoList"]: shortArr, // loading: false - }) - const cardList = this.data.cardList + }); + const cardList = this.data.cardList; for (let index = 0; index < cardList.length; index++) { const item = cardList[index]; for (let cindex = 0; cindex < item.infoList.length; cindex++) { - const citem = item.infoList[cindex] - citem.number = cindex + 1 - questionArr.push(citem) + const citem = item.infoList[cindex]; + citem.number = cindex + 1; + questionArr.push(citem); } } this.setData({ questionDataList: questionArr, cardList: cardList, - loading: false - }) - }) + loading: false, + }); + }); // loadings.value = false }, // 鑾峰彇缁勫嵎缁撴灉 async getEduQuizConfig() { await app.MG.edu .getEduQuizConfigResult({ - idOrRefCode: this.data.mockid + idOrRefCode: this.data.mockid, }) .then(async (configRes) => { // 鑾峰彇 鍒嗘暟 鏃堕棿 this.setData({ - 'mockData.score': configRes.score - }) + "mockData.score": configRes.score, + }); try { this.setData({ - 'mockData.time': JSON.parse(configRes.config).time * 1000, - countdownTime: JSON.parse(configRes.config).time * 1000 - }) + "mockData.time": JSON.parse(configRes.config).time * 1000, + countdownTime: JSON.parse(configRes.config).time * 1000, + }); } catch (error) { this.setData({ - 'mockData.time': 3600 * 1000, + "mockData.time": 3600 * 1000, countdownTime: 3600 * 1000, - }) + }); } this.setData({ - 'mockData.sumTime': this.data.mockData.time - }) - let itemIds = [] - let numberIndex = 1 + "mockData.sumTime": this.data.mockData.time, + }); + let itemIds = []; + let numberIndex = 1; // 鑾峰彇鎶介缁撴灉 const cardList = configRes.eduQuizConfigStageResultList.map((item) => { - let questionIds = [] + let questionIds = []; // 鑾峰彇蹇呭惈棰樼洰 let list = item.cmsItemList.map((idItem) => { - itemIds.push(idItem.id + '') + itemIds.push(idItem.id + ""); questionIds.push({ - id: idItem.id + '', - score: idItem.score - }) - numberIndex++ + id: idItem.id + "", + score: idItem.score, + }); + numberIndex++; return { number: numberIndex, id: idItem.id, - score: idItem.score - } - }) + score: idItem.score, + }; + }); // 鑾峰彇鎶介棰樼洰 - let extractList = [] + let extractList = []; for (let i = 0; i < item.generatorResultList.length; i++) { - const extractItem = item.generatorResultList[i] - let extractItemList = extractItem.cmsItemList.map((extractCmsItem) => { - itemIds.push(extractCmsItem.id + '') - questionIds.push({ - id: extractCmsItem.id + '', - score: extractCmsItem.score - }) - numberIndex++ - return { - number: numberIndex, - id: extractCmsItem.id, - score: extractCmsItem.score + const extractItem = item.generatorResultList[i]; + let extractItemList = extractItem.cmsItemList.map( + (extractCmsItem) => { + itemIds.push(extractCmsItem.id + ""); + questionIds.push({ + id: extractCmsItem.id + "", + score: extractCmsItem.score, + }); + numberIndex++; + return { + number: numberIndex, + id: extractCmsItem.id, + score: extractCmsItem.score, + }; } - }) - extractList = extractList.concat(extractItemList) + ); + extractList = extractList.concat(extractItemList); } return { path: item.id, catalogName: item.name, - infoList: list.concat(extractList) - } - }) + infoList: list.concat(extractList), + }; + }); this.setData({ - cardList: cardList - }) + cardList: cardList, + }); // 鏇存柊璇ユ潯缁勫嵎鐨勬暟鎹姸鎬侊紝鍖呮嫭璁板綍鏀硅瘯鍗锋�诲垎锛屾洿鏀圭粍鍗风姸鎬乻tate涓�1锛岃〃绀哄凡缁忔娊棰樺畬鎴愶紝骞惰灏嗘娊灞夋暟鎹褰曚笅鏉� if (this.data.mockData.datas && this.data.mockData.datas.length) { - const mockData = this.data.mockData + const mockData = this.data.mockData; mockData.datas.forEach((item, index) => { if (item.id == this.data.uuid) { - item.state = '1' - item.time = mockData.time - item.score = configRes.score - mockData.state = '1' + item.state = "1"; + item.time = mockData.time; + item.score = configRes.score; + mockData.state = "1"; } - }) + }); this.setData({ - mockData: mockData - }) + mockData: mockData, + }); } - this.setMockInfo(this.data.mockData.datas) // 璁板綍璇曞嵎鎬诲垎 鏃堕暱锛屼慨鏀箂tate涓� 1 + this.setMockInfo(this.data.mockData.datas); // 璁板綍璇曞嵎鎬诲垎 鏃堕暱锛屼慨鏀箂tate涓� 1 // 鏇存柊鏈湴mockData - this.saveMockQuestionList(this.data.cardList) // 璁板綍棰樼洰鍒楄〃 - await this.getMockDataList(this.data.cardList) // 璇锋眰棰樼洰鏁版嵁 - }) + this.saveMockQuestionList(this.data.cardList); // 璁板綍棰樼洰鍒楄〃 + await this.getMockDataList(this.data.cardList); // 璇锋眰棰樼洰鏁版嵁 + }); }, // 鑾峰彇缁勫嵎棰樼洰鍒楄〃 async getMockDataList(questionList, oldList) { - const questionDataList = this.data.questionDataList + const questionDataList = this.data.questionDataList; for (let pathindex = 0; pathindex < questionList.length; pathindex++) { const pathitem = questionList[pathindex]; - let itemIds = [] - pathitem.infoList.forEach(item => { - itemIds.push(item.id + '') - }) + let itemIds = []; + pathitem.infoList.forEach((item) => { + itemIds.push(item.id + ""); + }); let query = { - path: '*', + path: "*", cmsPath: this.data.rootCmsItemId, - cmsType: '*', + cmsType: "*", productId: this.data.bookId, - queryType: '*', + queryType: "*", itemIds, itemFields: { Embedded_QuestionBank_Stem: [], @@ -1597,272 +1773,330 @@ Embedded_QuestionBank_StemStyle: [], Embedded_QuestionBank_OptionStyle: [], Embedded_QuestionBank_KnowledgePoint: [], - Embedded_QuestionBank_Difficulty: [] - } - } + Embedded_QuestionBank_Difficulty: [], + }, + }; await app.MG.store.getProductDetail(query).then((res) => { res.datas.cmsDatas[0].datas.forEach((item, index) => { // 寰幆questionList,缁欐瘡棰樿祴鍊煎垎鏁� - let oldObj - if (oldList) oldObj = oldList.find((oldItem) => oldItem.id == item.id) + let oldObj; + if (oldList) + oldObj = oldList.find((oldItem) => oldItem.id == item.id); let questionObj = { // number: pathitem.infoList.find(infoItem => infoItem.itemId == item.id).number, id: item.id, - score: pathitem.infoList.find(infoItem => infoItem.id == item.id).score, - stem: item.Embedded_QuestionBank_QuestionType == 'completion' ? - JSON.parse(item.Embedded_QuestionBank_Stem) - .stemTxt.replaceAll('<vacancy>', ',input,') - .split(',') : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 + score: pathitem.infoList.find((infoItem) => infoItem.id == item.id) + .score, + stem: + item.Embedded_QuestionBank_QuestionType == "completion" + ? JSON.parse(item.Embedded_QuestionBank_Stem) + .stemTxt.replaceAll("<vacancy>", ",input,") + .split(",") + : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 answer: item.Embedded_QuestionBank_Answer, // 绛旀 - option: item.Embedded_QuestionBank_Option ? - JSON.parse(item.Embedded_QuestionBank_Option) : '', // 閫夋嫨棰橀�夐」 + option: item.Embedded_QuestionBank_Option + ? JSON.parse(item.Embedded_QuestionBank_Option) + : "", // 閫夋嫨棰橀�夐」 analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽 questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷 optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷 stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷 - difficulty: item.Embedded_QuestionBank_Difficulty ? - 4 - item.Embedded_QuestionBank_Difficulty : 0, // 闅惧害绛夌骇 - userAnswer: oldObj ? - oldObj.answer : item.Embedded_QuestionBank_QuestionType == 'completion' || - item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '', + difficulty: item.Embedded_QuestionBank_Difficulty + ? 4 - item.Embedded_QuestionBank_Difficulty + : 0, // 闅惧害绛夌骇 + userAnswer: oldObj + ? oldObj.answer + : item.Embedded_QuestionBank_QuestionType == "completion" || + item.Embedded_QuestionBank_QuestionType == "multipleChoice" + ? [] + : "", isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false, isRight: oldObj ? oldObj.isRight : null, // isComplete: oldObj ? oldObj.isComplete : false, - isComplete: this.data.mockData.state == '3' ? true : false, - isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false, - isUnfold: '' // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� - } + isComplete: this.data.mockData.state == "3" ? true : false, + isCollect: + this.data.collectList.indexOf(item.id) > -1 ? true : false, + isUnfold: "", // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� + }; // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 if ( - questionObj.questionType == 'completion' || - questionObj.questionType == 'multipleChoice' + questionObj.questionType == "completion" || + questionObj.questionType == "multipleChoice" ) { try { - questionObj.answer = JSON.parse(questionObj.answer).toString() + questionObj.answer = JSON.parse(questionObj.answer).toString(); } catch (error) { - questionObj.answer = item.Embedded_QuestionBank_Answer + questionObj.answer = item.Embedded_QuestionBank_Answer; } } // 濉┖棰樻敼閫� - if (questionObj.questionType == 'completion') { - let index = 0 + if (questionObj.questionType == "completion") { + let index = 0; for (let i = 0; i < questionObj.stem.length; i++) { - const item = questionObj.stem[i] - if (item == 'input') { + const item = questionObj.stem[i]; + if (item == "input") { questionObj.stem[i] = { num: index, - data: 'input' - } - if (!oldObj) questionObj.userAnswer[index] = '' - index++ + data: "input", + }; + if (!oldObj) questionObj.userAnswer[index] = ""; + index++; } } } // 棰樺共瀵屾枃鏈鐞� - if (questionObj.stemStyle == 'RichText') { + if (questionObj.stemStyle == "RichText") { // questionObj.option.txt = '' - questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img"') + questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace( + /\<img/gi, + '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img"' + ); } // 閫夐」瀵屾枃鏈鐞� - if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) { - questionObj.option.forEach(item => { - if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"') - }) + if ( + questionObj.optionStyle == "RichText" && + (questionObj.questionType == "singleChoice" || + questionObj.questionType == "judge" || + questionObj.questionType == "multipleChoice") + ) { + questionObj.option.forEach((item) => { + if (item.txt) + item.txt = item.txt.replace( + /\<img/gi, + '<img class="option-rich-img"' + ); + }); } // 鑾峰彇鍥剧墖 - if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { - questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) + if ( + questionObj.stemStyle == "Image" || + questionObj.stemStyle == "TxtAndImage" + ) { + questionObj.stem.stemImage = getPublicImage( + questionObj.stem.stemImage, + 150 + ); } - if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { - questionObj.option.forEach(optionItem => { - if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) - }) + if ( + questionObj.optionStyle == "Image" || + questionObj.optionStyle == "TxtAndImage" + ) { + questionObj.option.forEach((optionItem) => { + if (optionItem.img) + optionItem.img = getPublicImage(optionItem.img, 150); + }); } // 瀹㈣棰樻�诲垎璧嬪�� - if (questionObj.questionType !== 'shortAnswer') { + if (questionObj.questionType !== "shortAnswer") { this.setData({ - subjectiveGrade: this.data.subjectiveGrade + questionObj.score - }) + subjectiveGrade: this.data.subjectiveGrade + questionObj.score, + }); } if (oldObj && oldObj.isRight) { this.setData({ - correctNum: this.data.correctNum + 1 - }) + correctNum: this.data.correctNum + 1, + }); } - if (item.questionType != 'shortAnswer' && item.isComplete) { + if (item.questionType != "shortAnswer" && item.isComplete) { this.setData({ - subjectiveTotal: this.data.subjectiveTotal + 1 - }) + subjectiveTotal: this.data.subjectiveTotal + 1, + }); } // if (oldObj && isHaveAnswer(oldObj.answer)) countDownRef.value.changeAlready() // cardList璧嬪�� - let cardIndex = this.data.cardList.findIndex((item) => item.catalogName == pathitem.catalogName) - let infoIndex = this.data.cardList[cardIndex].infoList.findIndex(infoItem => infoItem.id == item.id) + let cardIndex = this.data.cardList.findIndex( + (item) => item.catalogName == pathitem.catalogName + ); + let infoIndex = this.data.cardList[cardIndex].infoList.findIndex( + (infoItem) => infoItem.id == item.id + ); this.setData({ - [`cardList[${cardIndex}].infoList[${infoIndex}]`]: questionObj - }) - let questionList = [] - const cardUpdatedList = this.data.cardList - cardUpdatedList.forEach(aitem => { + [`cardList[${cardIndex}].infoList[${infoIndex}]`]: questionObj, + }); + let questionList = []; + const cardUpdatedList = this.data.cardList; + cardUpdatedList.forEach((aitem) => { aitem.infoList.forEach((bitem, bindex) => { - questionList.push(bitem) - bitem.number = bindex + 1 - }) - }) + questionList.push(bitem); + bitem.number = bindex + 1; + }); + }); this.setData({ questionDataList: questionList, - cardList: cardUpdatedList - }) - }) - }) + cardList: cardUpdatedList, + }); + }); + }); } this.setData({ - loading: false - }) + loading: false, + }); }, // 鑾峰彇缁勫嵎鏁版嵁 getMockInfo(callback) { app.MG.identity .getUserKey({ - domain: 'mockData', - keys: [this.data.bookId] + domain: "mockData", + keys: [this.data.bookId], }) .then((res) => { - if (callback) callback(res) - }) + if (callback) callback(res); + }); }, // 璁板綍璐拱缁勫嵎鏃堕棿 setMockInfo(data) { app.MG.identity.setUserKey({ - setKeyRequests: [{ - domain: 'mockData', - key: this.data.bookId + '', - value: JSON.stringify(data) - }] - }) + setKeyRequests: [ + { + domain: "mockData", + key: this.data.bookId + "", + value: JSON.stringify(data), + }, + ], + }); }, // 璁板綍缁勫嵎棰樼洰鍒楄〃 saveMockQuestionList(data) { app.MG.identity .setUserKey({ - setKeyRequests: [{ - domain: 'mockQuestionData', - key: this.data.uuid, - value: JSON.stringify(data) - }] + setKeyRequests: [ + { + domain: "mockQuestionData", + key: this.data.uuid, + value: JSON.stringify(data), + }, + ], }) .then((res) => { - console.log('妯¤�冮鐩垪琛ㄥ凡璁板綍') - }) + console.log("妯¤�冮鐩垪琛ㄥ凡璁板綍"); + }); }, // 鑾峰彇璁板綍缁勫嵎棰樼洰鍒楄〃 async getMockQuestionList() { - let list = [] + let list = []; await app.MG.identity .getUserKey({ - domain: 'mockQuestionData', - keys: [this.data.uuid] + domain: "mockQuestionData", + keys: [this.data.uuid], }) .then((res) => { - list = JSON.parse(res[0].value) - }) - return list + list = JSON.parse(res[0].value); + }); + return list; }, // 鑾峰彇妯¤�冪敤鎴风瓟棰樻暟鎹� async getMockAnswer() { - let data + let data; await app.MG.identity .getUserKey({ - domain: 'mockAnswerData', - keys: [this.data.uuid] + domain: "mockAnswerData", + keys: [this.data.uuid], }) .then((res) => { if (res[0]) { this.setData({ currentIndex: JSON.parse(res[0].value).currentIndex, - 'mockData.time': JSON.parse(res[0].value).time, - countdownTime: JSON.parse(res[0].value).time ? JSON.parse(res[0].value).time : this.data.mockData.sumTime, - 'mockData.answer': JSON.parse(res[0].value).answerData - }) + "mockData.time": JSON.parse(res[0].value).time, + countdownTime: JSON.parse(res[0].value).time + ? JSON.parse(res[0].value).time + : this.data.mockData.sumTime, + "mockData.answer": JSON.parse(res[0].value).answerData, + }); console.log(JSON.parse(res[0].value)); - data = JSON.parse(res[0].value).answerData + data = JSON.parse(res[0].value).answerData; } - }) - return data + }); + return data; }, // 璁板綍妯¤�冪瓟棰樻暟鎹� saveMockData() { - const data = this.data.mockData.datas.find((itme) => itme.id == this.data.uuid) - if (data.state == '3') return true - const saveData = this.data.mockData.answer + const data = this.data.mockData.datas.find( + (itme) => itme.id == this.data.uuid + ); + if (data.state == "3") return true; + const saveData = this.data.mockData.answer; for (let i = 0; i < this.data.questionDataList.length; i++) { - const item = this.data.questionDataList[i] + const item = this.data.questionDataList[i]; if (this.isHaveAnswer(item.userAnswer)) { - const index = saveData.findIndex((saveitem) => saveitem.id == item.id) - if (index + '' != '-1') { - saveData[index].answer = item.userAnswer + const index = saveData.findIndex((saveitem) => saveitem.id == item.id); + if (index + "" != "-1") { + saveData[index].answer = item.userAnswer; } else { saveData.push({ id: item.id, - answer: item.userAnswer - }) + answer: item.userAnswer, + }); } } } - // - if (this.data.mockData.state == '1') { - const datas = this.data.mockData.datas + // + if (this.data.mockData.state == "1") { + const datas = this.data.mockData.datas; datas.forEach((item) => { if (item.id == this.data.uuid) { - item.state = '2' + item.state = "2"; } - }) - this.setMockInfo(datas) + }); + this.setMockInfo(datas); } - // + // app.MG.identity .setUserKey({ - setKeyRequests: [{ - domain: 'mockAnswerData', - key: this.data.uuid, - value: JSON.stringify({ - currentIndex: this.data.currentIndex, - time: this.data.countdownTime, - answerData: saveData - }) - }] + setKeyRequests: [ + { + domain: "mockAnswerData", + key: this.data.uuid, + value: JSON.stringify({ + currentIndex: this.data.currentIndex, + time: this.data.countdownTime, + answerData: saveData, + }), + }, + ], }) .then((res) => { this.setData({ - saveTime: 20 - }) - console.log('妯¤�冪瓟棰樻暟鎹凡璁板綍') - }) + saveTime: 20, + }); + console.log("妯¤�冪瓟棰樻暟鎹凡璁板綍"); + }); }, // 瀵屾枃鏈鐞� formatRichText(html) { console.log(html); let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) { - match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, ''); - match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, ''); - match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, ''); - return match; - }); - newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) { match = match - .replace(/<p>/gi, '<p class="p_class">') - .replace(/width:[^;]+;/gi, 'max-width:100%;') - .replace(/width:[^;]+;/gi, 'max-width:100%;'); + .replace(/style="[^"]+"/gi, "") + .replace(/style='[^']+'/gi, ""); + match = match + .replace(/width="[^"]+"/gi, "") + .replace(/width='[^']+'/gi, ""); + match = match + .replace(/height="[^"]+"/gi, "") + .replace(/height='[^']+'/gi, ""); return match; }); + newContent = newContent.replace( + /style="[^"]+"/gi, + function (match, capture) { + match = match + .replace(/<p>/gi, '<p class="p_class">') + .replace(/width:[^;]+;/gi, "max-width:100%;") + .replace(/width:[^;]+;/gi, "max-width:100%;"); + return match; + } + ); newContent = newContent.replace(/<br[^>]*\/>/gi, ""); newContent = newContent.replace(/<a>/gi, '<a class="p_class "'); newContent = newContent.replace(/<li>/gi, '<li class="p_class "'); newContent = newContent.replace(/\<p/gi, '<p class="p_class "'); newContent = newContent.replace(/\<span/gi, '<span class="p_class "'); - newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"'); + newContent = newContent.replace( + /\<img/gi, + '<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"' + ); return newContent; - } -}) \ No newline at end of file + }, +}); diff --git a/packageBookService/pages/bookServices/examination/questionList/index.wxml b/packageBookService/pages/bookServices/examination/questionList/index.wxml index 02022f2..6d3cdc5 100644 --- a/packageBookService/pages/bookServices/examination/questionList/index.wxml +++ b/packageBookService/pages/bookServices/examination/questionList/index.wxml @@ -155,7 +155,6 @@ </t-radio-group> <!-- 澶氶�夐 --> <t-checkbox-group - disabled="{{item.isComplete}}" class="checkbox-group" wx:elif="{{item.questionType == 'multipleChoice'}}" t-class="box" @@ -172,6 +171,7 @@ wx:key="contentIndex" > <t-checkbox + disabled="{{item.isComplete}}" icon="rectangle" block="{{false}}" value="{{contentItem.value}}" diff --git a/packageBookService/pages/bookServices/examination/questionOptions/index.wxml b/packageBookService/pages/bookServices/examination/questionOptions/index.wxml index ed07b9f..3179207 100644 --- a/packageBookService/pages/bookServices/examination/questionOptions/index.wxml +++ b/packageBookService/pages/bookServices/examination/questionOptions/index.wxml @@ -75,6 +75,26 @@ <text class="un-answered explain-color-box"></text> <text>鏈瓟</text> </view> + <view + class="error-box" + wx:if="{{((answerType == 'option' || answerType == 'mock') && submitStatus) || answerType == 'collectQuestion' || answerType == 'errorQuestion'}}" + > + <text + class="explain-color-box" + style="background-color: #ee1818" + ></text> + <text>閿欒</text> + </view> + <view + class="correct-box" + wx:if="{{((answerType == 'option' || answerType == 'mock') && submitStatus) || answerType == 'collectQuestion' || answerType == 'errorQuestion'}}" + > + <text + class="explain-color-box" + style="background-color: #1fbc1f" + ></text> + <text>姝g‘</text> + </view> </view> <view class="question-card-list"> <view wx:for="{{cardList}}" wx:key="index" class="card-box"> @@ -91,7 +111,7 @@ wx:for-item="citem" wx:for-index="cindex" wx:key="cindex" - class="question-box {{citem.isUserAnswer ? 'answered' : 'un-answered'}}" + class="question-box {{ citem.isUserAnswer ? 'answered' : 'un-answered' }} {{ ( ((answerType == 'option' || answerType == 'mock') && submitStatus || answerType == 'collectQuestion' || answerType == 'errorQuestion') && citem.questionType !== 'shortAnswer' ) ? citem.isRight ? 'correct-box-color' : 'error-box-color' : ''}} " > {{citem.number}} </view> diff --git a/packageBookService/pages/bookServices/examination/questionOptions/index.wxss b/packageBookService/pages/bookServices/examination/questionOptions/index.wxss index 291ce81..4df83a5 100644 --- a/packageBookService/pages/bookServices/examination/questionOptions/index.wxss +++ b/packageBookService/pages/bookServices/examination/questionOptions/index.wxss @@ -71,12 +71,16 @@ justify-content: flex-end; } -.explain-un-answered { +.explain-un-answered, +.correct-box, +.error-box { margin-left: 80rpx; } .explain-answered, -.explain-un-answered { +.explain-un-answered, +.correct-box, +.error-box { display: flex; align-items: center; } @@ -132,6 +136,16 @@ color: #fff; } +.error-box-color { + background-color: #EE1818; + color: #fff; +} + +.correct-box-color { + background-color: #1FBC1F; + color: #fff; +} + .un-answered { background-color: #F1F3F8; color: #B4B6BD; diff --git a/static/images/bookService/detail/link-click.png b/static/images/bookService/detail/link-click.png new file mode 100644 index 0000000..4e050a3 --- /dev/null +++ b/static/images/bookService/detail/link-click.png Binary files differ diff --git a/static/images/bookService/detail/link.png b/static/images/bookService/detail/link.png new file mode 100644 index 0000000..0a91a49 --- /dev/null +++ b/static/images/bookService/detail/link.png Binary files differ -- Gitblit v1.9.1