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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
| <template>
| <div class="temp-book" @mouseup="handleMouseUp" @mousedown="handleMouseDown" @mousemove="handleMousemove">
| <pageContent></pageContent>
| </div>
| </template>
|
| <script>
| import examinations from "./components/examinations/index.vue";
| import testData from '../assets/examinationList.json'
| import pageContent from "./content/index.vue";
| export default {
| name: "child-health",
| components: {
| pageContent,
| examinations,
| },
| data() {
| return {
| bookData:{},
| type: "option",
| idPathList: [],
| cardList: [],
| isMouseDown: false,
| showToolBox: false,
| move: false,
| };
| },
| mounted() {
| this.getBookInfo();
| console.log(this.$store.state.qiankun, "this.$store.state.qiankun");
| },
| 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.cmsDatas[0].datas);
| this.$data.bookData = res.datas.cmsDatas[0].datas
|
| });
| },
| getParentWithClass(element, className) {
| while (element.parentElement) {
| element = element.parentElement;
| if (element.classList.contains(className)) {
| return element;
| }
| }
| },
| handleMouseUp(e) {
| if (this.$data.move) {
| const txt = window.getSelection()?.toString();
| const selection = window.getSelection();
| if (selection.type != "none") {
| 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 (txt && pageHtml) {
| this.$dsta.showToolBox = true;
| const page = pageHtml.getAttribute("page");
| console.log(
| {
| chapterNum,
| txt,
| selection,
| node,
| page,
| x: e.x,
| y: e.y,
| },
| "sendData"
| );
| // 监听选中文本事件,并触发父层方法
| console.log("第二处判断", this.$store.state.qiankun);
| if (this.$store.state.qiankun.windowSelection) {
| this.$store.state.qiankun.windowSelection({
| txt,
| selection,
| node,
| page,
| x: e.x,
| y: e.y,
| });
| }
| }
| this.$data.isMouseDown = false;
| }
| }
| this.$data.move = false
| },
|
| handleMouseDown() {
| this.$data.isMouseDown = true;
| this.$data.showToolBox = false;
| },
| handleMousemove() {
| if (this.$data.isMouseDown) {
| this.$data.move = true;
| }
| },
|
| // handleMouseUp(e) {
| // if (move.value) {
| // const txt = window.getSelection()?.toString();
| // selectText.value = txt;
| // const node = window.getSelection();
| // let html = node.anchorNode.parentNode.parentNode;
| // dialogToolData.chapter = html.firstChild.innerHTML;
| // if (txt) {
| // showToolBox.value = true;
| // dialogToolData.top = e.y;
| // dialogToolData.left = e.x;
| // }
| // isMouseDown.value = false;
| // }
| // move.value = false;
| // },
| },
| };
| </script>
|
| <style lang="less" scoped></style>
|
|