From 6df96b3e7a7da1985ee875e84711e9f15c5fbff0 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 24 十二月 2024 18:25:02 +0800 Subject: [PATCH] Merge refs/remotes/origin/master into refs/heads/master --- packageBookService/pages/bookServices/examination/examination.js | 293 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 276 insertions(+), 17 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index 038bc76..320d1a5 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -55,6 +55,9 @@ showDialog: false, // 鏈彁浜ら��鍑烘嫤鎴脊绐� showId: '', isShowDialog: false, // 娴嬭瘯鎶ュ憡寮圭獥鏄惁鏄剧ず + joinGroup: false, // 鏄惁鍔犲叆鐝骇 + visible: false, // 鍔犲叆鐝骇寮圭獥鏄惁鎵撳紑 + classList: [] // 鐝骇鍒楄〃 }, /** @@ -88,7 +91,6 @@ } const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { loginInfo(app, (data) => { if (data) { @@ -100,7 +102,6 @@ } else { this.init() } - }, /** @@ -554,7 +555,8 @@ if ( this.data.answerType == "option" || this.data.answerType == "errorQuestion" || - this.data.answerType == "mock" + this.data.answerType == "mock" || + this.data.answerType == 'interaction' ) { // 鍏堥亶鍘嗘墍鏈夐鐩紝灏嗘湭鎵规敼鐨勯鐩壒鏀� const qustionList = this.data.questionDataList; @@ -617,6 +619,9 @@ this.setData({ isShowDialog: true }) + } else if (this.data.answerType == 'interaction') { + this.toggleCountdown(); + this.handleClassQuestion() } this.setData({ loading: false, @@ -639,6 +644,13 @@ // 娴嬭瘯绛旈 await this.getCollectIdList(); // 鑾峰彇鏀惰棌id鍒楄〃 await this.getErrorList(); // 鑾峰彇閿欓id鍒楄〃 + } else if (this.data.answerType == "interaction") { + this.setData({ + countdownTime: 2 * 60 * 60 * 1000, + }); + this.getCurrentClassList() + this.getinteractionInfo() + // 鏁欏浜掑姩 } else if (this.data.answerType == "collectQuestion") { this.setData({ submitStatus: true, @@ -747,6 +759,14 @@ }, ], }); this.init(); + } else if (this.data.answerType == 'interaction') { + this.setData({ + countdownTime: 2 * 60 * 60 * 1000, + }); + this.delinteractionInfo(() => { + this.getQuestionList() + this.clearTime(); + }) } else { this.init(); this.clearTime(); @@ -846,7 +866,6 @@ let query = { path: "*", queryType: "*", - productId: this.data.bookId, cmsPath: pathitem.productLinkPath, itemFields: { @@ -880,9 +899,6 @@ oldList = oldData.find( (item) => item.path == pathitem.productLinkPath ).infoList; - this.setData({ - submitStatus: true, - }); } res.datas.cmsDatas[0].datas.forEach((item, index) => { if (this.data.storeInfo || this.data.jslx) { @@ -1070,24 +1086,22 @@ questionDataList: questionList, cardList: cardUpdatedList, }); - console.log( - '棰樼洰', this.data.questionDataList - ); }); }); } // 鏈夐鐩啀寮�濮嬪�掕鏃� if (this.data.questionDataList.length) { this.startCountdown(); + this.setData({ + loading: false, + showId: this.data.questionDataList[0].id + }) } else { this.setData({ - noData: true + noData: true, + loading: false, }) } - this.setData({ - loading: false, - showId: this.data.questionDataList[0].id - }); }, // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級 handleQuestion(index) { @@ -2232,7 +2246,6 @@ // 瀵屾枃鏈鐞� formatRichText(html) { - console.log(html); let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) { match = match .replace(/style="[^"]+"/gi, "") @@ -2266,4 +2279,250 @@ ); return newContent; }, -}); \ No newline at end of file + // 鏁欏浜掑姩妯″紡鐩稿叧 + // 鑾峰彇鐝骇鍒楄〃 + getCurrentClassList() { + const query = { + start: 0, + size: 999, + infoTypes: [], + } + app.MG.identity.joinedGroupByList(query).then((res) => { + res.datas.forEach(async item => { + item.topicId = null + const data = await this.getTopicInfo(item.id) + if (data) { + item.topicId = data.id + } + }) + console.log('鐝骇', res) + if (res.datas.length) { + this.setData({ + classList: res.datas + }) + // 鍒ゆ柇鐝骇 鏄惁鎵�灞炰簬璇ヤ功 + const classData = res.datas.find(item => item.linkProductDto.product.id == this.data.bookId) + if (classData) { + if (classData.userState == 'Normal') { + // 鍔犲叆鐝骇 + this.setData({ + joinGroup: true + }) + } else if (classData.userState == 'WaitValid') { + this.setData({ + submitStatus: true + }) + // 瀹℃牳涓� + wx.showModal({ + title: '鎻愮ず', + content: '璇风瓑寰呰�佸笀瀹℃牳鍔犲叆鐝骇鍚庣瓟棰�', + confirmColor: "#ff6c00", + complete: (res) => { + if (res.cancel) { + wx.navigateBack() + } + if (res.confirm) { + wx.navigateBack() + } + } + }) + } else { + // 鎷掔粷 + this.setData({ + visible: true + }) + } + } else { + // 鏈姞鍏ョ彮绾� + this.setData({ + visible: true + }) + } + } else { + this.setData({ + visible: true, + }) + } + + }) + }, + // 鍔犲叆鐝骇 + joinClass(e) { + wx.showLoading({ + title: '鍔犺浇涓�' + }) + const data = { + refCode: e.detail.value + } + app.MG.identity.joinGroupByRefCode(data).then((res) => { + wx.hideLoading() + if (res == '缁勪笉瀛樺湪') { + wx.showToast({ + icon: 'error', + title: '鏃犳晥鐨勭彮绾�', + }) + } else if (res == '缁勬垚鍛樻暟閲忓凡鏈�澶�,涓嶈兘鍔犲叆') { + wx.showToast({ + icon: 'error', + title: '鐝骇鎴愬憳鏁伴噺宸叉渶澶э紝涓嶈兘鍔犲叆', + }) + } else if (res == '宸茬粡鐢宠杩囧姞鍏ユ缁�') { + wx.showToast({ + icon: 'error', + title: '宸茬粡鐢宠杩囧姞鍏ユ鐝骇', + }) + } else { + wx.showToast({ + icon: "success", + title: '宸叉垚鍔燂紝绛夊緟瀹℃牳涓�...', + }) + this.setData({ + visible: false + }) + this.getCurrentClassList() + } + }) + }, + // 鑾峰彇鐝骇topic + async getTopicInfo(classId) { + let query = { + classId, + refCodes: ["TeachInteraction"] + } + const res = await app.MG.edu.getClassTopic(query) + return res[0] ?? null + }, + // 鑾峰彇鏃ф暀瀛︿簰鍔ㄧ瓟棰樻暟鎹� + getinteractionInfo() { + app.MG.identity + .getUserKey({ + domain: "interactionData", + keys: [this.data.productLinkPath], + }) + .then((res) => { + if (res.length) { + let value = JSON.parse(res[0].value); + const scoreData = value.dataList.find(item => item.name == "瀹㈣棰樺緱鍒�" && item.path == this.data.productLinkPath) + this.setData({ + currentIndex: value.currentIndex ? value.currentIndex : 0, + subjectiveNum: scoreData ? scoreData.score : 0, + submitStatus: true + }); + // 鎼哄甫绛旈璁板綍 鑾峰彇棰樼洰 + this.getQuestionList(value.dataList); + } else { + this.getQuestionList(); // 鑾峰彇棰樺簱棰樼洰 + this.setData({ + showDialog: true + }) + } + }); + }, + // 鎻愪氦鏁欏浜掑姩绛旈鏁版嵁 + setinteractionInfo() { + const list = [] + this.data.cardList.forEach(item => { + list.push({ + catalogName: item.catalogName, + path: item.path, + infoList: item.infoList.map((citem) => ({ + id: citem.id, + userAnswer: citem.userAnswer + })) + }) + }) + list.push({ + name: "瀹㈣棰樺緱鍒�", + score: this.data.subjectiveNum, + path: this.data.productLinkPath, + }) + app.MG.identity + .setUserKey({ + setKeyRequests: [{ + domain: "interactionData", + key: this.data.productLinkPath, + value: JSON.stringify({ + currentIndex: this.data.currentIndex, + dataList: list + }), + }, ], + }) + .then((res) => {}); + }, + // 澶勭悊鏁欏浜掑姩绛旈 + handleClassQuestion() { + const flag = this.data.questionDataList.some(item => !item.userAnswer) + if (flag) { + // 娌″仛瀹岋紝淇濆瓨鍗冲彲 + const isAnswer = this.data.questionDataList.some(item => item.userAnswer) + if (isAnswer) this.setinteractionInfo() + } else { + // 鍋氬畬浜嗕笖鍔犲叆浜嗙彮绾э紝鎻愪氦鍒癿essage + if (this.data.classList.length && this.data.joinGroup) { + this.data.classList.forEach(item => { + if (item.linkProductDto.product.id == this.data.bookId && item.topicId) + this.newTopicMessage(item.topicId) + }) + this.setinteractionInfo() + } else { + // 鍋氬畬浜嗭紝娌″姞鍏ョ彮绾� + this.setinteractionInfo() + } + this.setData({ + isShowDialog: true + }) + } + this.setData({ + submitStatus: true + }) + }, + + // 鏂板缓topicMessage + newTopicMessage(topicId) { + let content = [] + for (let cindex = 0; cindex < this.data.questionDataList.length; cindex++) { + const citem = this.data.questionDataList[cindex]; + content.push({ + cmsItemId: citem.id, + answer: citem.userAnswer, + state: citem.questionType == 'shortAnswer' ? 'none' : citem.isRight, + type: citem.questionType + }) + const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey)) + const data = { + description: '', + icon: '', + state: 'Normal', + topicIdOrRefCode: String(topicId), + name: this.data.answerTitle, + content: JSON.stringify({ + bookId: this.data.bookId, + userName: userInfo.name ? userInfo.name : userInfo.nickName ? userInfo.nickName : '-', + path: this.data.productLinkPath, + content + }), + type: 'Normal', + cmsTypeRefCode: '', + newDataListRequest: [] + } + app.MG.ugc.newTopicMessage(data).then((res) => { + if (res) { + this.setData({ + isShowDialog: true + }) + } + }) + } + }, + // 鍒犻櫎鏁欏浜掑姩绛旈璁板綍 + delinteractionInfo(callback) { + app.MG.identity + .delUserKey({ + domain: 'interactionData', + keys: [this.data.productLinkPath] + }) + .then((res) => { + if (callback) callback() + }) + } +}) \ No newline at end of file -- Gitblit v1.9.1