From c03853bf7e9594bcbef3cfe087b313d18aacb4bb Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期四, 27 三月 2025 15:24:36 +0800 Subject: [PATCH] tiku --- packageBookService/pages/bookServices/examination/examination.js | 218 +++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 150 insertions(+), 68 deletions(-) diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js index 4b751df..04c90bb 100644 --- a/packageBookService/pages/bookServices/examination/examination.js +++ b/packageBookService/pages/bookServices/examination/examination.js @@ -91,7 +91,6 @@ } const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { loginInfo(app, (data) => { if (data) { @@ -103,7 +102,6 @@ } else { this.init() } - }, /** @@ -630,8 +628,42 @@ showDialog: false, }); }, + // 鍒濆鍖栧嚱鏁� async init() { + // 鑾峰彇鍥句功璇︽儏锛屽垽鏂搴撴槸鍚﹁喘涔� + const query = { + path: "*", + queryType: "*", + productId: this.data.bookId, + favoriteTypes: "FavoriteBookCity", + itemFields: { + "SysType=": "CmsFolder", + }, + coverSize: { + height: 300, + }, + fields: {}, + }; + const res = await app.MG.store.getProductDetail(query) + const saleData = res.datas.saleMethod.find(item => item.Name.includes('棰樺簱')) + if (saleData && !res.datas.purchasedSaleMethodIdList.includes(saleData.Id)) return wx.showModal({ + title: '鎻愮ず', + content: '璇峰厛璐拱棰樺簱鍐嶇瓟棰�', + confirmColor: "#ff6c00", + cancelColor: "#949494", + editable: false, //鏄惁鏄剧ず杈撳叆妗� + showCancel: false, + complete: () => { + this.setData({ + submitStatus: true + }) + wx.setStorageSync('tabValue', 'questionBank') + wx.redirectTo({ + url: `/packageBookService/pages/bookServices/detail/index?id=${res.datas.id}&name=${res.datas.name}`, + }) + } + }) this.setData({ loading: true, subjectiveTotal: 0, @@ -761,6 +793,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(); @@ -911,14 +951,15 @@ let oldObj = ""; if (oldList) oldObj = oldList.find((oldItem) => oldItem.id == item.id); + console.log(item.Embedded_QuestionBank_Stem, 111) let questionObj = { // num: index, // 棰樺彿 id: item.id, type: pathitem.name, - stem: item.Embedded_QuestionBank_QuestionType == "completion" ? + stem: item.Embedded_QuestionBank_Stem ? item.Embedded_QuestionBank_QuestionType == "completion" ? JSON.parse(item.Embedded_QuestionBank_Stem) .stemTxt.replaceAll("<vacancy>", ",input,") - .split(",") : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 + .split(",") : JSON.parse(item.Embedded_QuestionBank_Stem) : '-', // 棰樺共 answer: item.Embedded_QuestionBank_Answer, // 绛旀 option: item.Embedded_QuestionBank_Option ? JSON.parse(item.Embedded_QuestionBank_Option) : "", // 閫夋嫨棰橀�夐」 @@ -1080,9 +1121,6 @@ questionDataList: questionList, cardList: cardUpdatedList, }); - console.log( - '棰樼洰', this.data.questionDataList - ); }); }); } @@ -2282,7 +2320,7 @@ const query = { start: 0, size: 999, - filterList: [], + infoTypes: [], } app.MG.identity.joinedGroupByList(query).then((res) => { res.datas.forEach(async item => { @@ -2292,26 +2330,67 @@ item.topicId = data.id } }) + console.log('鐝骇', res) if (res.datas.length) { this.setData({ - joinGroup: true, - classList: res.datas, + 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({ - joinGroup: false, - visible: true + 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', @@ -2358,9 +2437,11 @@ .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({ - submitStatus: value.submitStatus, - currentIndex: value.currentIndex, + currentIndex: value.currentIndex ? value.currentIndex : 0, + subjectiveNum: scoreData ? scoreData.score : 0, + submitStatus: true }); // 鎼哄甫绛旈璁板綍 鑾峰彇棰樼洰 this.getQuestionList(value.dataList); @@ -2373,7 +2454,7 @@ }); }, // 鎻愪氦鏁欏浜掑姩绛旈鏁版嵁 - setinteractionInfo(submitStatus) { + setinteractionInfo() { const list = [] this.data.cardList.forEach(item => { list.push({ @@ -2385,14 +2466,17 @@ })) }) }) - console.log('鎻愪氦鏁版嵁', list); + 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({ - submitStatus, currentIndex: this.data.currentIndex, dataList: list }), @@ -2402,20 +2486,26 @@ }, // 澶勭悊鏁欏浜掑姩绛旈 handleClassQuestion() { - debugger const flag = this.data.questionDataList.some(item => !item.userAnswer) if (flag) { // 娌″仛瀹岋紝淇濆瓨鍗冲彲 const isAnswer = this.data.questionDataList.some(item => item.userAnswer) - if (isAnswer) this.setinteractionInfo(false) + if (isAnswer) this.setinteractionInfo() } else { - // 鍋氬畬浜嗭紝鎻愪氦鍒癿essage - this.setinteractionInfo(true) - if (this.data.classList.length) { + // 鍋氬畬浜嗕笖鍔犲叆浜嗙彮绾э紝鎻愪氦鍒癿essage + if (this.data.classList.length && this.data.joinGroup) { this.data.classList.forEach(item => { - this.newTopicMessage(item.topicId) + 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 @@ -2433,49 +2523,41 @@ state: citem.questionType == 'shortAnswer' ? 'none' : citem.isRight, type: citem.questionType }) - } - const data = { - description: '', - icon: '', - state: 'Normal', - topicIdOrRefCode: String(topicId), - name: this.data.answerTitle, - content: JSON.stringify({ - bookId: this.data.bookId, - userName: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).name, - path: this.data.productLinkPath, - content - }), - type: 'Normal', - cmsTypeRefCode: '', - newDataListRequest: [] - } - app.MG.ugc.newTopicMessage(data).then((res) => { - if (res) { - this.setData({ - isShowDialog: true - }) + 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: 'Public', + cmsTypeRefCode: '', + newDataListRequest: [] } - }) + app.MG.ugc.newTopicMessage(data).then((res) => { + if (res) { + this.setData({ + isShowDialog: true + }) + } + }) + } }, - // 鏂板缓瀛恡opicMessage - // newTopicSubMessage(parentId,topicId) { - // const data = { - // description: '', - // icon: '', - // parentId, - // state: 'Normal', - // topicIdOrRefCode: String(topicId), - // name: this.data.answerTitle, - // content: '', - // type: 'Normal', - // cmsTypeRefCode: '', - // newDataListRequest: [] - // } - // MG.ugc.newTopicMessage(data).then((res) => { - // if (res) { - - // } - // }) - // }, -}); \ No newline at end of file + // 鍒犻櫎鏁欏浜掑姩绛旈璁板綍 + 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