<template>
  <web-view v-if='src' :src="src"></web-view>
</template>

<script>
  export default {
    data() {
      return {
        token:'',
		id:'',
		src:'',
		userid:'',
		deviceId:'',
		url:''
      };
    },
	onLoad(options) {
		// console.log('options',options);
		if(options){
			this.id = options.id;
			this.deviceId = options.deviceId;
			this.url=options.url
		}
		let that = this
		uni.getStorage({
			key: 'token',
			success: function(res) {
				// console.log('res',res);
				that.token = res.data;
				uni.getStorage({
					key:'userid',
					success:function(res){
						that.userid = res.data
						that.src = `https://portal.lihe-control.com/#/${options.url}?id=${that.id}&token=${that.token}&userid=${that.userid}&deviceId=${that.deviceId}`
					}
				})
			},
			fail:function(err){
				uni.navigateTo({
					url:'/pages/fertilizer_machine/fertilizer_machine'
				});
				uni.showToast({
					title: "跳转失败!",
					icon: 'fail',
				})
			}
		})
	}
  }
</script>

<style lang="scss">

</style>
