1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <template>
- <web-view :src="url" @message="handleGetMessage"/>
- </template>
- <script>
- import {h5BaseUrl} from '@/utils/config'
- import {apiGetPDFDetail} from '@/api/report.js'
- import {apiGetSceneToParams} from '@/api/common'
- 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.shareImg||this.globalImgUrls.pdfShareImg
- }
- },
- methods: {
- async init(options){
- if(options.scene){
- const res=await apiGetSceneToParams({scene_key:options.scene})
- if(res.code==200){
- const obj=JSON.parse(res.data)
- options.pdf_id = obj.pdf_id
- this.pdf_id = Number(obj.pdf_id)
- this.getPDFDetail()
- }
- }else{
- this.pdf_id = Number(options.pdf_id)||0
- this.getPDFDetail()
- }
-
- },
- getPDFDetail(){
- if(!this.pdf_id){
- uni.showToast({
- title: '未找到PDF',
- icon: 'none'
- })
- return
- }
- 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>
|