<template>
	<view class="container">
		<!-- <navbar :config="config" backColor="#999999"></navbar> -->
	</view>
</template>

<script>
	let app = getApp();
	export default {
		data() {
			return {
				subNVue: null,
				RefreshMap:true
			};
		},

		onLoad() {

			this.openSubNVue();
			uni.$on('mapJump', (data) => {
				this.$openPage(data)
			})
	 
			uni.$on('onMapNextPage', res => {
				 console.log('地图跳转，返回时不需要刷新')
			});
		},
		onShow() {
			let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
			let upRoute = routes[routes.length - 1].route // 获取当前页面路由，也就是最后一个打开的页面路由
			console.log('upRoute = ' , upRoute , routes.length)
			console.log('this.subNVue = ', this.subNVue)
			if (this.subNVue) {
				this.subNVue.show()
			} else {
				this.openSubNVue();
			}
		},
		onUnload() {
			uni.$off('initPop')
			uni.$off('mapJump')
			uni.$off('NextMap')
			uni.$off('NextMapKwd')

		},
		methods: {
			openSubNVue() {
				this.subNVue = uni.getSubNVueById('mapPopup');
				this.subNVue.setStyle({
					"top": '0',
					'bottom': 0
					// "height": screenHeight - navHeight + 'px'
				})
				this.subNVue && this.subNVue.show()
				// this.subNVue && this.subNVue.show('slide-in-left', 300, () => {
				// 	console.log('初始化')
				// 	uni.$emit('initMap', {
				// 		init: true
				// 	})
				// })
			},
			onSearch(e) {
				uni.$emit('NextMap', e)
			},
			onSearchKwd(e) {
				uni.$emit('NextMapKwd', e)
			}
		},

		onHide() {
			setTimeout(() => {
				const subNVue = uni.getSubNVueById('mapPopup');
				subNVue && subNVue.hide()
			}, 100)
		}
	};
</script>