YM
2024-05-15 d3d71f644755f2396ce21b5027f0177a80ed89c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<template>
  <div class="temp-book" @mouseup="handleMouseUp">
    <pageContent></pageContent>
  </div>
</template>
 
<script>
import examinations from "./components/examinations/index.vue";
import pageContent from "./content/index.vue";
// import testData from '../assets/examinationList'
// import getQuestionData from '@/assets/methods/examination'
export default {
  name: "child-health",
  components: {
    pageContent,
    examinations
  },
  data() {
    return {
      bookData: {},
      type: "option",
      idPathList: [],
      cardList: [],
      isMouseDown: false
    };
  },
  mounted() {
    this.getBookInfo();
  },
  methods: {
    getBookInfo() {
      let query = {
        path: "*",
        queryType: "*",
        productId: this.config.bookId,
        favoriteTypes: "FavoriteBookCity",
        itemFields: {
          "SysType=": "CmsFolder"
        },
        coverSize: {
          height: 300
        },
        fields: {
          seriesName: [],
          author: [],
          isbn: [],
          publicationDate: [],
          bookClassification: [],
          paperPrice: [],
          JDLink: [],
          tmallLink: [],
          dangdangLink: [],
          weidianLink: [],
          content: [],
          authorIntroduction: [],
          // isApplyPaperBook: [],
          // isApplyEBook: [],
          isApplyBook: [],
          isSell: [],
          pdf: [],
          protectedEpub: [],
          probationPage: [], //pdf试读页数
          freeEpubPage: [] //epub试读百分比
        }
      };
      this.MG.store.getProductDetail(query).then((res) => {
        console.log("图书信息",res.datas); 
        this.$data.bookData =  res.datas
        this.$store.commit('setRootCmsItemId',res.datas.rootCmsItemId)
        // const questiondata = testData
        // for(let key in testData) {
        //   for(let tkey in testData[key]) {
        //     console.log(testData[key][tkey]);
        //     questiondata[key][tkey]  = getQuestionData(res.datas.rootCmsItemId,testData[key][tkey])
        //   }
        // }
        // this.$store.commit('setQuestionData',questiondata)
        // console.log(questiondata);
      });
    },
    getParentWithClass(element, className) {
      while (element.parentElement) {
        element = element.parentElement;
        if (element.classList.contains(className)) {
          return element;
        }
      }
    },
    handleMouseUp(e) {
      const selection = (this.container ? this.container : window).getSelection();
      const txt = selection.toString();
      if (selection.type != "none" && txt) {
        let node = selection.anchorNode.parentNode;
        let pageHtml = this.getParentWithClass(
          selection.anchorNode,
          "page-box"
        );
        let chapterDom = this.getParentWithClass(
          selection.anchorNode,
          "chapter"
        );
        let chapterNum;
        if (chapterDom) chapterNum = chapterDom.getAttribute("num");
        if (pageHtml) {
          const page = pageHtml.getAttribute("page");
          // 监听选中文本事件,并触发父层方法
          if (this.$store.state.qiankun.windowSelection) {
            this.$store.state.qiankun.windowSelection({
              chapterNum,
              txt,
              page,
              x: e.x,
              y: e.y
            });
          }
          console.log("选中的文字", {
            chapterNum,
            txt,
            selection,
            node,
            page,
            x: e.x,
            y: e.y
          });
        }
      }
    }
  }
};
</script>
 
<style lang="less" scoped>
 
</style>