chapterDetail.vue 1.5 KB

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