map - 副本.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view class="container">
  3. <!-- <navbar :config="config" backColor="#999999"></navbar> -->
  4. </view>
  5. </template>
  6. <script>
  7. let app = getApp();
  8. export default {
  9. data() {
  10. return {
  11. subNVue: null,
  12. RefreshMap:true
  13. };
  14. },
  15. onLoad() {
  16. this.openSubNVue();
  17. uni.$on('mapJump', (data) => {
  18. this.$openPage(data)
  19. })
  20. uni.$on('onMapNextPage', res => {
  21. console.log('地图跳转,返回时不需要刷新')
  22. });
  23. },
  24. onShow() {
  25. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  26. let upRoute = routes[routes.length - 1].route // 获取当前页面路由,也就是最后一个打开的页面路由
  27. console.log('upRoute = ' , upRoute , routes.length)
  28. console.log('this.subNVue = ', this.subNVue)
  29. if (this.subNVue) {
  30. this.subNVue.show()
  31. } else {
  32. this.openSubNVue();
  33. }
  34. },
  35. onUnload() {
  36. uni.$off('initPop')
  37. uni.$off('mapJump')
  38. uni.$off('NextMap')
  39. uni.$off('NextMapKwd')
  40. },
  41. methods: {
  42. openSubNVue() {
  43. this.subNVue = uni.getSubNVueById('mapPopup');
  44. this.subNVue.setStyle({
  45. "top": '0',
  46. 'bottom': 0
  47. // "height": screenHeight - navHeight + 'px'
  48. })
  49. this.subNVue && this.subNVue.show()
  50. // this.subNVue && this.subNVue.show('slide-in-left', 300, () => {
  51. // console.log('初始化')
  52. // uni.$emit('initMap', {
  53. // init: true
  54. // })
  55. // })
  56. },
  57. onSearch(e) {
  58. uni.$emit('NextMap', e)
  59. },
  60. onSearchKwd(e) {
  61. uni.$emit('NextMapKwd', e)
  62. }
  63. },
  64. onHide() {
  65. setTimeout(() => {
  66. const subNVue = uni.getSubNVueById('mapPopup');
  67. subNVue && subNVue.hide()
  68. }, 100)
  69. }
  70. };
  71. </script>