previewPDF.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <web-view :src="url" @message="handleGetMessage"/>
  3. </template>
  4. <script>
  5. import {h5BaseUrl} from '@/utils/config'
  6. import {apiGetPDFDetail} from '@/api/report.js'
  7. export default {
  8. data() {
  9. return {
  10. msgObj:{},
  11. url:'',
  12. pdf_id:0,
  13. pdf_name:'',
  14. pdf_url:''
  15. };
  16. },
  17. onLoad(options) {
  18. this.init(options)
  19. wx.setVisualEffectOnCapture({visualEffect:'hidden'})
  20. },
  21. onShareAppMessage() {
  22. return {
  23. title:this.msgObj.title||this.pdf_name||'',
  24. path:`/pages-report/previewPDF?pdf_id=${this.pdf_id}`,
  25. imageUrl:this.msgObj.imgUrl||this.globalImgUrls.pdfShareImg
  26. }
  27. },
  28. methods: {
  29. init(options){
  30. this.pdf_id = options.pdf_id
  31. this.getPDFDetail()
  32. },
  33. getPDFDetail(){
  34. apiGetPDFDetail({pdf_id:this.pdf_id}).then(res=>{
  35. if(res.code!==200) return
  36. this.pdf_name=res.data.pdf_name||''
  37. this.pdf_url=res.data.pdf_url||''
  38. const token=this.$store.state.user.token
  39. this.url = `${h5BaseUrl}/hzyb/report/previewpdf?pdfSrc=${this.pdf_url}&token=${token}#wechat_redirect`
  40. //this.url = `http://192.168.77.31:3000/xcx_h5/hzyb/report/previewpdf?pdfSrc=${this.pdf_url}&token=${token}#wechat_redirect`
  41. })
  42. },
  43. handleGetMessage(e){
  44. const data=e.detail.data[e.detail.data.length-1]
  45. console.log('h5传来的数据',data);
  46. this.msgObj=data
  47. },
  48. },
  49. };
  50. </script>
  51. <style scoped lang="scss">
  52. </style>