| | |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | isBuy: false, // 是否需要购买 |
| | | questuionName: "", //试卷名称 |
| | | dataList: "", |
| | | barHeight: "", |
| | | navBarHeight: "", |
| | | loading: false, |
| | | loading: true, |
| | | answerTitle: "", // 导航栏标题 |
| | | submitStatus: false, // 提交状态 |
| | | currentIndex: 0, // 当前显示的题号 |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | const questuionName = options.listName |
| | | this.setData({ |
| | | questuionName: questuionName |
| | | }) |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = |
| | | (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.init(); |
| | | // 在此进行是否购买的查询 |
| | | const questionId = options.listId; |
| | | const bookId = options.bookId |
| | | const bookName = options.bookName |
| | | const formPath = options.formPath |
| | | const query = { |
| | | "cmsItemId": Number(questionId) |
| | | }; |
| | | app.MG.file.checkCmsItem(query) |
| | | .then((res) => { |
| | | const isBuys = res; |
| | | this.setData({ |
| | | isBuy: isBuys |
| | | }); |
| | | if (!isBuys) { |
| | | wx.showModal({ |
| | | icon: 'error', |
| | | title: '温馨提示', |
| | | content: '请购买题库,即将返回购买页', |
| | | confirmText: '确定', |
| | | showCancel: false, // 关闭取消按钮 |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: '/packageBookService/pages/bookServices/detail/index?id=' + bookId + '&name=' + bookName + '&tabValue=' + formPath, |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | return; // 直接返回,避免执行后续代码 |
| | | } |
| | | |
| | | // 其他逻辑 |
| | | const questuionName = options.listName; |
| | | this.setData({ |
| | | questionName: questuionName |
| | | }); |
| | | |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = |
| | | (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.init(); |
| | | } else { |
| | | this.init(); |
| | | } |
| | | }); |
| | | } else { |
| | | this.init(); |
| | | } |
| | | }) |
| | | } else { |
| | | this.init() |
| | | } |
| | | .catch((err) => { |
| | | console.error('检查题库失败:', err); |
| | | wx.showToast({ |
| | | icon: 'error', |
| | | title: '加载失败,请重试' |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | |
| | | }, |
| | | // 切换题目 |
| | | changeSwiper(e) { |
| | | 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]; |
| | | let index = e.detail.index; |
| | | const lastItem = this.data.questionDataList[index]; |
| | | this.setData({ |
| | | currentIndex: e.detail.index, |
| | | showId: lastItem.id |
| | | }); |
| | | if ( |
| | | (this.data.answerType == "collectQuestion" || |
| | | this.data.answerType == "errorQuestion") && |
| | | !item.isComplete |
| | | ) { |
| | | let flag = this.isHaveAnswer(item.userAnswer); |
| | | if (flag) this.handleQuestion(index); |
| | | } |
| | | }, |
| | | |
| | | // 我的错题,收藏查看解析按钮 |
| | | viewParsing() { |
| | | if ( |
| | |
| | | radioChange(citem) |
| | | } |
| | | } |
| | | const listLength = this.data.questionDataList.length - 1 |
| | | if (this.data.currentIndex < listLength) { |
| | | this.setData({ |
| | | currentIndex: this.data.currentIndex + 1 |
| | | }) |
| | | } |
| | | }, |
| | | // 输入框触发 |
| | | onChangeInput(e) { |
| | |
| | | // 先遍历所有题目,将未批改的题目批改 |
| | | const qustionList = this.data.questionDataList; |
| | | if (qustionList.length) this.handleQuestion(); |
| | | this.setData({ |
| | | isShowDialog: true, |
| | | submitStatus: true, |
| | | }) |
| | | // 记录用户答题数据 |
| | | let saveData = []; |
| | | for (let index = 0; index < this.data.questionDataList.length; index++) { |
| | |
| | | }); |
| | | this.setData({ |
| | | loading: false, |
| | | showDialog: false, |
| | | isShowDialog: true, |
| | | submitStatus: true, |
| | | }); |
| | | }, |
| | | // 初始化函数 |
| | | async init(isReset) { |
| | | this.setData({ |
| | | loading: false, |
| | | isShowDialog: false, |
| | | loading: true, |
| | | }); |
| | | const questuionName = this.data.questuionName |
| | | const questuionList = pastData.postData.list |
| | |
| | | const questionList = this.data.questionDataList; |
| | | const optionList = this.data.questionDataOptions; |
| | | const scoreData = this.data.scoreDataList; |
| | | debugger |
| | | for (let index = 0; index < questionList.length; index++) { |
| | | const item = questionList[index]; |
| | | if (item.questionType == 'judge' && item.userAnswer) { |
| | |
| | | }, |
| | | async restart() { |
| | | this.setData({ |
| | | isShowDialog: false, |
| | | currentIndex: 0, |
| | | submitStatus: false, |
| | | }); |
| | |
| | | this.setData({ |
| | | questionDataList: newArr, |
| | | scoreDataList: scoreArr, |
| | | loading: false, |
| | | }) |
| | | } catch (error) { |
| | | this.setData({ |
| | | questionDataList: newArr, |
| | | scoreDataList: scoreArr |
| | | scoreDataList: scoreArr, |
| | | loading: false, |
| | | }) |
| | | console.log(error); |
| | | } |
| | | const e = { |
| | | detail: { |
| | | index: 0 |
| | | } |
| | | }; |
| | | this.changeSwiper(e) |
| | | }); |
| | | }, |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 记录模考答题数据 |
| | | saveMockData() { |