detail.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <web-view :src="url" @message="handleGetMessage"></web-view>
  3. </template>
  4. <script>
  5. import {h5BaseUrl} from '@/utils/config'
  6. export default {
  7. data () {
  8. return {
  9. url:'',
  10. msgObj:{}
  11. }
  12. },
  13. onShareAppMessage() {
  14. let paramsStr=''
  15. for(const key in this.msgObj.params){
  16. if(!paramsStr){
  17. paramsStr=`${key}=${this.msgObj.params[key]}`
  18. }else{
  19. paramsStr=`${paramsStr}&${key}=${this.msgObj.params[key]}`
  20. }
  21. }
  22. return {
  23. title:this.msgObj.title||'持仓分析详情',
  24. path:`/pages/positionAnalysis/detail?${paramsStr}&from=share`,
  25. imageUrl:this.msgObj.shareImg||''
  26. }
  27. },
  28. onLoad(options){
  29. const queryObj={
  30. classify_name:options.classify_name,
  31. classify_type:options.classify_type,
  32. exchange:options.exchange,
  33. token:this.$store.state.user.token||uni.getStorageSync("token"),
  34. timestamp:new Date().getTime(),//防止缓存
  35. }
  36. let queryObjStr=''
  37. for (const key in queryObj) {
  38. if(!queryObjStr){
  39. queryObjStr=`${key}=${queryObj[key]}`
  40. }else{
  41. queryObjStr=`${queryObjStr}&${key}=${queryObj[key]}`
  42. }
  43. }
  44. console.log('拼接字符串:',queryObjStr);
  45. this.url=`${h5BaseUrl}/hzyb/chart/positionanalysis?${queryObjStr}#wechat_redirect`
  46. },
  47. methods: {
  48. // 获取到用户点击转发时从h5页面传来的参数
  49. handleGetMessage(e){
  50. const data=e.detail.data[e.detail.data.length-1]
  51. console.log('h5传来的数据',data);
  52. this.msgObj=data
  53. }
  54. },
  55. }
  56. </script>
  57. <style>
  58. page{
  59. padding-bottom: constant(safe-area-inset-bottom);
  60. padding-bottom: env(safe-area-inset-bottom);
  61. }
  62. </style>