reportDetail.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <web-view v-if="url" :src="url" @message="handleGetMessage"></web-view>
  3. </template>
  4. <script>
  5. import {h5BaseUrl} from '@/utils/config'
  6. import {apiGetSceneToParams} from '@/api/common'
  7. export default {
  8. data () {
  9. return {
  10. url:'',
  11. msgObj:{},
  12. options:{}
  13. }
  14. },
  15. onLoad(options) {
  16. this.options=options
  17. wx.setVisualEffectOnCapture({visualEffect:'hidden'})
  18. },
  19. onShow(){
  20. this.init(this.options)
  21. },
  22. onUnload(){
  23. wx.setVisualEffectOnCapture({visualEffect:'none'})
  24. },
  25. onShareAppMessage() {
  26. return {
  27. title:this.msgObj.title,
  28. path:`/pages-report/reportDetail?reportId=${this.msgObj.reportId}`,
  29. imageUrl:this.msgObj.shareImg||''
  30. }
  31. },
  32. methods: {
  33. async init(options){
  34. console.log('options',options);
  35. this.url=''
  36. if(options.scene){
  37. const res=await apiGetSceneToParams({scene_key:options.scene})
  38. if(res.code==200){
  39. console.log(res);
  40. const obj=JSON.parse(res.data)
  41. console.log(obj);
  42. options.reportId=obj.reportId
  43. console.log(options);
  44. }
  45. }
  46. let reportId=options.reportId
  47. const timestamp=new Date().getTime()
  48. const token=this.$store.state.user.token
  49. setTimeout(()=>{
  50. this.url=`${h5BaseUrl}/hzyb/report/detail?reportId=${reportId}&userId=${this.userInfo.user_id}&fromPage=${options.fromPage||''}&token=${token}&timestamp=${timestamp}#wechat_redirect`
  51. },100)
  52. },
  53. handleGetMessage(e){
  54. const data=e.detail.data[e.detail.data.length-1]
  55. console.log('h5传来的数据',data);
  56. this.msgObj=data
  57. }
  58. }
  59. }
  60. </script>