<template>
  <web-view :src="url"></web-view>
</template>
 
<script>
export default {
  data() {
    return {
      url: '',
	  tempUrl: ''
    }
  },
  onLoad(option) {
	  let url = ''
	  console.log(option);
	  if (option.url) {
	  	url = decodeURIComponent(option.url)
	  }else{
		url = uni.getStorageSync('webUrl')
		console.log(url);
	  }
	  this.tempUrl = url
  },
  onShow() {
  	let url = this.tempUrl
  	// 如果跳转地图需要token
  	  if(url.toLocaleLowerCase().indexOf('yandumap.sz-trip.com')>=0 && url.toLocaleLowerCase().indexOf("token")<0) {
  		  let userInfo = (uni.getStorageSync('userInfo') && JSON.parse(uni.getStorageSync('userInfo'))) || this.$store.state.user.userInfo || {}
  		  if(userInfo.token) {
  				let tokenParam = 'token=' + userInfo.token
  				let concatStr = url.indexOf('?')>0?'&':'?'
  				url+=concatStr
  				url+=tokenParam
  		  }else {
  				uni.navigateTo({
  					url: '/pages/login/login',
  				})
				return
  		  }
  	  }
  	  
  	  if (this.url != url) {
  		  this.url = url
  	  }
  	console.log(this.url)
  	// 传入需要跳转的链接 使用web-view标签进行跳转
  },
}
</script>
 
<style lang="scss" scoped>
	
</style>
 