From ecabd20b3dfbd956dad14ffb6ba3dc2efcfdd7c1 Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期一, 25 三月 2024 16:23:32 +0800 Subject: [PATCH] 微信支付 --- packageBookService/pages/bookServices/examination/examination.js | 562 ++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 388 insertions(+), 174 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index e5c3c26..e444433 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -39,13 +39,24 @@ time: 0, // 绛旈鍓╀綑鏃堕棿 datas: [], // 鎵�鏈夋ā鑰冭褰曟暟鎹�(棰樼洰鍒楄〃锛岀敤鎴风瓟棰橈紝鑰冭瘯鎶ュ憡) answer: [] - } + }, + saveTime: 20, + isNight: false }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { + // wx.enableAlertBeforeUnload({ + // message: "鏈彁浜わ紝鏄惁閫�鍑虹瓟棰橈紵", + // success: function (res) { + // console.log('纭畾', res); + // }, + // fail: function (err) { + // console.log("澶辫触锛�", err); + // }, + // }); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� @@ -73,27 +84,48 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 */ onReady() { - }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ onShow() { - + if (this.data.answerType != 'mock') { + if (wx.timer) { + clearInterval(wx.timer) + } + } + if (this.data.answerType == 'mock') { + if (wx.timer) { + clearInterval(wx.timer) + } + wx.timer = setInterval(() => { + this.setData({ + saveTime: this.data.saveTime - 1 + }) + if (this.data.saveTime == 0) { + this.saveMockData() + } + }, 1000) + } }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 */ onHide() { - + if (wx.timer) { + clearInterval(wx.timer) + } }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 */ - onUnload() { + onUnload(e) { + if (wx.timer) { + clearInterval(wx.timer) + } if (this.data.countdownInterval !== null) { clearInterval(this.data.countdownInterval) } @@ -118,11 +150,37 @@ */ onShareAppMessage() { }, - // 杩斿洖 - goBack() { - wx.navigateBack(); + + // 鐩戝惉watch + watch(context, variableName, callback) { + let value = context.data[variableName]; // 鑾峰彇琚洃鍚睘鎬х殑褰撳墠鍊� + + // 浣跨敤 Object.defineProperty 鏂规硶鍦ㄦ暟鎹璞′笂瀹氫箟灞炴�х殑 getter 鍜� setter + Object.defineProperty(context.data, variableName, { + configurable: true, // 鍙厤缃� + enumerable: true, // 鍙灇涓� + get: function () { + return value; // 杩斿洖灞炴�х殑褰撳墠鍊� + }, + set: function (newVal) { + const oldVal = value; // 璁板綍灞炴�х殑鏃у�� + value = newVal; // 鏇存柊灞炴�х殑鍊� + callback.call(context, newVal, oldVal); // 璋冪敤鍥炶皟鍑芥暟锛屼紶閫掓柊鍊煎拰鏃у�� + } + }); }, + // 杩斿洖 + goBack() { + console.log(this.data.submitStatus); + wx.navigateBack(); + }, + //璁剧疆鑳屾櫙鑹� + changeBGColor(e) { + this.setData({ + isNight: e.detail.value + }) + }, // 鑾峰彇淇濆瓨鐨勫�掕鏃舵椂闂� getSavedTime() { const savedTime = wx.getStorageSync('countdownTime') @@ -182,10 +240,11 @@ this.setData({ currentIndex: e.detail.index }) - let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0 - let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer) - if (flag) this.handleQuestion(e.detail.index) - + if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') { + let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0 + let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer) + if (flag) this.handleQuestion(e.detail.index) + } }, // 鐐瑰嚮绛旈鍗¤烦杞鐩� goQuestion(e) { @@ -207,28 +266,59 @@ questionList.forEach(item => { if (item.id == id) { item.userAnswer = radioChecked + item.isUserAnswer = this.isHaveAnswer(radioChecked) } }) - this.setData({ - questionDataList: questionList + const cardListUpdata = this.data.cardList + cardListUpdata.forEach(item => { + item.infoList.forEach(citem => { + if (citem.id == id) { + citem.userAnswer = radioChecked + citem.isUserAnswer = this.isHaveAnswer(radioChecked) + } + }) }) - console.log(this.data.questionDataList); + this.setData({ + questionDataList: questionList, + cardList: cardListUpdata + }) + if (this.data.answerType == 'mock') { + this.setData({ + saveTime: 20 + }) + } }, // 杈撳叆妗嗚Е鍙� onChangeInput(e) { const inputData = e.detail.value.detail.value const id = e.detail.value.currentTarget.dataset.id - const index = e.detail.value.currentTarget.dataset.index + const index = Number(e.detail.value.currentTarget.dataset.index) + console.log(index); const questionList = this.data.questionDataList questionList.forEach(item => { if (item.id == id) { item.userAnswer[index] = inputData + return item.isUserAnswer = this.isHaveAnswer(inputData) } }) - this.setData({ - questionDataList: questionList + 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) + } + }) }) - console.log(this.data.questionDataList); + this.setData({ + questionDataList: questionList, + cardList: cardListUpdata, + }) + if (this.data.answerType == 'mock') { + this.setData({ + saveTime: 20 + }) + } }, // 鏁扮粍杞负瀛楃涓叉柟娉� arrayToString(data) { @@ -253,37 +343,79 @@ } else { return false } - } else { + } else if (typeof data == 'object') { const answer = data.find((item) => item.length > 0) if (answer) { return true } else { return false } + } else { + return false } }, // 鎻愪氦閫昏緫 submitPaper() { + // 鍏抽棴閫�鍑洪〉闈㈢洃鍚� + wx.disableAlertBeforeUnload() this.setData({ submitStatus: 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 + for (let index = 0; index < qustionList.length; index++) { + const item = qustionList[index]; + if (!item.isComplete) this.handleQuestion(index + 1) + } + } if (this.data.answerType == 'option') { this.toggleCountdown() - const child = this.selectComponent('#question-options') - if (this.data.answerType == 'option' || this.data.answerType == 'errorQuestion') { - // 鍏堥亶鍘嗘墍鏈夐鐩紝灏嗘湭鎵规敼鐨勯鐩壒鏀� - const qustionList = this.data.questionDataList - for (let index = 0; index < qustionList.length; index++) { - const item = qustionList[index]; - if (!item.isComplete) this.handleQuestion(index + 1) - } - } - if (this.data.answerType == 'option') { - this.recordAnswerData() - child.openTestReportDialog() - } + 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 + mockData.datas.forEach((item) => { + if (item.id == this.data.uuid) { + item.state = '3' + item.report = { + userScore: this.data.subjectiveNum + } + } + }) + this.setData({ + mockData: mockData, + submitStatus: true + }) + this.setMockInfo(mockData.datas) + // 璁板綍鐢ㄦ埛绛旈鏁版嵁 + 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 + }) + } + app.MG.identity.setUserKey({ + setKeyRequests: [ + { + domain: 'mockAnswerData', + key: this.data.uuid, + value: JSON.stringify({ + time: this.data.countdownTime, + answerData: saveData + }) + } + ] + }) + child.openTestReportDialog() } }, @@ -337,12 +469,20 @@ let oldQuestionList = [] oldQuestionList = await this.getMockQuestionList() const userAnswerList = await this.getMockAnswer() - await this.getMockDataList(oldQuestionList, userAnswerList) this.setData({ '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 == '3') { + this.setData({ + submitStatus: true, + subjectiveNum: oldMockData.report.userScore + }) } } }) @@ -377,9 +517,9 @@ setKeyRequests: [ { domain: 'mockAnswerData', - key: route.query.uuid, + key: this.data.uuid, value: JSON.stringify({ - time: countDownRef.value.countdownTime, + time: this.data.countdownTime, answerData: [] }) } @@ -419,6 +559,7 @@ let value = JSON.parse(res[0].value) // 鏈夌瓟棰樿褰曪紝寰楀垎璧嬪�� if (value) { + wx.disableAlertBeforeUnload() this.setData({ submitStatus: true }) @@ -432,6 +573,7 @@ this.setData({ currentIndex: value.currentIndex }) + console.log(this.data.submitStatus); // 鎼哄甫绛旈璁板綍 鑾峰彇棰樼洰 await this.getQuestionList(value.dataList) } else { @@ -454,19 +596,19 @@ errorList: JSON.parse(res[0].value) }) } catch (error) { - } }) }, // 鑾峰彇棰樺簱棰樼洰 - getQuestionList(oldData) { + async getQuestionList(oldData) { // 娓呯┖姝g‘棰樻暟璁板綍 this.setData({ cardList: [], correctNum: 0, }) let flag = 0 - this.data.idPathList.forEach((pathitem) => { + for (let index = 0; index < this.data.idPathList.length; index++) { + const pathitem = this.data.idPathList[index]; const pathList = this.data.cardList pathList.push({ path: pathitem.productLinkPath, @@ -499,7 +641,7 @@ size: 999 } } - app.MG.store.getProductDetail(query).then((res) => { + await app.MG.store.getProductDetail(query).then((res) => { this.setData({ total: res.datas.cmsDatas[0].datas.length }) @@ -542,6 +684,7 @@ 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, @@ -623,21 +766,21 @@ aitem.infoList.forEach((bitem, bindex) => { questionList.push(bitem) bitem.number = bindex + 1 - bitem.grade = 2 + bitem.score = 2 }) }) this.setData({ questionDataList: questionList, - cardList: cardUpdatedList + cardList: cardUpdatedList, }) }) }) - }) + } this.setData({ - loading: false, + loading: false }) }, - // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘忥級 + // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級 handleQuestion(num) { const questionList = this.data.questionDataList const index = num - 1 >= 0 ? num - 1 : 0 @@ -685,13 +828,13 @@ if (item.questionType != 'shortAnswer') { this.setData({ subjectiveTotal: this.data.subjectiveTotal + 1, - subjectiveGrade: this.data.subjectiveGrade + item.grade + subjectiveGrade: this.data.subjectiveGrade + item.score }) } if (questionList[index].isRight && item.questionType != 'shortAnswer') { // 瀹㈣棰樺洖绛旀纭� this.setData({ - subjectiveNum: this.data.subjectiveNum + item.grade, + subjectiveNum: this.data.subjectiveNum + item.score, correctNum: this.data.correctNum + 1 }) } @@ -725,6 +868,7 @@ console.log(res) }) } + this.setData({ questionDataList: questionList }) @@ -1180,11 +1324,13 @@ }) try { this.setData({ - 'mockData.time': 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({ @@ -1202,7 +1348,7 @@ numberIndex++ return { number: numberIndex, - itemId: idItem.id, + id: idItem.id, score: idItem.score } }) @@ -1216,7 +1362,7 @@ numberIndex++ return { number: numberIndex, - itemId: extractCmsItem.id, + id: extractCmsItem.id, score: extractCmsItem.score } }) @@ -1252,7 +1398,144 @@ await this.getMockDataList(this.data.cardList) // 璇锋眰棰樼洰鏁版嵁 }) }, - + // 鑾峰彇缁勫嵎棰樼洰鍒楄〃 + async getMockDataList(questionList, oldList) { + 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 query = { + path: '*', + cmsPath: this.data.rootCmsItemId, + cmsType: '*', + productId: this.data.bookId, + queryType: '*', + itemIds, + itemFields: { + Embedded_QuestionBank_Stem: [], + Embedded_QuestionBank_AnalysisCon: [], + Embedded_QuestionBank_Answer: [], + Embedded_QuestionBank_Option: [], + Embedded_QuestionBank_QuestionType: [], + Embedded_QuestionBank_StemStyle: [], + Embedded_QuestionBank_OptionStyle: [], + Embedded_QuestionBank_KnowledgePoint: [], + 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 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), // 棰樺共 + answer: item.Embedded_QuestionBank_Answer, // 绛旀 + 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' + ? [] + : '', + 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瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� + } + // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 + if ( + questionObj.questionType == 'completion' || + questionObj.questionType == 'multipleChoice' + ) { + try { + questionObj.answer = JSON.parse(questionObj.answer) + } catch (error) { + questionObj.answer = item.Embedded_QuestionBank_Answer + } + } + // 濉┖棰樻敼閫� + if (questionObj.questionType == 'completion') { + let index = 0 + for (let i = 0; i < questionObj.stem.length; i++) { + const item = questionObj.stem[i] + if (item == 'input') { + questionObj.stem[i] = { + num: index, + data: 'input' + } + if (!oldObj) questionObj.userAnswer[index] = '' + index++ + } + } + } + // 鑾峰彇鍥剧墖 + 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 (oldObj && oldObj.isRight) { + this.setData({ + correctNum: this.data.correctNum + 1 + }) + } + if (item.questionType != 'shortAnswer' && item.isComplete) { + this.setData({ + 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) + this.setData({ + [`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 + }) + }) + this.setData({ + questionDataList: questionList, + cardList: cardUpdatedList + }) + }) + }) + } + this.setData({ + loading: false + }) + }, // 鑾峰彇缁勫嵎鏁版嵁 getMockInfo(callback) { app.MG.identity @@ -1316,136 +1599,67 @@ .then((res) => { if (res[0]) { this.setData({ - 'mockData.time': JSON.parse(res[0].value).timem, + 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 }) + console.log(JSON.parse(res[0].value)); data = JSON.parse(res[0].value).answerData } }) return data }, - // 缁勫嵎鑾峰彇棰樼洰鍒楄〃 - async getMockDataList(questionList, oldList) { - const questionDataList = this.data.questionDataList - questionList.forEach(async (pathitem, pathindex) => { - let itemIds = [] - pathitem.infoList.forEach(item => { - itemIds.push(item.itemId + '') - }) - let query = { - path: '*', - cmsPath: this.data.rootCmsItemId, - cmsType: '*', - productId: this.data.bookId, - queryType: '*', - itemIds, - itemFields: { - Embedded_QuestionBank_Stem: [], - Embedded_QuestionBank_AnalysisCon: [], - Embedded_QuestionBank_Answer: [], - Embedded_QuestionBank_Option: [], - Embedded_QuestionBank_QuestionType: [], - Embedded_QuestionBank_StemStyle: [], - Embedded_QuestionBank_OptionStyle: [], - Embedded_QuestionBank_KnowledgePoint: [], - Embedded_QuestionBank_Difficulty: [] + + // 璁板綍妯¤�冪瓟棰樻暟鎹� + 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 + for (let i = 0; i < this.data.questionDataList.length; 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 + } else { + saveData.push({ + id: item.id, + answer: item.userAnswer + }) } } - 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 questionObj = { - 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), // 棰樺共 - answer: item.Embedded_QuestionBank_Answer, // 绛旀 - 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' - ? [] - : '', - isRight: oldObj ? oldObj.isRight : null, - // isComplete: oldObj ? oldObj.isComplete : false, - isComplete: oldObj ? oldObj.isComplete : false, - isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false, - isUnfold: '' // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� - } - const cardList = this.data.cardList - for (let a = 0; a < cardList.length; a++) { - const cardItem = cardList[a]; - for (let b = 0; b < cardItem.infoList.length; b++) { - if (cardItem.infoList[b].itemId == item.id) { - questionObj.number = cardItem.infoList[b].number; - questionObj.score = cardItem.infoList[b].score; - cardItem.infoList[b] = obj; - } - } - } - this.setData({ - cardList: cardList - }) - // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 - if ( - questionObj.questionType == 'completion' || - questionObj.questionType == 'multipleChoice' - ) { - try { - questionObj.answer = JSON.parse(questionObj.answer) - } catch (error) { - questionObj.answer = item.Embedded_QuestionBank_Answer - } - } - // 濉┖棰樻敼閫� - if (questionObj.questionType == 'completion') { - let index = 0 - for (let i = 0; i < questionObj.stem.length; i++) { - const item = questionObj.stem[i] - if (item == 'input') { - questionObj.stem[i] = { - num: index, - data: 'input' - } - if (!oldObj) questionObj.userAnswer[index] = '' - index++ - } - } - } - if (oldObj && oldObj.isRight) { - this.setData({ - correctNum: this.data.correctNum + 1 - }) - } - if (item.questionType != 'shortAnswer') { - this.setData({ - subjectiveTotal: this.data.subjectiveTotal + 1 - }) - } - // if (oldObj && isHaveAnswer(oldObj.answer)) countDownRef.value.changeAlready() - questionDataList.push(questionObj) - }) + } + // + if (this.data.mockData.state == '1') { + const datas = this.data.mockData.datas + datas.forEach((item) => { + if (item.id == this.data.uuid) { + item.state = '2' + } }) - }) - - this.setData({ - questionDataList: questionDataList, - loading: false - }) + 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 + }) + } + ] + }) + .then((res) => { + this.setData({ + saveTime: 20 + }) + console.log('妯¤�冪瓟棰樻暟鎹凡璁板綍') + }) } }) \ No newline at end of file -- Gitblit v1.9.1