reportDetail.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <web-view :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. }
  13. },
  14. onLoad(options) {
  15. this.init(options)
  16. wx.setVisualEffectOnCapture({visualEffect:'hidden'})
  17. },
  18. onUnload(){
  19. wx.setVisualEffectOnCapture({visualEffect:'none'})
  20. },
  21. onShareAppMessage() {
  22. return {
  23. title:this.msgObj.title,
  24. path:`/pages-report/reportDetail?reportId=${this.msgObj.reportId}`,
  25. imageUrl:this.msgObj.shareImg||''
  26. }
  27. },
  28. methods: {
  29. async init(options){
  30. console.log('options',options);
  31. if(options.scene){
  32. const res=await apiGetSceneToParams({scene_key:options.scene})
  33. if(res.code==200){
  34. console.log(res);
  35. const obj=JSON.parse(res.data)
  36. console.log(obj);
  37. options.reportId=obj.reportId
  38. console.log(options);
  39. }
  40. }
  41. let reportId=options.reportId
  42. const timestamp=new Date().getTime()
  43. const token=this.$store.state.user.token
  44. this.url=`${h5BaseUrl}/hzyb/report/detail?reportId=${reportId}&userId=${this.userInfo.user_id}&fromPage=${options.fromPage||''}&token=${token}&timestamp=${timestamp}#wechat_redirect`
  45. },
  46. handleGetMessage(e){
  47. const data=e.detail.data[e.detail.data.length-1]
  48. console.log('h5传来的数据',data);
  49. this.msgObj=data
  50. }
  51. }
  52. }
  53. </script>