xgwangman 4 роки тому
батько
коміт
9fdb4cc80c

+ 1 - 0
jydocs-mobile/package.json

@@ -14,6 +14,7 @@
     "html2canvas": "^1.0.0-rc.6",
     "js-cookie": "^2.2.1",
     "moment": "^2.24.0",
+    "pdfjs-dist": "^2.6.347",
     "vant": "^2.8.2",
     "vue": "^2.6.11",
     "vue-class-component": "^7.2.3",

+ 1 - 1
jydocs-mobile/src/api/index.ts

@@ -2,7 +2,7 @@ import request from '@/api/ajax'
 import mock from '@/api/mock'
 
 let $request: any = request
-if (process.env.NODE_ENV === 'development' && process.env.VUE_APP_MOCK === 'true') {
+if (process.env.NODE_ENV === 'development' && process.env.VUE_APP_MOCK === 'false') {
   $request = mock
 }
 

+ 3 - 3
jydocs-mobile/src/components/SharePopup.vue

@@ -13,11 +13,11 @@
             <span class="share_detail">了解详情</span>
         </div>
         <div class="share_channel">
-            <div class="share_c_wx share_out" @click="wxShare('1')">
+            <div class="share_c_wx share_out" @click="shareClick('1')">
                 <img src="../assets/icon/weixin.png" class="share_out_img" alt="">
                 <span class="wx_text out_text">微信</span>
             </div>
-            <div class="share_c_pyq share_out" @click="wxShare('3')">
+            <div class="share_c_pyq share_out" @click="shareClick('3')">
                 <img src="../assets/icon/pengyouquan.png" class="share_out_img" alt="">
                 <span class="pyq_text out_text">朋友圈</span>
             </div>
@@ -47,7 +47,7 @@ export default class extends Vue {
       this.show = false
     }
 
-    wxShare (num: string) {
+    shareClick (num: string) {
       shareToOthers({
         type: num, // options.type--1微信分享,2qq分享,3朋友圈分享
         title: this.detailData.docName,

+ 47 - 38
jydocs-mobile/src/views/details/details.vue

@@ -13,7 +13,7 @@
         </div>
         <div class="botts" v-show="buyed">
             <div class="cont-page" id="pdfPage">
-                <iframe :src="conts" width="100%" height="100%"></iframe>
+                <!-- <iframe :src="conts" width="100%" height="100%"></iframe> -->
             </div>
         </div>
         <van-goods-action>
@@ -41,6 +41,8 @@ import { Icon, Toast, GoodsAction, GoodsActionIcon, GoodsActionButton } from 'va
 import Recharge from '@/components/Recharge.vue'
 import sharePop from '@/components/SharePopup.vue'
 import { MixinTop } from '@/utils/mixin-top'
+const pdfjsLib = require('pdfjs-dist/build/pdf.js').default
+const pdfjsViewer = require('pdfjs-dist/web/pdf_viewer.js').default
 
 @Component({
   name: 'details-p',
@@ -135,39 +137,39 @@ export default class extends Vue {
   //   }
   // }
 
-  // renders () {
-  //   const container = document.getElementById('pdfPage')
-  //   return this.pdfDocument.getPage(this.config.PAGE_TO_VIEW).then((pdfPage: any) => {
-  //     const pdfPageView = new pdfjsViewer.PDFPageView({
-  //       container: container,
-  //       id: this.config.PAGE_TO_VIEW,
-  //       scale: this.config.SCALE,
-  //       defaultViewport: pdfPage.getViewport({ scale: this.config.SCALE }),
-  //       eventBus: new pdfjsViewer.EventBus(),
-  //       annotationLayerFactory: new pdfjsViewer.DefaultAnnotationLayerFactory()
-  //     })
-  //     pdfPageView.setPdfPage(pdfPage)
-  //     this.pData.heightList.push(pdfPageView.viewport.height)
-  //     return pdfPageView.draw()
-  //   })
-  // }
+  renders () {
+    const container = document.getElementById('pdfPage')
+    return this.pdfDocument.getPage(this.config.PAGE_TO_VIEW).then((pdfPage: any) => {
+      const pdfPageView = new pdfjsViewer.PDFPageView({
+        container: container,
+        id: this.config.PAGE_TO_VIEW,
+        scale: this.config.SCALE,
+        defaultViewport: pdfPage.getViewport({ scale: this.config.SCALE }),
+        eventBus: new pdfjsViewer.EventBus(),
+        annotationLayerFactory: new pdfjsViewer.DefaultAnnotationLayerFactory()
+      })
+      pdfPageView.setPdfPage(pdfPage)
+      this.pData.heightList.push(pdfPageView.viewport.height)
+      return pdfPageView.draw()
+    })
+  }
 
-  // init () {
-  //   console.log(this.conts)
-  //   const loadingTask = pdfjsLib.getDocument({
-  //     url: this.conts
-  //   })
-  //   loadingTask.promise.then((pdfDocument: any) => {
-  //     this.pdfDocument = pdfDocument
-  //     console.log(this.pdfDocument.numPages)
-  //     // this.updateText({type: 'count', value: this.pdfDocument.numPages})
-  //     // this.updateText({type: 'num', value: 1})
-  //     for (let i = 0; i < this.pdfDocument.numPages; i++) {
-  //       this.config.PAGE_TO_VIEW++
-  //       this.renders()
-  //     }
-  //   })
-  // }
+  init () {
+    console.log(this.conts)
+    const loadingTask = pdfjsLib.getDocument({
+      url: this.conts
+    })
+    loadingTask.promise.then((pdfDocument: any) => {
+      this.pdfDocument = pdfDocument
+      console.log(this.pdfDocument.numPages)
+      // this.updateText({type: 'count', value: this.pdfDocument.numPages})
+      // this.updateText({type: 'num', value: 1})
+      for (let i = 0; i < this.pdfDocument.numPages; i++) {
+        this.config.PAGE_TO_VIEW++
+        this.renders()
+      }
+    })
+  }
 
   watchPage () {
     const top = window.scrollY
@@ -181,21 +183,28 @@ export default class extends Vue {
     }
   }
 
+  buyShow () {
+    this.getShow({ docId: this.docIds }).then((res: any) => {
+      console.log(res.data)
+      this.conts = res.data
+      this.init()
+    })
+  }
+
   onList () {
-    this.getDetails({ docId: this.docIds }).then((res: any) => {
+    this.getDetails({ docId: this.docIds, from: this.$route.query.from }).then((res: any) => {
       console.log(res.data)
       this.detailData = res.data.detail
       this.buyed = res.data.status
+      if (res.data.status === 1) {
+        this.buyShow()
+      }
       this.collectd = res.data.collect
     })
     this.getCoin({ B: true }).then((res: any) => {
       console.log(res.data.data)
       this.coins = res.data.data.points
     })
-    this.getShow({ docId: this.docIds }).then((res: any) => {
-      console.log(res.data)
-      this.conts = res.data
-    })
   }
 
   jubaod () {

+ 5 - 0
jydocs-mobile/yarn.lock

@@ -6942,6 +6942,11 @@ pbkdf2@^3.0.3:
     safe-buffer "^5.0.1"
     sha.js "^2.4.8"
 
+pdfjs-dist@^2.6.347:
+  version "2.6.347"
+  resolved "https://registry.npm.taobao.org/pdfjs-dist/download/pdfjs-dist-2.6.347.tgz#f257ed66e83be900cd0fd28524a2187fb9e25cd5"
+  integrity sha1-8lftZug76QDND9KFJKIYf7niXNU=
+
 performance-now@^2.1.0:
   version "2.1.0"
   resolved "https://registry.npm.taobao.org/performance-now/download/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"