12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <template>
- <web-view v-if="url" :src="url" @message="handleGetMessage"></web-view>
- </template>
- <script>
- import {h5BaseUrl} from '@/utils/config'
- import {apiGetSceneToParams} from '@/api/common'
- export default {
- data () {
- return {
- url:'',
- msgObj:{},
- options:{}
- }
- },
- onLoad(options) {
- this.options=options
- wx.setVisualEffectOnCapture({visualEffect:'hidden'})
- },
- onShow(){
- this.init(this.options)
- },
- onUnload(){
- wx.setVisualEffectOnCapture({visualEffect:'none'})
- },
- onShareAppMessage() {
- return {
- title:this.msgObj.title,
- path:`/pages-report/reportDetail?reportId=${this.msgObj.reportId}`,
- imageUrl:this.msgObj.shareImg||''
- }
- },
- methods: {
- async init(options){
- console.log('options',options);
- this.url=''
- if(options.scene){
- const res=await apiGetSceneToParams({scene_key:options.scene})
- if(res.code==200){
- console.log(res);
- const obj=JSON.parse(res.data)
- console.log(obj);
- options.reportId=obj.reportId
- console.log(options);
- }
- }
- let reportId=options.reportId
- const timestamp=new Date().getTime()
- const token=this.$store.state.user.token
- setTimeout(()=>{
- this.url=`${h5BaseUrl}/hzyb/report/detail?reportId=${reportId}&userId=${this.userInfo.user_id}&fromPage=${options.fromPage||''}&token=${token}×tamp=${timestamp}#wechat_redirect`
- },100)
- },
- handleGetMessage(e){
- const data=e.detail.data[e.detail.data.length-1]
- console.log('h5传来的数据',data);
- this.msgObj=data
- }
- }
-
- }
- </script>
|