<template>
	<web-view cache="no-cache" :src="webViewSrc" @message="getMSG"></web-view>
</template>

<script>
	import {getToken} from '@/libs/auth.js';
	export default {
		data() {
			return {
				webViewSrc:""
			}
		},
		onLoad(options) {
			this.init(options)	
		},
		methods: {
			init(options){
				let t=new Date().getTime();
				if(options.type==='scan'){
					let href="http://h5.xazhyc.com/scanApp/#/pages/index/index"
					let qrcode=uni.getStorageSync('qrcode')
					qrcode=qrcode.split('?')[1]
					this.webViewSrc=`${href}?token=${getToken()}&${qrcode}&v=${t}`
					console.log(`${href}?token=${getToken()}&${qrcode}&v=${t}`)
					uni.setNavigationBarTitle({
						title:"扫码操作"
					})										
				}else{
					let other=""
					for(let key in options){
						if(key!=='href'&&key!=='name'){
							other+=`${key}=${options[key]}&`
						}
					}
					this.webViewSrc=`${options.href}?token=${getToken()}&${other}v=${t}`	
					uni.setNavigationBarTitle({
						title:`${options.name}`
					})									
				}
			},
			getMSG(){
				
			}
		},
		onBackPress(e){
			// console.log(e)
		}
	}
</script>