chapterDetail.vue 1.3 KB

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