From 8dc4e50769a7ebc5f0a3d766f61aa08b8f23b772 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期五, 06 九月 2024 11:23:21 +0800 Subject: [PATCH] login --- packageBookService/pages/bookServices/examination/examination.js | 137 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 104 insertions(+), 33 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index ceac28b..c96c46d 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -14,6 +14,8 @@ countdownInterval: null, // 璁℃椂鍣� isCountdownRunning: true, // 鏄惁鍊掕鏃� countdownTime: 0, // 鍊掕鏃舵椂闂� + storeInfo: '', + jslx: '', bookId: "", productLinkPath: "", rootCmsItemId: "", @@ -47,7 +49,8 @@ sliderValue: 0, // 瀛椾綋婊戝潡 startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿 pauseTime: 0, //鏆傚仠鏃堕棿 - showDialog: false // 鏈彁浜ら��鍑烘嫤鎴脊绐� + showDialog: false, // 鏈彁浜ら��鍑烘嫤鎴脊绐� + showId: '' }, /** @@ -67,15 +70,23 @@ rootCmsItemId: options.rootCmsItemId, idPathList: options.idPathList ? JSON.parse(options.idPathList) : [], answerType: options.answerType, + storeInfo: options.storeInfo, + jslx: options.jslx, }); - // wx.setNavigationBarTitle({ - // title: options.answerTitle, - // }) + wx.setNavigationBarTitle({ + title: options.answerTitle, + }) if (this.data.answerType == "mock") { this.setData({ uuid: options.uuid, mockid: options.mockid, }); + } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + if (data) {} else {} + }) } this.init(); }, @@ -198,7 +209,20 @@ }, }); }, - + // 淇敼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灞炴�у�� @@ -235,26 +259,28 @@ }, // 杩斿洖鎷︽埅 beforeleave() { - 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(); - } - }, - }); + 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({ @@ -269,9 +295,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() { @@ -329,11 +367,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") && @@ -432,7 +472,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) { @@ -496,7 +535,6 @@ // 鎻愪氦閫昏緫 submitPaper() { this.setData({ - showDialog: false, submitStatus: true, loading: true, }); @@ -563,6 +601,7 @@ } this.setData({ loading: false, + showDialog: false, }); }, // 鍒濆鍖栧嚱鏁� @@ -662,6 +701,7 @@ subjectiveNum: 0, currentIndex: 0, submitStatus: false, + showDialog: true }); if (this.data.answerType == "option") { this.setData({ @@ -787,6 +827,7 @@ let query = { path: "*", queryType: "*", + productId: this.data.bookId, cmsPath: pathitem.productLinkPath, itemFields: { @@ -806,6 +847,9 @@ size: 999, }, }; + if (this.data.storeInfo) { + query.storeInfo = this.data.storeInfo + } await app.MG.store.getProductDetail(query).then((res) => { this.setData({ total: res.datas.cmsDatas[0].datas.length, @@ -822,6 +866,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); @@ -993,6 +1050,9 @@ questionDataList: questionList, cardList: cardUpdatedList, }); + console.log( + '棰樼洰', this.data.questionDataList + ); }); }); } @@ -1007,6 +1067,7 @@ } this.setData({ loading: false, + showId: this.data.questionDataList[0].id }); }, // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級 @@ -1198,7 +1259,6 @@ } } } - this.setAnswerInfo(setInfoData); }, // 鎻愪氦绛旈鏁版嵁 @@ -1326,6 +1386,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) => { @@ -1480,6 +1543,7 @@ } this.setData({ questionDataList: questionArr, + showId: questionArr[0].id, cardList: cardList, loading: false, }); @@ -1572,6 +1636,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) => { @@ -1728,11 +1795,11 @@ } this.setData({ questionDataList: questionArr, + showId: questionArr[0].id, cardList: cardList, loading: false, }); }); - // loadings.value = false }, // 鑾峰彇缁勫嵎缁撴灉 async getEduQuizConfig() { @@ -1857,6 +1924,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,缁欐瘡棰樿祴鍊煎垎鏁� @@ -2011,6 +2081,7 @@ } this.setData({ loading: false, + showId: this.data.questionDataList[0].id }); }, // 鑾峰彇缁勫嵎鏁版嵁 -- Gitblit v1.9.1