litian
2024-07-05 2f9305515c7264637164c9e03c2840f4219ca1e3
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({
  /**
@@ -12,6 +14,7 @@
    countdownInterval: null, // 计时器
    isCountdownRunning: true, // 是否倒计时
    countdownTime: 0, // 倒计时时间
    storeInfo: '',
    bookId: "",
    productLinkPath: "",
    rootCmsItemId: "",
@@ -28,6 +31,7 @@
    total: 0, // 题目总数
    cardList: [], // 提交项,
    questionDataList: [], // 显示题目列表
    noData: false,
    mockid: 0,
    uuid: 0,
    mockData: {
@@ -44,6 +48,8 @@
    sliderValue: 0, // 字体滑块
    startTime: "", //进入页面当前时间
    pauseTime: 0, //暂停时间
    showDialog: false, // 未提交退出拦截弹窗
    showId: ''
  },
  /**
@@ -63,7 +69,11 @@
      rootCmsItemId: options.rootCmsItemId,
      idPathList: options.idPathList ? JSON.parse(options.idPathList) : [],
      answerType: options.answerType,
      storeInfo: options.storeInfo,
    });
    wx.setNavigationBarTitle({
      title: options.answerTitle,
    })
    if (this.data.answerType == "mock") {
      this.setData({
        uuid: options.uuid,
@@ -71,7 +81,6 @@
      });
    }
    this.init();
    console.log("传参", options);
  },
  /**
@@ -178,7 +187,6 @@
  // 监听watch
  watch(context, variableName, callback) {
    let value = context.data[variableName]; // 获取被监听属性的当前值
    // 使用 Object.defineProperty 方法在数据对象上定义属性的 getter 和 setter
    Object.defineProperty(context.data, variableName, {
      configurable: true, // 可配置
@@ -193,24 +201,78 @@
      },
    });
  },
  // 修改nav颜色
  changeNavBarColor(e) {
    if (type == 'night') {
      wx.setNavigationBarColor({
        backgroundColor: '#000000',
        frontColor: '#ffffff',
      })
    } else {
      wx.setNavigationBarColor({
        backgroundColor: '#ffffff',
        frontColor: '#000000',
      })
    }
  },
  // 正则找出听力src
  extractSourceSrc(htmlString) {
    // 正则表达式匹配<source>标签中的src属性值
    var srcRegex = /<source\s+src="([^"]+)"/i;
    var srcTwo = /<audio\s+src="([^"]+)"/i;
    // 执行正则匹配
    var match = srcRegex.exec(htmlString);
    const local = srcTwo.exec(htmlString)
    // 如果匹配成功,返回第一个捕获组的内容(src属性的值)
    if (match && match[1]) {
      return match[1].replace('../file', app.config.requestCtx + '/file');
    } else if (local && local[1]) {
      return local[1].replace('../file', app.config.requestCtx + '/file')
    } else {
      // 如果没有匹配到,返回null
      return null;
    }
  },
  // 拿到听力题除audio标签外其他内容
  removeVideoAndAudioTags(htmlString) {
    // 使用正则表达式匹配并移除所有的 <video> 和 <audio> 标签
    var cleanedHtml = htmlString.replace(/<video[^>]*>[\s\S]*?<\/video>|<audio[^>]*>[\s\S]*?<\/audio>/gi, '');
    return cleanedHtml;
  },
  // 改变loading状态
  changeLoadingState() {
    this.setData({
      loading: true
    })
  },
  // 返回拦截
  beforeleave() {
    wx.showModal({
      title: "提示",
      content: "未提交,是否退出答题",
      confirmColor: "#ff6c00",
      cancelColor: "#949494",
      complete: (res) => {
        if (res.cancel) {
        }
        if (res.confirm) {
          this.setData({
            submitStatus: true,
          });
          wx.navigateBack();
        }
      },
    });
    if ((this.data.answerType == 'option' || this.data.answerType == 'mock') && !this.data.submitStatus) {
      wx.showModal({
        title: "提示",
        content: "未提交,是否退出答题",
        confirmColor: "#ff6c00",
        cancelColor: "#949494",
        complete: (res) => {
          if (res.cancel) {
            this.setData({
              showDialog: true
            })
          }
          if (res.confirm) {
            this.setData({
              submitStatus: true,
              showDialog: false
            });
            wx.navigateBack();
          }
        },
      });
    }
  },
  onChangeSlider(e) {
    this.setData({
@@ -225,9 +287,21 @@
  },
  //设置背景色
  changeBGColor(e) {
    const flag = e.detail.value
    this.setData({
      isNight: e.detail.value,
      isNight: flag,
    });
    if (flag) {
      wx.setNavigationBarColor({
        backgroundColor: '#000000',
        frontColor: '#ffffff',
      })
    } else {
      wx.setNavigationBarColor({
        backgroundColor: '#ffffff',
        frontColor: '#000000',
      })
    }
  },
  // 获取保存的倒计时时间
  getSavedTime() {
@@ -285,11 +359,13 @@
  },
  // 切换题目
  changeSwiper(e) {
    this.setData({
      currentIndex: e.detail.index,
    });
    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];
    this.setData({
      currentIndex: e.detail.index,
      showId: lastItem.id
    });
    if (
      (this.data.answerType == "collectQuestion" ||
        this.data.answerType == "errorQuestion") &&
@@ -505,21 +581,20 @@
        });
      }
      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();
    }
    this.setData({
      loading: false,
      showDialog: false,
    });
  },
  // 初始化函数
@@ -532,7 +607,6 @@
    });
    if (this.data.answerType == "option") {
      if (this.data)
        // this.startCountdown()
        this.setData({
          countdownTime: 2 * 60 * 60 * 1000,
        });
@@ -596,6 +670,9 @@
            oldMockData.state == "2"
          ) {
            this.startCountdown();
            this.setData({
              showDialog: true
            })
          }
          if (oldMockData.state == "3") {
            this.setData({
@@ -617,6 +694,7 @@
      subjectiveNum: 0,
      currentIndex: 0,
      submitStatus: false,
      showDialog: true
    });
    if (this.data.answerType == "option") {
      this.setData({
@@ -633,16 +711,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 {
@@ -693,11 +769,13 @@
              this.setData({
                currentIndex: value.currentIndex,
              });
              console.log(this.data.submitStatus);
              // 携带答题记录 获取题目
              await this.getQuestionList(value.dataList);
            } else {
              await this.getQuestionList(); // 获取题库题目
              this.setData({
                showDialog: true
              })
            }
          });
        }
@@ -722,6 +800,7 @@
  async getQuestionList(oldData) {
    // 清空正确题数记录
    this.setData({
      noData: false,
      cardList: [],
      correctNum: 0,
    });
@@ -741,6 +820,7 @@
      let query = {
        path: "*",
        queryType: "*",
        productId: this.data.bookId,
        cmsPath: pathitem.productLinkPath,
        itemFields: {
@@ -760,6 +840,9 @@
          size: 999,
        },
      };
      if (this.data.storeInfo) {
        query.storeInfo = this.data.storeInfo
      }
      await app.MG.store.getProductDetail(query).then((res) => {
        this.setData({
          total: res.datas.cmsDatas[0].datas.length,
@@ -776,6 +859,19 @@
          });
        }
        res.datas.cmsDatas[0].datas.forEach((item, index) => {
          if (this.data.storeInfo) {
            if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') {
              pathitem.name = "单选题"
            } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') {
              pathitem.name = "简答题"
            } else if (item.Embedded_QuestionBank_QuestionType == "completion") {
              pathitem.name = "填空题";
            } else if (item.Embedded_QuestionBank_QuestionType == "multipleChoice") {
              pathitem.name = "多选题";
            } else if (item.Embedded_QuestionBank_QuestionType == "judge") {
              pathitem.name = "判断题";
            }
          }
          let oldObj = "";
          if (oldList)
            oldObj = oldList.find((oldItem) => oldItem.id == item.id);
@@ -783,34 +879,26 @@
            // 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,
            isCollect:
              this.data.collectList.indexOf(item.id) > -1 ? true : false,
            isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false,
            isUnfold: "", // 控制解析的折叠面板是否展开
          };
          // 多选和填空答案肯为数组,要转换JSON格式
@@ -847,7 +935,7 @@
                /\<img/gi,
                '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
              )
              .replace(/\<p/gi, '<p class="stem-rich-p"');
              .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
          }
          // 选项富文本处理
          if (
@@ -859,8 +947,8 @@
            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"');
                .replace(/\<img/gi, '<img class="option-rich-img"')
                .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
            });
          }
          // 解析富文本处理
@@ -872,6 +960,14 @@
              /\<img/gi,
              '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
            );
          }
          // 听力题修改
          if (questionObj.questionType == 'singleChoice') {
            const src = this.extractSourceSrc(questionObj.stem.stemTxt)
            if (src) {
              questionObj.src = src
              questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt)
            }
          }
          // 获取图片
          if (
@@ -951,9 +1047,17 @@
      });
    }
    // 有题目再开始倒计时
    if (this.data.questionDataList.length) this.startCountdown();
    if (this.data.questionDataList.length) {
      console.log(this.data.questionDataList);
      this.startCountdown();
    } else {
      this.setData({
        noData: true
      })
    }
    this.setData({
      loading: false,
      showId: this.data.questionDataList[0].id
    });
  },
  // 批改题目 (练习,我的错题,我的收藏,,组卷)
@@ -1047,13 +1151,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);
@@ -1111,13 +1213,11 @@
    }
    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) => {});
  },
@@ -1149,24 +1249,21 @@
        }
      }
    }
    this.setAnswerInfo(setInfoData);
  },
  // 提交答题数据
  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) => {});
  },
  // 获取答题数据
  // 获取旧答题数据
  getAnswerInfo(callback) {
    app.MG.identity
      .getUserKey({
@@ -1177,7 +1274,7 @@
        if (callback) callback(res);
      });
  },
  // 删除答题数据
  // 删除旧答题数据
  delAnswerInfo(callback) {
    app.MG.identity
      .delUserKey({
@@ -1206,6 +1303,7 @@
        } else {
          this.setData({
            loading: false,
            noData: true
          });
          wx.showModal({
            title: "提示",
@@ -1230,8 +1328,7 @@
  async getCollectDataList() {
    let questionArr = [];
    this.setData({
      cardList: [
        {
      cardList: [{
          catalogName: "单选题",
          infoList: [],
        },
@@ -1279,34 +1376,30 @@
          Embedded_QuestionBank_Difficulty: [],
        },
      };
      if (this.data.storeInfo) {
        query.storeInfo = this.data.storeInfo
      }
      await app.MG.store.getProductDetail(query).then((res) => {
        let questionArr = [];
        res.datas.cmsDatas[0].datas.forEach((item, index) => {
          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,
@@ -1365,7 +1458,7 @@
                /\<img/gi,
                '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
              )
              .replace(/\<p/gi, '<p class="stem-rich-p"');
              .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
          }
          // 选项富文本处理
          if (
@@ -1377,9 +1470,27 @@
            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"');
                .replace(/\<img/gi, '<img class="option-rich-img"')
                .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
            });
          }
          // 解析富文本处理
          if (
            questionObj.analysisCon &&
            typeof questionObj.analysisCon == "string"
          ) {
            questionObj.analysisCon = questionObj.analysisCon.replace(
              /\<img/gi,
              '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
            );
          }
          // 听力题修改
          if (questionObj.questionType == 'singleChoice') {
            const src = this.extractSourceSrc(questionObj.stem.stemTxt)
            if (src) {
              questionObj.src = src
              questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt)
            }
          }
          if (item.Embedded_QuestionBank_QuestionType == "judge") {
            questionObj.type = "判断题";
@@ -1422,6 +1533,7 @@
    }
    this.setData({
      questionDataList: questionArr,
      showId: questionArr[0].id,
      cardList: cardList,
      loading: false,
    });
@@ -1443,7 +1555,8 @@
          this.getErrorDataList();
        } else {
          this.setData({
            loading: true,
            loading: false,
            noData: true
          });
          wx.showModal({
            title: "提示",
@@ -1467,8 +1580,7 @@
  // 获取错题集
  async getErrorDataList() {
    this.setData({
      cardList: [
        {
      cardList: [{
          catalogName: "单选题",
          infoList: [],
        },
@@ -1514,34 +1626,30 @@
        Embedded_QuestionBank_Difficulty: [],
      },
    };
    if (this.data.storeInfo) {
      query.storeInfo = this.data.storeInfo
    }
    await app.MG.store.getProductDetail(query).then((res) => {
      let questionArr = [];
      res.datas.cmsDatas[0].datas.forEach((item, index) => {
        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,
@@ -1602,7 +1710,7 @@
              /\<img/gi,
              '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
            )
            .replace(/\<p/gi, '<p class="stem-rich-p"');
            .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
        }
        // 选项富文本处理
        if (
@@ -1614,9 +1722,28 @@
          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"');
              .replace(/\<img/gi, '<img class="option-rich-img"')
              .replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
          });
        }
        // 解析富文本处理
        if (
          questionObj.analysisCon &&
          typeof questionObj.analysisCon == "string"
        ) {
          questionObj.analysisCon = questionObj.analysisCon.replace(
            /\<img/gi,
            '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
          );
        }
        // 听力题修改
        if (questionObj.questionType == 'singleChoice') {
          const src = this.extractSourceSrc(questionObj.stem.stemTxt)
          if (src) {
            questionObj.src = src
            questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt)
            console.log('题干', questionObj.stem.stemTxt);
          }
        }
        if (item.Embedded_QuestionBank_QuestionType == "judge") {
          questionObj.type = "判断题";
@@ -1658,11 +1785,11 @@
      }
      this.setData({
        questionDataList: questionArr,
        showId: questionArr[0].id,
        cardList: cardList,
        loading: false,
      });
    });
    // loadings.value = false
  },
  // 获取组卷结果
  async getEduQuizConfig() {
@@ -1787,6 +1914,9 @@
          Embedded_QuestionBank_Difficulty: [],
        },
      };
      if (this.data.storeInfo) {
        query.storeInfo = this.data.storeInfo
      }
      await app.MG.store.getProductDetail(query).then((res) => {
        res.datas.cmsDatas[0].datas.forEach((item, index) => {
          // 循环questionList,给每题赋值分数
@@ -1798,35 +1928,27 @@
            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"
              ? []
              : "",
            isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false,
            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.answer) : false,
            isRight: oldObj ? oldObj.isRight : null,
            // isComplete: oldObj ? oldObj.isComplete : false,
            isComplete: this.data.mockData.state == "3" ? true : false,
            isCollect:
              this.data.collectList.indexOf(item.id) > -1 ? true : false,
            isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false,
            isUnfold: "", // 控制解析的折叠面板是否展开
          };
          // 多选和填空答案肯为数组,要转换JSON格式
@@ -1861,7 +1983,7 @@
            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"').replace('../file', app.config.requestCtx + '/file');
          }
          // 选项富文本处理
          if (
@@ -1875,8 +1997,16 @@
                item.txt = item.txt.replace(
                  /\<img/gi,
                  '<img class="option-rich-img"'
                );
                ).replace(/\<p/gi, '<p class="stem-rich-p"').replace('../file', app.config.requestCtx + '/file');
            });
          }
          // 听力题修改
          if (questionObj.questionType == 'singleChoice') {
            const src = this.extractSourceSrc(questionObj.stem.stemTxt)
            if (src) {
              questionObj.src = src
              questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt)
            }
          }
          // 获取图片
          if (
@@ -1941,6 +2071,7 @@
    }
    this.setData({
      loading: false,
      showId: this.data.questionDataList[0].id
    });
  },
  // 获取组卷数据
@@ -1957,26 +2088,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("模考题目列表已记录");
@@ -2005,12 +2132,12 @@
      })
      .then((res) => {
        if (res[0]) {
          // 这里的 countdownTime 赋值:如果是时间到了提交,记录的剩余时间就是0,所以:如果是0的话赋值1秒,防止监听到时间为0再次提交
          this.setData({
            currentIndex: JSON.parse(res[0].value).currentIndex,
            "mockData.time": JSON.parse(res[0].value).time,
            countdownTime: JSON.parse(res[0].value).time
              ? JSON.parse(res[0].value).time
              : this.data.mockData.sumTime,
            countdownTime: JSON.parse(res[0].value).time > 0 ?
              JSON.parse(res[0].value).time : 1000,
            "mockData.answer": JSON.parse(res[0].value).answerData,
          });
          console.log(JSON.parse(res[0].value));
@@ -2054,17 +2181,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({
@@ -2110,4 +2235,4 @@
    );
    return newContent;
  },
});
});