| | |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | if (this.data.answerType != 'mock') { |
| | | if (wx.timer) { |
| | | clearInterval(wx.timer) |
| | | } |
| | | } |
| | | if (this.data.answerType == 'mock') { |
| | | if (wx.timer) { |
| | | clearInterval(wx.timer) |
| | |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | if (wx.timer) { |
| | | clearInterval(wx.timer) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload(e) { |
| | | if (wx.timer) { |
| | | clearInterval(wx.timer) |
| | | } |
| | | if (this.data.countdownInterval !== null) { |
| | | clearInterval(this.data.countdownInterval) |
| | | } |
| | |
| | | item.isUserAnswer = this.isHaveAnswer(radioChecked) |
| | | } |
| | | }) |
| | | const cardListUpdata = this.data.cardList |
| | | cardListUpdata.forEach(item => { |
| | | item.infoList.forEach(citem => { |
| | | if (citem.id == id) { |
| | | citem.userAnswer = radioChecked |
| | | citem.isUserAnswer = this.isHaveAnswer(radioChecked) |
| | | } |
| | | }) |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionList |
| | | questionDataList: questionList, |
| | | cardList: cardListUpdata |
| | | }) |
| | | if (this.data.answerType == 'mock') { |
| | | this.setData({ |
| | |
| | | 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, |
| | | item.isUserAnswer = this.isHaveAnswer(item.userAnswer) |
| | | item.userAnswer[index] = inputData |
| | | return item.isUserAnswer = this.isHaveAnswer(inputData) |
| | | } |
| | | }) |
| | | 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) |
| | | } |
| | | }) |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionList |
| | | questionDataList: questionList, |
| | | cardList: cardListUpdata, |
| | | }) |
| | | if (this.data.answerType == 'mock') { |
| | | this.setData({ |
| | |
| | | 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 |
| | | submitStatus: true, |
| | | subjectiveNum: oldMockData.report.userScore |
| | | }) |
| | | } |
| | | } |
| | |
| | | errorList: JSON.parse(res[0].value) |
| | | }) |
| | | } catch (error) { |
| | | |
| | | } |
| | | }) |
| | | }, |
| | | // 获取题库题目 |
| | | getQuestionList(oldData) { |
| | | async getQuestionList(oldData) { |
| | | // 清空正确题数记录 |
| | | 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, |
| | |
| | | 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 |
| | | }) |
| | |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionList, |
| | | cardList: cardUpdatedList |
| | | cardList: cardUpdatedList, |
| | | }) |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | this.setData({ |
| | | loading: false, |
| | | loading: false |
| | | }) |
| | | }, |
| | | // 批改题目 (练习,我的错题,我的收藏,,组卷) |
| | |
| | | // 获取组卷题目列表 |
| | | async getMockDataList(questionList, oldList) { |
| | | const questionDataList = this.data.questionDataList |
| | | questionList.forEach(async (pathitem, pathindex) => { |
| | | for (let pathindex = 0; pathindex < questionList.length; pathindex++) { |
| | | const pathitem = questionList[pathindex]; |
| | | let itemIds = [] |
| | | pathitem.infoList.forEach(item => { |
| | | itemIds.push(item.id + '') |
| | |
| | | isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false, |
| | | isRight: oldObj ? oldObj.isRight : null, |
| | | // isComplete: oldObj ? oldObj.isComplete : false, |
| | | isComplete: this.data.mockData.state == '3' ? true : oldObj ? this.isHaveAnswer(oldObj.answer) : false, |
| | | isComplete: this.data.mockData.state == '3' ? true : false, |
| | | isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false, |
| | | isUnfold: '' // 控制解析的折叠面板是否展开 |
| | | } |
| | |
| | | questionDataList: questionList, |
| | | cardList: cardUpdatedList |
| | | }) |
| | | console.log('组卷题目列表', this.data.questionDataList); |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | this.setData({ |
| | | // questionDataList: questionDataList, |
| | | loading: false |
| | | }) |
| | | }, |