瀏覽代碼

fix: pdf 分次显示

zhangyuhan 4 年之前
父節點
當前提交
d0ad98d765
共有 1 個文件被更改,包括 24 次插入4 次删除
  1. 24 4
      jydocs-mobile/src/views/details/details.vue

+ 24 - 4
jydocs-mobile/src/views/details/details.vue

@@ -1,5 +1,5 @@
 <template>
-    <div class="details-p"  @scroll="showMorePage">
+    <div class="details-p" ref="sContent"  @scroll="showMorePage">
         <div class="top-title-group flex-r-c">
           <van-icon :name="'diy-' + fileType(detailData.docFileType)"></van-icon>
           <div class="flex">{{detailData.docName}}</div>
@@ -117,13 +117,16 @@ export default class extends Vue {
     }
   }
 
+  showPageNum = 2
+  showPageNumT: any = ''
+
   created () {
     this.docIds = this.$route.params.id
     this.onList()
   }
 
   get getPageNum () {
-    return this.pdfPage.pageNum
+    return this.showPageNum
   }
 
   get Offset () {
@@ -135,8 +138,25 @@ export default class extends Vue {
     }
   }
 
-  showMorePage (e: Event) {
-    console.log(e, 'ss')
+  getMorePage () {
+    if (this.showPageNum < this.pdfPage.pageNum) {
+      if (this.showPageNum + 2 <= this.pdfPage.pageNum) {
+        this.showPageNum = this.showPageNum + 2
+      } else {
+        this.showPageNum = this.pdfPage.pageNum
+      }
+    }
+  }
+
+  showMorePage () {
+    const tDom = this.$refs.sContent as HTMLDivElement
+    const beBottom = tDom.scrollHeight - tDom.clientHeight - tDom.scrollTop
+    if (beBottom <= 200) {
+      clearTimeout(this.showPageNumT)
+      this.showPageNumT = setTimeout(() => {
+        this.getMorePage()
+      }, 300)
+    }
   }
 
   getNumPages (url: string) {