cxmo 1 год назад
Родитель
Сommit
618a1285d9
3 измененных файлов с 32 добавлено и 5 удалено
  1. 9 0
      api/report.js
  2. 22 5
      pages-report/previewPDF.vue
  3. 1 0
      utils/config.js

+ 9 - 0
api/report.js

@@ -152,4 +152,13 @@ export const apiReportChapterAudioSet=params=>{
  */
 export const apiRddpShareImg=params=>{
     return httpPost('/report/detail/rddp_share_img',{source:'rddp_share_img',...params})
+}
+
+/**
+ * 获取PDF详情
+ * @param pdf_id 
+ * @returns 
+ */
+export const apiGetPDFDetail = params=>{
+    return httpGet('/report/pdf/detail',params)
 }

+ 22 - 5
pages-report/previewPDF.vue

@@ -1,13 +1,18 @@
 <template>
-    <web-view :src="url" />
+    <web-view :src="url" @message="handleGetMessage"/>
 </template>
 
 <script>
+import {h5BaseUrl} from '@/utils/config'
+import {apiGetPDFDetail} from '@/api/report.js'
 export default {
     data() {
         return {
             msgObj:{},
-            url:''
+            url:'',
+            pdf_id:0,
+            pdf_name:'',
+            pdf_url:''
         };
     },
     onLoad(options) {
@@ -16,13 +21,25 @@ export default {
     },
     onShareAppMessage() {
         return {
-            title:this.msgObj.title,
-            path:`/pages-report/previewPDF?Id=${this.msgObj.Id}`,
+            title:this.msgObj.title||this.pdf_name||'',
+            path:`/pages-report/previewPDF?pdf_id=${this.pdf_id}`,
+            imageUrl:this.msgObj.imgUrl||this.globalImgUrls.pdfShareImg
         }
     },
     methods: {
         init(options){
-            this.url = `http://192.168.77.31:3000/xcx_h5/hzyb/report/previewpdf`
+            this.pdf_id = options.pdf_id
+            this.getPDFDetail()
+        },
+        getPDFDetail(){
+            apiGetPDFDetail({pdf_id:this.pdf_id}).then(res=>{
+                if(res.code!==200) return 
+                this.pdf_name=res.data.pdf_name||''
+                this.pdf_url=res.data.pdf_url||''
+                const token=this.$store.state.user.token
+                this.url = `${h5BaseUrl}/hzyb/report/previewpdf?pdfSrc=${this.pdf_url}&token=${token}#wechat_redirect`
+                //this.url = `http://192.168.77.31:3000/xcx_h5/hzyb/report/previewpdf?pdfSrc=${this.pdf_url}&token=${token}#wechat_redirect`
+            })
         },
         handleGetMessage(e){
             const data=e.detail.data[e.detail.data.length-1]

+ 1 - 0
utils/config.js

@@ -35,6 +35,7 @@ const globalImgUrls={
 	sandBoxNoAuthor:'https://hzstatic.hzinsights.com/static/icon/hzyb/sandbox_no_author.png', //沙盘无权限 无数据
 	sandBoxShareDefault1:'https://hzstatic.hzinsights.com/static/images/yb/sandbox_20220705160455.png', //沙盘分享时 默认图片1
 	sandBoxShareDefault2:'https://hzstatic.hzinsights.com/static/images/yb/sandbox_20220705160533.png', //沙盘分享时 默认图片2
+    pdfShareImg:'https://hzstatic.hzinsights.com/static/images/yb/report_pdf_share_cover.png',//PDF报告分享图
 }
 
 // 默认tabbar数据