From 892efc9976feb68ce1a3a4d759317e2585d67ebe Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期六, 07 九月 2024 18:16:18 +0800 Subject: [PATCH] bug修改 --- packageBookService/pages/bookServices/examination/examination.js | 205 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 157 insertions(+), 48 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index 070b53f..b75af1a 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -1,6 +1,9 @@ import { getPublicImage } from "../../../../assets/js/middleGround/tool"; +import { + loginInfo +} from '../../../../assets/js/login'; const app = getApp(); Page({ /** @@ -14,6 +17,8 @@ countdownInterval: null, // 璁℃椂鍣� isCountdownRunning: true, // 鏄惁鍊掕鏃� countdownTime: 0, // 鍊掕鏃舵椂闂� + storeInfo: '', + jslx: '', bookId: "", productLinkPath: "", rootCmsItemId: "", @@ -47,7 +52,9 @@ sliderValue: 0, // 瀛椾綋婊戝潡 startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿 pauseTime: 0, //鏆傚仠鏃堕棿 - + showDialog: false, // 鏈彁浜ら��鍑烘嫤鎴脊绐� + showId: '', + isShowDialog: false, // 娴嬭瘯鎶ュ憡寮圭獥鏄惁鏄剧ず }, /** @@ -67,15 +74,33 @@ rootCmsItemId: options.rootCmsItemId, idPathList: options.idPathList ? JSON.parse(options.idPathList) : [], answerType: options.answerType, + storeInfo: options.storeInfo, + jslx: options.jslx, }); + wx.setNavigationBarTitle({ + title: options.answerTitle, + }) if (this.data.answerType == "mock") { this.setData({ uuid: options.uuid, mockid: options.mockid, }); } - this.init(); - console.log("浼犲弬", options); + + const token = wx.getStorageSync(app.config.tokenKey) + + if (!token) { + loginInfo(app, (data) => { + if (data) { + this.init(); + } else { + this.init(); + } + }) + } else { + this.init() + } + }, /** @@ -196,21 +221,34 @@ }, }); }, - + // 淇敼nav棰滆壊 + changeNavBarColor(e) { + if (type == 'night') { + wx.setNavigationBarColor({ + backgroundColor: '#000000', + frontColor: '#ffffff', + }) + } else { + wx.setNavigationBarColor({ + backgroundColor: '#ffffff', + frontColor: '#000000', + }) + } + }, // 姝e垯鎵惧嚭鍚姏src extractSourceSrc(htmlString) { // 姝e垯琛ㄨ揪寮忓尮閰�<source>鏍囩涓殑src灞炴�у�� var srcRegex = /<source\s+src="([^"]+)"/i; var srcTwo = /<audio\s+src="([^"]+)"/i; - + // 鎵ц姝e垯鍖归厤 var match = srcRegex.exec(htmlString); const local = srcTwo.exec(htmlString) // 濡傛灉鍖归厤鎴愬姛锛岃繑鍥炵涓�涓崟鑾风粍鐨勫唴瀹癸紙src灞炴�х殑鍊硷級 if (match && match[1]) { - return match[1].replace( '../file', app.config.requestCtx + '/file'); + return match[1].replace('../file', app.config.requestCtx + '/file'); } else if (local && local[1]) { - return local[1].replace( '../file', app.config.requestCtx + '/file') + return local[1].replace('../file', app.config.requestCtx + '/file') } else { // 濡傛灉娌℃湁鍖归厤鍒帮紝杩斿洖null return null; @@ -233,21 +271,28 @@ }, // 杩斿洖鎷︽埅 beforeleave() { - wx.showModal({ - title: "鎻愮ず", - content: "鏈彁浜わ紝鏄惁閫�鍑虹瓟棰�", - confirmColor: "#ff6c00", - cancelColor: "#949494", - complete: (res) => { - if (res.cancel) {} - if (res.confirm) { - this.setData({ - submitStatus: true, - }); - wx.navigateBack(); - } - }, - }); + if ((this.data.answerType == 'option' || this.data.answerType == 'mock') && !this.data.submitStatus) { + wx.showModal({ + title: "鎻愮ず", + content: "鏈彁浜わ紝鏄惁閫�鍑虹瓟棰�", + confirmColor: "#ff6c00", + cancelColor: "#949494", + complete: (res) => { + if (res.cancel) { + this.setData({ + showDialog: true + }) + } + if (res.confirm) { + this.setData({ + submitStatus: true, + showDialog: false + }); + wx.navigateBack(); + } + }, + }); + } }, onChangeSlider(e) { this.setData({ @@ -262,9 +307,21 @@ }, //璁剧疆鑳屾櫙鑹� changeBGColor(e) { + const flag = e.detail.value this.setData({ - isNight: e.detail.value, + isNight: flag, }); + if (flag) { + wx.setNavigationBarColor({ + backgroundColor: '#000000', + frontColor: '#ffffff', + }) + } else { + wx.setNavigationBarColor({ + backgroundColor: '#ffffff', + frontColor: '#000000', + }) + } }, // 鑾峰彇淇濆瓨鐨勫�掕鏃舵椂闂� getSavedTime() { @@ -322,11 +379,13 @@ }, // 鍒囨崲棰樼洰 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]; + const lastItem = this.data.questionDataList[index + 1]; + this.setData({ + currentIndex: e.detail.index, + showId: lastItem.id + }); if ( (this.data.answerType == "collectQuestion" || this.data.answerType == "errorQuestion") && @@ -425,7 +484,6 @@ 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) => { if (item.id == id) { @@ -492,7 +550,8 @@ submitStatus: true, loading: true, }); - const child = this.selectComponent("#question-options"); + const child = this.selectComponent('#question-options'); + if ( this.data.answerType == "option" || this.data.answerType == "errorQuestion" || @@ -508,7 +567,11 @@ if (this.data.answerType == "option") { this.toggleCountdown(); this.recordAnswerData(); - child.openTestReportDialog(); + // this.selectComponent 鎷夸笉鍒� 缁勪欢浜嗭紝 鏀逛负鐩戝惉缁勪欢浼犲�� 鎵撳紑寮圭獥 + // child.openTestReportDialog(); + this.setData({ + isShowDialog: true + }) } else if ( this.data.answerType == "collectQuestion" || this.data.answerType == "errorQuestion" @@ -551,10 +614,14 @@ }), }, ], }); - child.openTestReportDialog(); + // child.openTestReportDialog(); + this.setData({ + isShowDialog: true + }) } this.setData({ loading: false, + showDialog: false, }); }, // 鍒濆鍖栧嚱鏁� @@ -567,7 +634,6 @@ }); if (this.data.answerType == "option") { if (this.data) - // this.startCountdown() this.setData({ countdownTime: 2 * 60 * 60 * 1000, }); @@ -631,6 +697,9 @@ oldMockData.state == "2" ) { this.startCountdown(); + this.setData({ + showDialog: true + }) } if (oldMockData.state == "3") { this.setData({ @@ -652,6 +721,7 @@ subjectiveNum: 0, currentIndex: 0, submitStatus: false, + showDialog: true }); if (this.data.answerType == "option") { this.setData({ @@ -730,6 +800,9 @@ await this.getQuestionList(value.dataList); } else { await this.getQuestionList(); // 鑾峰彇棰樺簱棰樼洰 + this.setData({ + showDialog: true + }) } }); } @@ -774,6 +847,7 @@ let query = { path: "*", queryType: "*", + productId: this.data.bookId, cmsPath: pathitem.productLinkPath, itemFields: { @@ -793,10 +867,10 @@ size: 999, }, }; + if (this.data.storeInfo) { + query.storeInfo = this.data.storeInfo + } await app.MG.store.getProductDetail(query).then((res) => { - if (!res.datas.cmsDatas[0].datas.length) return this.setData({ - noData: true - }) this.setData({ total: res.datas.cmsDatas[0].datas.length, }); @@ -812,6 +886,19 @@ }); } res.datas.cmsDatas[0].datas.forEach((item, index) => { + if (this.data.storeInfo || this.data.jslx) { + if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { + pathitem.name = "鍗曢�夐" + } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { + pathitem.name = "绠�绛旈" + } else if (item.Embedded_QuestionBank_QuestionType == "completion") { + pathitem.name = "濉┖棰�"; + } else if (item.Embedded_QuestionBank_QuestionType == "multipleChoice") { + pathitem.name = "澶氶�夐"; + } else if (item.Embedded_QuestionBank_QuestionType == "judge") { + pathitem.name = "鍒ゆ柇棰�"; + } + } let oldObj = ""; if (oldList) oldObj = oldList.find((oldItem) => oldItem.id == item.id); @@ -875,7 +962,7 @@ /\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' ) - .replace(/\<p/gi, '<p class="stem-rich-p"'); + .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file'); } // 閫夐」瀵屾枃鏈鐞� if ( @@ -888,7 +975,7 @@ if (item.txt) item.txt = item.txt .replace(/\<img/gi, '<img class="option-rich-img"') - .replace(/\<p/gi, '<p class="stem-rich-p"'); + .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file'); }); } // 瑙f瀽瀵屾枃鏈鐞� @@ -983,13 +1070,24 @@ questionDataList: questionList, cardList: cardUpdatedList, }); + console.log( + '棰樼洰', this.data.questionDataList + ); }); }); } // 鏈夐鐩啀寮�濮嬪�掕鏃� - if (this.data.questionDataList.length) this.startCountdown(); + if (this.data.questionDataList.length) { + console.log(this.data.questionDataList); + this.startCountdown(); + } else { + this.setData({ + noData: true + }) + } this.setData({ loading: false, + showId: this.data.questionDataList[0].id }); }, // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級 @@ -1023,7 +1121,7 @@ // 绠�绛� 缈昏瘧 questionList[index].isRight = null; } else if (item.questionType == "completion") { - if (item.answer == "string") { + if (typeof item.answer == "string") { item.isRight = item.answer == item.userAnswer[0]; } else { if (item.answer.length != item.userAnswer.length) { @@ -1181,7 +1279,6 @@ } } } - this.setAnswerInfo(setInfoData); }, // 鎻愪氦绛旈鏁版嵁 @@ -1309,6 +1406,9 @@ Embedded_QuestionBank_Difficulty: [], }, }; + if (this.data.storeInfo) { + query.storeInfo = this.data.storeInfo + } await app.MG.store.getProductDetail(query).then((res) => { let questionArr = []; res.datas.cmsDatas[0].datas.forEach((item, index) => { @@ -1388,7 +1488,7 @@ /\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' ) - .replace(/\<p/gi, '<p class="stem-rich-p"'); + .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file'); } // 閫夐」瀵屾枃鏈鐞� if ( @@ -1401,7 +1501,7 @@ if (item.txt) item.txt = item.txt .replace(/\<img/gi, '<img class="option-rich-img"') - .replace(/\<p/gi, '<p class="stem-rich-p"'); + .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file'); }); } // 瑙f瀽瀵屾枃鏈鐞� @@ -1463,6 +1563,7 @@ } this.setData({ questionDataList: questionArr, + showId: questionArr[0].id, cardList: cardList, loading: false, }); @@ -1555,6 +1656,9 @@ Embedded_QuestionBank_Difficulty: [], }, }; + if (this.data.storeInfo) { + query.storeInfo = this.data.storeInfo + } await app.MG.store.getProductDetail(query).then((res) => { let questionArr = []; res.datas.cmsDatas[0].datas.forEach((item, index) => { @@ -1636,7 +1740,7 @@ /\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' ) - .replace(/\<p/gi, '<p class="stem-rich-p"'); + .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file'); } // 閫夐」瀵屾枃鏈鐞� if ( @@ -1649,7 +1753,7 @@ if (item.txt) item.txt = item.txt .replace(/\<img/gi, '<img class="option-rich-img"') - .replace(/\<p/gi, '<p class="stem-rich-p"'); + .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file'); }); } // 瑙f瀽瀵屾枃鏈鐞� @@ -1711,11 +1815,11 @@ } this.setData({ questionDataList: questionArr, + showId: questionArr[0].id, cardList: cardList, loading: false, }); }); - // loadings.value = false }, // 鑾峰彇缁勫嵎缁撴灉 async getEduQuizConfig() { @@ -1840,6 +1944,9 @@ Embedded_QuestionBank_Difficulty: [], }, }; + if (this.data.storeInfo) { + query.storeInfo = this.data.storeInfo + } await app.MG.store.getProductDetail(query).then((res) => { res.datas.cmsDatas[0].datas.forEach((item, index) => { // 寰幆questionList,缁欐瘡棰樿祴鍊煎垎鏁� @@ -1906,7 +2013,7 @@ 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"').replace('../file', app.config.requestCtx + '/file'); } // 閫夐」瀵屾枃鏈鐞� if ( @@ -1920,7 +2027,7 @@ item.txt = item.txt.replace( /\<img/gi, '<img class="option-rich-img"' - ); + ).replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file'); }); } // 鍚姏棰樹慨鏀� @@ -1994,6 +2101,7 @@ } this.setData({ loading: false, + showId: this.data.questionDataList[0].id }); }, // 鑾峰彇缁勫嵎鏁版嵁 @@ -2054,11 +2162,12 @@ }) .then((res) => { if (res[0]) { + // 杩欓噷鐨� countdownTime 璧嬪�硷細濡傛灉鏄椂闂村埌浜嗘彁浜わ紝璁板綍鐨勫墿浣欐椂闂村氨鏄�0锛屾墍浠ワ細濡傛灉鏄�0鐨勮瘽璧嬪��1绉掞紝闃叉鐩戝惉鍒版椂闂翠负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, + countdownTime: JSON.parse(res[0].value).time > 0 ? + JSON.parse(res[0].value).time : 1000, "mockData.answer": JSON.parse(res[0].value).answerData, }); console.log(JSON.parse(res[0].value)); -- Gitblit v1.9.1