From bd8c361302d9a2992f7618955eb6b8dd26df6ecf Mon Sep 17 00:00:00 2001
From: unknown <qq1940665526@163.com>
Date: 星期二, 11 六月 2024 18:37:55 +0800
Subject: [PATCH] 优化

---
 src/books/sportsAndHealth/css/default.less                    |    6 +
 src/components/pdfview/index.vue                              |  205 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/books/sportsAndHealth/view/components/testDynaicTable.vue |   16 ++++
 src/books/sportsAndHealth/view/components/index.vue           |    2 
 4 files changed, 226 insertions(+), 3 deletions(-)

diff --git a/src/books/sportsAndHealth/css/default.less b/src/books/sportsAndHealth/css/default.less
index f777519..94cd6a1 100644
--- a/src/books/sportsAndHealth/css/default.less
+++ b/src/books/sportsAndHealth/css/default.less
@@ -212,12 +212,13 @@
 
               span {
                 display: block;
-                height: 25px;
-                line-height: 15px;
+                height: 30px;
+                line-height: 19px;
                 border: 1px solid #89a0d0;
                 padding: 5px 15px;
                 box-sizing: border-box;
                 border-radius: 5px;
+                font-size: 14px;
                 cursor: pointer;
                 -webkit-user-select: none;
                 /* Safari 3.1+ */
@@ -555,6 +556,7 @@
           margin: 0;
           // font-weight: 900;
           margin-bottom: 10px;
+          text-indent: 2em;
         }
 
 
diff --git a/src/books/sportsAndHealth/view/components/index.vue b/src/books/sportsAndHealth/view/components/index.vue
index 8b6a584..b8d881e 100644
--- a/src/books/sportsAndHealth/view/components/index.vue
+++ b/src/books/sportsAndHealth/view/components/index.vue
@@ -188,7 +188,7 @@
   },
   mounted() {
     // 榛樿鍔犺浇绔犺妭
-    this.showCatalogList = [1];
+    this.showCatalogList = [3];
     // 婊氬姩鐩戝惉鑺傛祦
     this.throttledScrollHandler = _.throttle(
       this.scrollFun,
diff --git a/src/books/sportsAndHealth/view/components/testDynaicTable.vue b/src/books/sportsAndHealth/view/components/testDynaicTable.vue
index 928c92f..e9a1656 100644
--- a/src/books/sportsAndHealth/view/components/testDynaicTable.vue
+++ b/src/books/sportsAndHealth/view/components/testDynaicTable.vue
@@ -114,11 +114,22 @@
         </div>
       </div>
     </div>
+    <!-- <div class="page-box" page="226">
+      <div v-if="showPageList.indexOf(226)>-1">
+        <div class="bodystyle">
+          <pdfView :md5="md5"></pdfView>
+        </div>
+      </div>
+    </div> -->
   </div>
 </template>
 <script>
+// import pdfView from '@/components/pdfview'
 export default {
   name: "testD",
+  // components:{
+  //   pdfView
+  // },
   props: {
     showPageList: {
       type: Array,
@@ -127,5 +138,10 @@
       type: Object,
     },
   },
+  data(){
+    return {
+      md5:'54741d14a21eb47b2ed06a2231271cd5'
+    }
+  }
 };
 </script>
diff --git a/src/components/pdfview/index.vue b/src/components/pdfview/index.vue
new file mode 100644
index 0000000..04edf5e
--- /dev/null
+++ b/src/components/pdfview/index.vue
@@ -0,0 +1,205 @@
+<template>
+  <div class="imgbox">
+    <img
+      ref="image"
+      :onLoad="initFun"
+      :onDragStart="dragStart"
+      :onWheel="handleScroll"
+      :src="currentPageSrc"
+      alt=""
+    />
+  </div>
+</template>
+<script>
+export default {
+  name: "pdf_view",
+  props: {
+    md5: {
+      type: String,
+    },
+    title: {
+      type: String,
+    },
+  },
+  data() {
+    return {
+      currentPageSrc: "",
+      fileLoading: false,
+      visible: true,
+      close: null,
+      currentPage: 1,
+      totalPage: 1,
+      rcViewerOptions: {
+        // inline: true
+      },
+      zoom: 1,
+      catalogVisible: false,
+      tocData: [],
+      generateList: [],
+      expandedKeys: [],
+      searchValue: "",
+      autoExpandParent: true,
+      drawerSize: "default",
+    };
+  },
+  watch: {
+    md5: {
+      handler(newVal, oldVal) {
+        if (newVal) {
+          this.getFileInfo();
+        }
+      },
+    },
+  },
+  created(){
+    this.getFileInfo();
+  },
+  methods: {
+    initFun() {
+      // 鍒濆鍖栨嫋鎷�
+      let image = this.refs.image;
+      let imageBox = this.refs.imageBox;
+      let initLeft = imageBox.offsetWidth / 2 - image.offsetWidth / 2;
+      image.style.left = initLeft + "px";
+      image.style.top = 0 + "px";
+      let canMove = false;
+      let offsetX, offsetY, oldLeft, oldTop;
+      image.onmousedown = function (e) {
+        canMove = true;
+        offsetX = e.x;
+        offsetY = e.y;
+        oldLeft = parseFloat(image.style.left.split("px")[0]);
+        oldTop = parseFloat(image.style.top.split("px")[0]);
+      };
+      imageBox.onmousemove = function (e) {
+        if (canMove == true) {
+          let left = e.clientX - offsetX;
+          let top = e.clientY - offsetY;
+          image.style.left = oldLeft + left + "px";
+          image.style.top = oldTop + top + "px";
+        }
+      };
+      image.onmouseup = function () {
+        canMove = false;
+      };
+      this.fileLoading = false;
+    },
+    dragStart(e) {
+      if (e && e.preventDefault) {
+        e.preventDefault();
+      } else {
+        window.event.returnValue = false;
+      }
+    },
+    handleScroll(e) {
+      if (e.nativeEvent.deltaY <= 0) {
+        if (this.zoom < 3) {
+          let newZoom = this.zoom + 0.1;
+          this.zoom = newZoom;
+          this.refs.image.style.height = newZoom * 100 + "%";
+        }
+      } else {
+        if (this.zoom > 0.5) {
+          let newZoom = this.zoom - 0.1;
+          this.zoom = newZoom;
+          this.refs.image.style.height = newZoom * 100 + "%";
+        }
+      }
+    },
+    getFileInfo() {
+      // 鑾峰彇鐩綍
+      // this.MG.file
+      //   .GetPdfToc({ md5: this.md5 })
+      //   .then((tocRes) => {
+      //     console.log(tocRes, "3232---3232----32");
+      //     if (tocRes && tocRes.length && tocRes[0]) {
+      //       let tocDataList = [];
+      //       for (let i = 0; i < tocRes.length; i++) {
+      //         const tacItem = tocRes[i];
+      //         if (tacItem) {
+      //           let itemInfo = tacItem.split(" ");
+      //           let obj = {
+      //             page: itemInfo[0],
+      //             level: itemInfo[1],
+      //             title: itemInfo[2] + " ( " + itemInfo[0] + " )",
+      //             children: [],
+      //           };
+      //           tocDataList.push(obj);
+      //         }
+      //       }
+      //       let cLevel = 0;
+      //       let tocData = [];
+      //       let generateList = []; // 鐢ㄤ簬妫�绱㈢殑Data
+      //       let memorySrc = null;
+      //       for (let j = 0; j < tocDataList.length; j++) {
+      //         const tocItem = tocDataList[j];
+      //         if (tocItem.level == 0) {
+      //           tocItem.key = tocData.length;
+      //           tocData.push(tocItem);
+      //           generateList.push(tocItem);
+      //           cLevel = 0;
+      //         } else if (tocItem.level == cLevel) {
+      //           tocItem.key = memorySrc.key + "-" + memorySrc.children.length;
+      //           memorySrc.children.push(tocItem);
+      //           generateList.push(tocItem);
+      //         } else if (tocItem.level > cLevel) {
+      //           memorySrc = this.handleDocData(tocData, cLevel);
+      //           tocItem.key = memorySrc.key + "-" + memorySrc.children.length;
+      //           memorySrc.children.push(tocItem);
+      //           generateList.push(tocItem);
+      //           cLevel = tocItem.level;
+      //         } else if (tocItem.level < cLevel) {
+      //           memorySrc = this.handleDocData(tocData, tocItem.level - 1);
+      //           tocItem.key = memorySrc.key + "-" + memorySrc.children.length;
+      //           memorySrc.children.push(tocItem);
+      //           generateList.push(tocItem);
+      //           cLevel = tocItem.level;
+      //         }
+      //       }
+      //       this.tocData = tocData;
+      //       this.generateList = generateList;
+      //       console.log(tocData, generateList, 1221212121211);
+      //     }
+
+          // 鑾峰彇鎬婚〉鏁�
+          this.MG.file
+            .getPdfInfo({ md5: this.md5 })
+            .then((res) => {
+              console.log(res, 79879879879797979);
+              this.totalPage = res.totalPages;
+              this.getPageImage(this.currentPage - 1);
+            })
+            .catch((err) => {
+              console.error(err);
+            });
+        // })
+        // .catch((err) => {
+        //   console.error(err);
+        // });
+    },
+    getPageImage(page) {
+      console.log(page, "page");
+      const ctx = process.env.VUE_APP_API_URL;
+      this.fileLoading = true;
+      this.currentPageSrc =
+        ctx +
+        "/file/Preview/GetPageImage" +
+        "?md5=" +
+        this.md5 +
+        "&index=" +
+        page +
+        "&dpi=150";
+    },
+  },
+};
+</script>
+<style scoped lang="less">
+.imgbox {
+  width: 100%;
+  height: 100%;
+  background-color: aquamarine;
+  img {
+    width: 100%;
+  }
+}
+</style>

--
Gitblit v1.9.1