闫增涛
2024-05-15 2e664020f32a0eda87139bc1363fa34b7b5697ba
Merge branch 'master' of http://182.92.203.7:2001/r/testbookLayout
2个文件已删除
4个文件已修改
3937 ■■■■■ 已修改文件
public/information.json 1514 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/resource.json 2066 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/methods/examination.js 282 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/books/childHealth/view/content/components/chapter001.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/books/childHealth/view/content/index.vue 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/books/childHealth/view/index.vue 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/information.json
File was deleted
public/resource.json
File was deleted
src/assets/methods/examination.js
@@ -1,7 +1,7 @@
import { activeBook } from "@/assets/js/config";
import MG from "@/assets/js/middleGround/WebMiddleGroundApi";
import getPublicImage from "@/assets/js/middleGround/tool";
const getQuestionList = (questionList) => {
const getQuestionList = async (questionList) => {
  let cardList = [
    {
      catalogName: "单选题",
@@ -50,147 +50,146 @@
        Embedded_QuestionBank_Difficulty: [],
      },
    };
    MG.store.getProductDetail(query).then( (res) => {
       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), // 题干
          answer: item.Embedded_QuestionBank_Answer, // 答案
          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"
              ? []
              : "",
          isSubmit: false, // 查看解析
          isRight: null, // 是否正确
          isComplete: false,
          isCollect: true,
          isUnfold: "",
        };
        // 多选和填空答案肯为数组,要转换JSON格式
        if (
          questionObj.questionType == "completion" ||
          questionObj.questionType == "multipleChoice"
        ) {
          try {
            questionObj.answer = JSON.parse(questionObj.answer).toString();
          } catch (error) {
            questionObj.answer = item.Embedded_QuestionBank_Answer;
    const res = await MG.store.getProductDetail(query);
    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), // 题干
        answer: item.Embedded_QuestionBank_Answer, // 答案
        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"
            ? []
            : "",
        isSubmit: false, // 查看解析
        isRight: null, // 是否正确
        isComplete: false,
        isCollect: true,
        isUnfold: "",
      };
      // 多选和填空答案肯为数组,要转换JSON格式
      if (
        questionObj.questionType == "completion" ||
        questionObj.questionType == "multipleChoice"
      ) {
        try {
          questionObj.answer = JSON.parse(questionObj.answer).toString();
        } catch (error) {
          questionObj.answer = item.Embedded_QuestionBank_Answer;
        }
      }
      // 填空题改造
      if (questionObj.questionType == "completion") {
        let index = 0;
        for (let i = 0; i < questionObj.stem.length; i++) {
          const item = questionObj.stem[i];
          if (item == "input") {
            questionObj.stem[i] = {
              num: index,
              data: "input",
            };
            questionObj.userAnswer[index] = "";
            index++;
          }
        }
        // 填空题改造
        if (questionObj.questionType == "completion") {
          let index = 0;
          for (let i = 0; i < questionObj.stem.length; i++) {
            const item = questionObj.stem[i];
            if (item == "input") {
              questionObj.stem[i] = {
                num: index,
                data: "input",
              };
              questionObj.userAnswer[index] = "";
              index++;
            }
          }
        }
        // 获取图片
        if (
          questionObj.stemStyle == "Image" ||
          questionObj.stemStyle == "TxtAndImage"
        ) {
          questionObj.stem.stemImage = getPublicImage(
            questionObj.stem.stemImage,
            150
          );
        }
        if (
          questionObj.optionStyle == "Image" ||
          questionObj.optionStyle == "TxtAndImage"
        ) {
          questionObj.option.forEach((optionItem) => {
            if (optionItem.img)
              optionItem.img = getPublicImage(optionItem.img, 150);
          });
        }
        // 题干富文本处理
        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"')
            .replace("../file", app.config.requestCtx + "/file");
        }
        // 选项富文本处理
        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"')
                .replace("../file", app.config.requestCtx + "/file");
          });
        }
        // 解析富文本处理
        if (
          questionObj.analysisCon &&
          typeof questionObj.analysisCon == "string"
        ) {
          questionObj.analysisCon = questionObj.analysisCon.replace(
      }
      // 获取图片
      if (
        questionObj.stemStyle == "Image" ||
        questionObj.stemStyle == "TxtAndImage"
      ) {
        questionObj.stem.stemImage = getPublicImage(
          questionObj.stem.stemImage,
          150
        );
      }
      if (
        questionObj.optionStyle == "Image" ||
        questionObj.optionStyle == "TxtAndImage"
      ) {
        questionObj.option.forEach((optionItem) => {
          if (optionItem.img)
            optionItem.img = getPublicImage(optionItem.img, 150);
        });
      }
      // 题干富文本处理
      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.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 = "判断题";
          judgeArr.push(questionObj);
        } else if (item.Embedded_QuestionBank_QuestionType == "singleChoice") {
          questionObj.type = "单选题";
          singleChoiceArr.push(questionObj);
        } else if (
          item.Embedded_QuestionBank_QuestionType == "multipleChoice"
        ) {
          questionObj.type = "多选题";
          multipleChoiceArr.push(questionObj);
        } else if (item.Embedded_QuestionBank_QuestionType == "completion") {
          questionObj.type = "填空题";
          completionArr.push(questionObj);
        } else if (item.Embedded_QuestionBank_QuestionType == "shortAnswer") {
          questionObj.type = "简答题";
          shortArr.push(questionObj);
        }
      });
          )
          .replace(/\<p/gi, '<p class="stem-rich-p"')
          .replace("../file", app.config.requestCtx + "/file");
      }
      // 选项富文本处理
      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"')
              .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 = "判断题";
        judgeArr.push(questionObj);
      } else if (item.Embedded_QuestionBank_QuestionType == "singleChoice") {
        questionObj.type = "单选题";
        singleChoiceArr.push(questionObj);
      } else if (
        item.Embedded_QuestionBank_QuestionType == "multipleChoice"
      ) {
        questionObj.type = "多选题";
        multipleChoiceArr.push(questionObj);
      } else if (item.Embedded_QuestionBank_QuestionType == "completion") {
        questionObj.type = "填空题";
        completionArr.push(questionObj);
      } else if (item.Embedded_QuestionBank_QuestionType == "shortAnswer") {
        questionObj.type = "简答题";
        shortArr.push(questionObj);
      }
    });
  }
  cardList[0].infoList = singleChoiceArr
@@ -205,13 +204,14 @@
      citem.number = cindex + 1;
    }
  }
  return cardList
  console.log(cardList.filter(item=>item.infoList.length > 0),"cardList.filter(item=>item.infoList.length > 0)");
  return cardList.filter(item=>item.infoList.length > 0);
};
const getQuestionData = (chapterData) => {
const getQuestionData = async (chapterData) => {
  const data = { ...chapterData };
  for (let key in chapterData) {
    data[key] = getQuestionList(chapterData[key]);
    data[key] = await getQuestionList(chapterData[key]);
  }
  return data;
};
src/books/childHealth/view/content/components/chapter001.vue
@@ -3429,9 +3429,9 @@
      pathTen:''
    };
  },
  mounted() {
    this.$data.questionData = getQuestionData(testData[1])
    // console.log('题目',this.$data.questionData );
  async mounted() {
    this.$data.questionData = await getQuestionData(testData[1])
    console.log('题目',this.$data.questionData );
    this.$data.pathOne = getResourcePath('f6f6588a75086576b87bed2fb9ca1ec1')
    this.$data.pathTwo = getResourcePath('e5993b62684fe55d13190cfe52bf00ed')
    this.$data.pathThree = getResourcePath('6b6d42213aa85aa5ff7724aaf96ffee6')
src/books/childHealth/view/content/index.vue
@@ -51,7 +51,7 @@
  },
  watch: {
    showCatalogList: {
      handler(newVal) {
      handler(newVal, oldVal) {
        if (
          this.$store.state.qiankun &&
          this.$store.state.qiankun.catalogChange
@@ -96,10 +96,17 @@
    //   this.gotoPage(5, 100);
    //   setTimeout(() => {
    //     this.renderSign("Note", {
    //       page: 100,
    //       txt: "前儿童生长发育的影响是一个渐",
    //       id: "2ACA9359",
    //       txt: "营养素和热量,才能",
    //       page: "100",
    //       type: "Highlight",
    //       color: "#F5E12A"
    //     });
    //     setTimeout(() => {
    //       this.delSign({
    //         ids: ["2ACA9359"]
    //       });
    //     }, 2000);
    //   }, 1000);
    // }, 3000);
  },
@@ -145,18 +152,17 @@
        }
      }
      // showCatalogList 当前显示的三个章节,watch监听传递给主应用
      console.log(this.showCatalogList);
      // 更新上一次滚动的位置
      this.previousScrollTop = event.target.scrollTop;
      // 返回页码和章节信息
      if (this.$store.state.qiankun && this.$store.state.qiankun.pageChange)
        this.$store.state.qiankun.pageChange({
          page: 100,
          catalog: 5,
          catalogId: "",
          catalogName: ""
        });
      // if (this.$store.state.qiankun && this.$store.state.qiankun.pageChange)
      //   this.$store.state.qiankun.pageChange({
      //     page: 100,
      //     catalog: 5,
      //     catalogId: "",
      //     catalogName: ""
      //   });
    },
    gotoPage(catalog, page) {
      if (catalog >= 0 && catalog <= this.catalogLength) {
@@ -202,33 +208,24 @@
            // 高亮
            pageDom.innerHTML = pageDom.innerHTML.replace(
              reg,
              `<span datatype="Highlight" dataid="${data.id}" style="background: ${data.color};" class="highLight">${data.txt}</span>`
              `<span datatype="Highlight" dataid="${data.id}" style="background: ${data.color};" class="highLight" onclick="signClick('Highlight','${data.id}')">${data.txt}</span>`
            );
            break;
          case "Dashing":
            // 划线
            pageDom.innerHTML = pageDom.innerHTML.replace(
              reg,
              `<span datatype="Dashing" dataid="${data.id}" style="text-decoration-color:${data.color};" class="underline">${data.txt}</span>`
              `<span datatype="Dashing" dataid="${data.id}" style="text-decoration-color:${data.color};" class="underline" onclick="signClick('Dashing','${data.id}')">${data.txt}</span>`
            );
            break;
          case "Note":
            // 笔记
            pageDom.innerHTML = pageDom.innerHTML.replace(
              reg,
              `<span datatype="Note" dataid="${data.id}" style="border-bottom-color:${data.color}" class="notesline">${data.txt}</span><img src="${NoteIcon}" style="cursor: pointer" />`
              `<span datatype="Note" dataid="${data.id}" style="border-bottom-color:${data.color}" class="notesline" onclick="signClick('Note','${data.id}')">${data.txt}<img src="${NoteIcon}" style="cursor: pointer" /></span>`
            );
            break;
        }
        // 绑定事件
        const thisAddDom = (
          this.container ? this.container : document
        ).querySelector(`[dataid="${data.id}"]`);
        thisAddDom.addEventListener("click", function (e) {
          console.log("点击事件回调的实例,通过这个参数获取类型", e);
          if (this.$store.state.qiankun && this.$store.state.qiankun.signClick)
            this.$store.state.qiankun.signClick(type, data);
        });
      }
    },
    delSign({ ids, type }) {
src/books/childHealth/view/index.vue
@@ -9,7 +9,7 @@
export default {
  name: "child-health",
  components: {
    pageContent,
    pageContent
  },
  data() {
    return {
@@ -60,9 +60,9 @@
        }
      };
      this.MG.store.getProductDetail(query).then((res) => {
        console.log("图书信息",res.datas);
        this.$data.bookData =  res.datas
        this.$store.commit('setRootCmsItemId',res.datas.rootCmsItemId)
        console.log("图书信息", res.datas);
        this.$data.bookData = res.datas;
        this.$store.commit("setRootCmsItemId", res.datas.rootCmsItemId);
      });
    },
    getParentWithClass(element, className) {
@@ -74,7 +74,9 @@
      }
    },
    handleMouseUp(e) {
      const selection = (this.container ? this.container : window).getSelection();
      const selection = (
        this.container ? this.container : window
      ).getSelection();
      const txt = selection.toString();
      if (selection.type != "none" && txt) {
        let node = selection.anchorNode.parentNode;
@@ -110,12 +112,20 @@
            y: e.y
          });
        }
      } else {
        if (this.$store.state.qiankun.windowSelection) {
          this.$store.state.qiankun.windowSelection({
            chapterNum: "",
            txt: "",
            page: "",
            x: "",
            y: ""
          });
        }
      }
    }
  }
};
</script>
<style lang="less" scoped>
</style>
<style lang="less" scoped></style>