12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <template>
- <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:'',
- pdf_id:0,
- pdf_name:'',
- pdf_url:''
- };
- },
- onLoad(options) {
- this.init(options)
- wx.setVisualEffectOnCapture({visualEffect:'hidden'})
- },
- onShareAppMessage() {
- return {
- 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.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]
- console.log('h5传来的数据',data);
- this.msgObj=data
- },
- },
- };
- </script>
- <style scoped lang="scss">
- </style>
|