闫增涛
2024-03-29 608eefe5fb03d2f3d3145b11d7de573434451e76
packageBookService/pages/bookServices/examination/examination.js
@@ -1,4 +1,6 @@
import { getPublicImage } from '../../../../assets/js/middleGround/tool'
import {
  getPublicImage
} from '../../../../assets/js/middleGround/tool'
const app = getApp()
Page({
@@ -9,26 +11,26 @@
    barHeight: "",
    navBarHeight: "",
    loading: false,
    answerTitle: "",  // 导航栏标题
    countdownInterval: null,   // 计时器
    answerTitle: "", // 导航栏标题
    countdownInterval: null, // 计时器
    isCountdownRunning: true, // 是否倒计时
    countdownTime: 0,  // 倒计时时间
    countdownTime: 0, // 倒计时时间
    bookId: "",
    productLinkPath: "",
    rootCmsItemId: "",
    idPathList: [],  // 题目列表
    answerType: "",  // 答题模式
    submitStatus: false,  // 提交状态
    idPathList: [], // 题目列表
    answerType: "", // 答题模式
    submitStatus: false, // 提交状态
    currentIndex: 0, // 当前显示的题号
    collectList: [],   //  收藏题目列表
    errorList: [],  // 错题列表
    subjectiveTotal: 0,  // 客观题总数
    collectList: [], //  收藏题目列表
    errorList: [], // 错题列表
    subjectiveTotal: 0, // 客观题总数
    subjectiveNum: 0, // 客观题得分
    subjectiveGrade: 0, // 客观题总分
    correctNum: 0,  // 正确题目数量
    total: 0,   // 题目总数
    cardList: [],  // 提交项,
    questionDataList: [],  // 显示题目列表
    correctNum: 0, // 正确题目数量
    total: 0, // 题目总数
    cardList: [], // 提交项,
    questionDataList: [], // 显示题目列表
    mockid: 0,
    uuid: 0,
    mockData: {
@@ -84,8 +86,7 @@
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  onReady() {},
  /**
   * 生命周期函数--监听页面显示
@@ -149,8 +150,7 @@
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
  },
  onShareAppMessage() {},
  // 监听watch
  watch(context, variableName, callback) {
@@ -246,10 +246,11 @@
    this.setData({
      currentIndex: 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)
    let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0
    const item = this.data.questionDataList[index]
    if ((this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
      let flag = this.isHaveAnswer(item.userAnswer)
      if (flag) this.handleQuestion(index)
    }
  },
  // 点击答题卡跳转题目
@@ -269,21 +270,45 @@
    const id = e.detail.value.currentTarget.dataset.id
    const radioChecked = e.detail.value.detail.value
    const questionList = this.data.questionDataList
    questionList.forEach(item => {
      if (item.id == id) {
    // 我的错题和我的收藏模式下,单选题选择了直接批改
    for (let index = 0; index < questionList.length; index++) {
      const item = questionList[index];
      if (item.id == id && !item.isComplete) {
        item.userAnswer = radioChecked
        item.isUserAnswer = this.isHaveAnswer(radioChecked)
        if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
          this.handleQuestion(this.data.currentIndex)
        }
      }
    })
    }
    // questionList.forEach(item => {
    //   if (item.id == id && !item.isComplete) {
    //     item.userAnswer = radioChecked
    //     item.isUserAnswer = this.isHaveAnswer(radioChecked)
    //     if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
    //       this.handleQuestion(this.data.currentIndex)
    //     }
    //   }
    // })
    const cardListUpdata = this.data.cardList
    cardListUpdata.forEach(item => {
      item.infoList.forEach(citem => {
        if (citem.id == id) {
    for (let index = 0; index < cardListUpdata.length; index++) {
      const item = cardListUpdata[index];
      for (let cindex = 0; cindex < item.infoList.length; cindex++) {
        const citem = item.infoList[cindex];
        if (citem.id == id && !citem.isComplete) {
          citem.userAnswer = radioChecked
          citem.isUserAnswer = this.isHaveAnswer(radioChecked)
        }
      })
    })
      }
    }
    // cardListUpdata.forEach(item => {
    //   item.infoList.forEach(citem => {
    //     if (citem.id == id && !citem.isComplete) {
    //       citem.userAnswer = radioChecked
    //       citem.isUserAnswer = this.isHaveAnswer(radioChecked)
    //     }
    //   })
    // })
    this.setData({
      questionDataList: questionList,
      cardList: cardListUpdata
@@ -375,7 +400,7 @@
      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 (!item.isComplete) this.handleQuestion(index)
      }
    }
    if (this.data.answerType == 'option') {
@@ -412,16 +437,14 @@
        })
      }
      app.MG.identity.setUserKey({
        setKeyRequests: [
          {
            domain: 'mockAnswerData',
            key: this.data.uuid,
            value: JSON.stringify({
              time: this.data.countdownTime,
              answerData: saveData
            })
          }
        ]
        setKeyRequests: [{
          domain: 'mockAnswerData',
          key: this.data.uuid,
          value: JSON.stringify({
            time: this.data.countdownTime,
            answerData: saveData
          })
        }]
      })
      child.openTestReportDialog()
    }
@@ -439,13 +462,13 @@
    })
    if (this.data.answerType == 'option') {
      if (this.data)
        this.startCountdown()
      this.setData({
        countdownTime: 2 * 60 * 60 * 1000
      })
        // this.startCountdown()
        this.setData({
          countdownTime: 2 * 60 * 60 * 1000
        })
      // 测试答题
      await this.getCollectIdList() // 获取收藏id列表
      await this.getErrorList()   // 获取错题id列表
      await this.getErrorList() // 获取错题id列表
    } else if (this.data.answerType == 'collectQuestion') {
      this.setData({
        submitStatus: true
@@ -472,7 +495,6 @@
        }
        if (mocklist.length && this.data.uuid) {
          const oldMockData = mocklist.find((mockItem) => mockItem.id == this.data.uuid)
          debugger
          this.setData({
            'mockData.state': oldMockData.state,
            'mockData.score': oldMockData.score,
@@ -531,16 +553,14 @@
      // 组卷模式
      // 清空答题记录
      await app.MG.identity.setUserKey({
        setKeyRequests: [
          {
            domain: 'mockAnswerData',
            key: this.data.uuid,
            value: JSON.stringify({
              time: this.data.countdownTime,
              answerData: []
            })
          }
        ]
        setKeyRequests: [{
          domain: 'mockAnswerData',
          key: this.data.uuid,
          value: JSON.stringify({
            time: this.data.countdownTime,
            answerData: []
          })
        }]
      })
      this.init()
    } else {
@@ -563,8 +583,7 @@
          this.setData({
            collectList: JSON.parse(res[0].value)
          })
        } catch (error) {
        }
        } catch (error) {}
        if (this.data.answerType == 'option') {
          // 先获取用户答题记录
          this.getAnswerInfo(async (res) => {
@@ -612,8 +631,7 @@
          this.setData({
            errorList: JSON.parse(res[0].value)
          })
        } catch (error) {
        }
        } catch (error) {}
      })
  },
  // 获取题库题目
@@ -678,29 +696,22 @@
            // num: index, // 题号
            id: item.id,
            type: pathitem.name,
            stem:
              item.Embedded_QuestionBank_QuestionType == 'completion'
                ? JSON.parse(item.Embedded_QuestionBank_Stem)
                  .stemTxt.replaceAll('<vacancy>', ',input,')
                  .split(',')
                : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
            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)
              : '', // 选择题选项
            option: item.Embedded_QuestionBank_Option ?
              JSON.parse(item.Embedded_QuestionBank_Option) : '', // 选择题选项
            analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析
            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.userAnswer
              : item.Embedded_QuestionBank_QuestionType == 'completion' ||
                item.Embedded_QuestionBank_QuestionType == 'multipleChoice'
                ? []
                : '',
            difficulty: item.Embedded_QuestionBank_Difficulty ?
              4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级
            userAnswer: oldObj ?
              oldObj.userAnswer : 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,
@@ -734,6 +745,18 @@
                index++
              }
            }
          }
          // 题干富文本处理
          if (questionObj.stemStyle == 'RichText') {
            // questionObj.option.txt = ''
            questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ').replace(/\<p/gi, '<p class="stem-rich-p"')
          }
          // 选项富文本处理
          if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) {
            questionObj.option.forEach(item => {
              if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"')
            })
          }
          // 获取图片
          if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') {
@@ -793,14 +816,15 @@
        })
      })
    }
    // 有题目再开始倒计时
    if (this.data.questionDataList.length) this.startCountdown()
    this.setData({
      loading: false
    })
  },
  // 批改题目 (练习,我的错题,我的收藏,,组卷)
  handleQuestion(num) {
  handleQuestion(index) {
    const questionList = this.data.questionDataList
    const index = num - 1 >= 0 ? num - 1 : 0
    if (questionList[index].isComplete) {
      // 题目已完成,跳过
      return true
@@ -873,13 +897,11 @@
      // 记录错题
      app.MG.identity
        .setUserKey({
          setKeyRequests: [
            {
              domain: 'errorData',
              key: this.data.rootCmsItemId,
              value: JSON.stringify(this.data.errorList)
            }
          ]
          setKeyRequests: [{
            domain: 'errorData',
            key: this.data.rootCmsItemId,
            value: JSON.stringify(this.data.errorList)
          }]
        })
        .then((res) => {
          console.log(res)
@@ -935,27 +957,23 @@
    }
    app.MG.identity
      .setUserKey({
        setKeyRequests: [
          {
            domain: 'collectData',
            key: this.data.rootCmsItemId,
            value: JSON.stringify(this.data.collectList)
          }
        ]
        setKeyRequests: [{
          domain: 'collectData',
          key: this.data.rootCmsItemId,
          value: JSON.stringify(this.data.collectList)
        }]
      })
      .then((res) => { })
      .then((res) => {})
  },
  // 处理答题数据
  recordAnswerData() {
    this.data.cardList.push(
      {
        name: '客观题得分',
        score: this.data.subjectiveNum,
        path: this.data.productLinkPath,
        // infoList: [],
        // catalogName: ''
      }
    )
    this.data.cardList.push({
      name: '客观题得分',
      score: this.data.subjectiveNum,
      path: this.data.productLinkPath,
      // infoList: [],
      // catalogName: ''
    })
    let setInfoData = {
      currentIndex: this.data.currentIndex,
      dataList: JSON.parse(JSON.stringify(this.data.cardList))
@@ -982,15 +1000,13 @@
  setAnswerInfo(data) {
    app.MG.identity
      .setUserKey({
        setKeyRequests: [
          {
            domain: 'answerData',
            key: this.data.productLinkPath,
            value: JSON.stringify(data)
          }
        ]
        setKeyRequests: [{
          domain: 'answerData',
          key: this.data.productLinkPath,
          value: JSON.stringify(data)
        }]
      })
      .then((res) => { })
      .then((res) => {})
  },
  // 获取答题数据
  getAnswerInfo(callback) {
@@ -1027,8 +1043,7 @@
            collectList: JSON.parse(res[0].value)
          })
          // total.value = collectList.value.length
        } catch (error) {
        }
        } catch (error) {}
        if (this.data.collectList && this.data.collectList.length) {
          await this.getCollectDataList()
        } else {
@@ -1037,8 +1052,8 @@
          })
          wx.showModal({
            title: '提示',
            content: '收藏夹暂无数据',//editable如果为true,这就是输入框的内容
            editable: false,//是否显示输入框
            content: '收藏夹暂无数据', //editable如果为true,这就是输入框的内容
            editable: false, //是否显示输入框
            showCancel: false,
            success: (res) => {
              if (res.confirm) {
@@ -1057,12 +1072,10 @@
  async getCollectDataList() {
    let questionArr = []
    this.setData({
      cardList: [
        {
          catalogName: '收藏夹',
          infoList: []
        }
      ]
      cardList: [{
        catalogName: '收藏夹',
        infoList: []
      }]
    })
    let query = {
      path: '*',
@@ -1089,28 +1102,21 @@
        const questionObj = {
          number: index + 1, // 题号
          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), // 题干
          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)
            : '', // 选择题选项
          option: item.Embedded_QuestionBank_Option ?
            JSON.parse(item.Embedded_QuestionBank_Option) : '', // 选择题选项
          analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析
          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:
            item.Embedded_QuestionBank_QuestionType == 'completion' ||
              item.Embedded_QuestionBank_QuestionType == 'multipleChoice'
              ? []
              : '',
          difficulty: item.Embedded_QuestionBank_Difficulty ?
            4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级
          userAnswer: item.Embedded_QuestionBank_QuestionType == 'completion' ||
            item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '',
          isSubmit: false, // 查看解析
          isRight: null, // 是否正确
          isComplete: false,
@@ -1185,8 +1191,7 @@
          this.setData({
            errorList: JSON.parse(res[0].value)
          })
        } catch (error) {
        }
        } catch (error) {}
        if (this.data.errorList && this.data.errorList.length) {
          this.getErrorDataList()
        } else {
@@ -1195,8 +1200,8 @@
          })
          wx.showModal({
            title: '提示',
            content: '错题集暂无数据',//editable如果为true,这就是输入框的内容
            editable: false,//是否显示输入框
            content: '错题集暂无数据', //editable如果为true,这就是输入框的内容
            editable: false, //是否显示输入框
            showCancel: false,
            success: (res) => {
              if (res.confirm) {
@@ -1213,12 +1218,10 @@
  // 获取错题集
  async getErrorDataList() {
    this.setData({
      cardList: [
        {
          catalogName: '错题集',
          infoList: []
        }
      ]
      cardList: [{
        catalogName: '错题集',
        infoList: []
      }]
    })
    let query = {
      path: '*',
@@ -1245,28 +1248,21 @@
        const questionObj = {
          number: index + 1, // 题号
          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), // 题干
          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)
            : '', // 选择题选项
          option: item.Embedded_QuestionBank_Option ?
            JSON.parse(item.Embedded_QuestionBank_Option) : '', // 选择题选项
          analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析
          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:
            item.Embedded_QuestionBank_QuestionType == 'completion' ||
              item.Embedded_QuestionBank_QuestionType == 'multipleChoice'
              ? []
              : '',
          difficulty: item.Embedded_QuestionBank_Difficulty ?
            4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级
          userAnswer: item.Embedded_QuestionBank_QuestionType == 'completion' ||
            item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '',
          isSubmit: false, // 查看解析
          isRight: null, // 是否正确
          isComplete: false,
@@ -1361,7 +1357,10 @@
          // 获取必含题目
          let list = item.cmsItemList.map((idItem) => {
            itemIds.push(idItem.id + '')
            questionIds.push({ id: idItem.id + '', score: idItem.score })
            questionIds.push({
              id: idItem.id + '',
              score: idItem.score
            })
            numberIndex++
            return {
              number: numberIndex,
@@ -1375,7 +1374,10 @@
            const extractItem = item.generatorResultList[i]
            let extractItemList = extractItem.cmsItemList.map((extractCmsItem) => {
              itemIds.push(extractCmsItem.id + '')
              questionIds.push({ id: extractCmsItem.id + '', score: extractCmsItem.score })
              questionIds.push({
                id: extractCmsItem.id + '',
                score: extractCmsItem.score
              })
              numberIndex++
              return {
                number: numberIndex,
@@ -1452,29 +1454,22 @@
            // 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), // 题干
            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)
              : '', // 选择题选项
            option: item.Embedded_QuestionBank_Option ?
              JSON.parse(item.Embedded_QuestionBank_Option) : '', // 选择题选项
            analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析
            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'
                ? []
                : '',
            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,
@@ -1507,6 +1502,17 @@
                index++
              }
            }
          }
          // 题干富文本处理
          if (questionObj.stemStyle == 'RichText') {
            // questionObj.option.txt = ''
            questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img"')
          }
          // 选项富文本处理
          if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) {
            questionObj.option.forEach(item => {
              if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"')
            })
          }
          // 获取图片
          if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') {
@@ -1567,26 +1573,22 @@
  // 记录购买组卷时间
  setMockInfo(data) {
    app.MG.identity.setUserKey({
      setKeyRequests: [
        {
          domain: 'mockData',
          key: this.data.bookId + '',
          value: JSON.stringify(data)
        }
      ]
      setKeyRequests: [{
        domain: 'mockData',
        key: this.data.bookId + '',
        value: JSON.stringify(data)
      }]
    })
  },
  // 记录组卷题目列表
  saveMockQuestionList(data) {
    app.MG.identity
      .setUserKey({
        setKeyRequests: [
          {
            domain: 'mockQuestionData',
            key: this.data.uuid,
            value: JSON.stringify(data)
          }
        ]
        setKeyRequests: [{
          domain: 'mockQuestionData',
          key: this.data.uuid,
          value: JSON.stringify(data)
        }]
      })
      .then((res) => {
        console.log('模考题目列表已记录')
@@ -1660,17 +1662,15 @@
    // 
    app.MG.identity
      .setUserKey({
        setKeyRequests: [
          {
            domain: 'mockAnswerData',
            key: this.data.uuid,
            value: JSON.stringify({
              currentIndex: this.data.currentIndex,
              time: this.data.countdownTime,
              answerData: saveData
            })
          }
        ]
        setKeyRequests: [{
          domain: 'mockAnswerData',
          key: this.data.uuid,
          value: JSON.stringify({
            currentIndex: this.data.currentIndex,
            time: this.data.countdownTime,
            answerData: saveData
          })
        }]
      })
      .then((res) => {
        this.setData({
@@ -1678,5 +1678,30 @@
        })
        console.log('模考答题数据已记录')
      })
  },
  // 富文本处理
  formatRichText(html) {
    console.log(html);
    let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) {
      match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
      match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
      match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
      return match;
    });
    newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) {
      match = match
        .replace(/<p>/gi, '<p class="p_class">')
        .replace(/width:[^;]+;/gi, 'max-width:100%;')
        .replace(/width:[^;]+;/gi, 'max-width:100%;');
      return match;
    });
    newContent = newContent.replace(/<br[^>]*\/>/gi, "");
    newContent = newContent.replace(/<a>/gi, '<a class="p_class "');
    newContent = newContent.replace(/<li>/gi, '<li class="p_class "');
    newContent = newContent.replace(/\<p/gi, '<p class="p_class "');
    newContent = newContent.replace(/\<span/gi, '<span class="p_class "');
    newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"');
    return newContent;
  }
})