chapterDetail.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. 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/chapterDetail?chapterId=${this.msgObj.chapterId}`,
  25. imageUrl:this.msgObj.shareImg||''
  26. }
  27. },
  28. methods: {
  29. async init(options){
  30. if(options.scene){
  31. const res=await apiGetSceneToParams({scene_key:options.scene})
  32. if(res.code==200){
  33. const obj=JSON.parse(res.data)
  34. options.chapterId=obj.chapterId
  35. }
  36. }
  37. let chapterId=options.chapterId
  38. let fromPage=options.fromPage||''
  39. const timestamp=new Date().getTime()
  40. const token=this.$store.state.user.token
  41. this.url=`${h5BaseUrl}/hzyb/report/chapterdetail?chapterId=${chapterId}&userId=${this.userInfo.user_id}&fromPage=${fromPage}&token=${token}&timestamp=${timestamp}#wechat_redirect`
  42. },
  43. handleGetMessage(e){
  44. const data=e.detail.data[e.detail.data.length-1]
  45. console.log('h5传来的数据',data);
  46. this.msgObj=data
  47. }
  48. }
  49. };
  50. </script>