<template>
	<view class="">
		<view class="status_bar" :style="navHeight"></view>
		<web-view ref="web-view" class="uni-flex-item" :src="src" :webview-styles="webview_styles" @message="message"
			@error="error" @loading="loading" @loaded="loaded">
		</web-view>
	</view>
</template>

<script>
	import { getClientByApp } from '@/servers/address.js'
	import { mapState } from 'vuex'
	export default {
		data() {
			return {
				src: '',
				webview_styles: {
				}
			}
		},
		onLoad() {
			this.getClientByApp()
		},
		computed: {
			...mapState(['userInfo']),
			navHeight() {
				return {
					'height': `100px`
				}
			},
		},
		methods: {
			async getClientByApp(){
				const res = await getClientByApp({code: this.userInfo.code})
				if(res){
					this.src = 'https://yingxiao.wuliangye.com.cn/webroot/login/jxsLogin.html?'+res
				}else{
					uni.showToast({
						title: '权限校验不通过',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				
			},
			message(event) {
				console.log(JSON.stringify(event.detail));
			},
			error(event) {
				console.log(JSON.stringify(event.detail));
			},
			loading(event) {
				console.log(JSON.stringify(event.type));
			},
			loaded(event ) {
				console.log(JSON.stringify(event.type));
			},
		}
	}
</script>

<style>
	.uni-input-v {
		padding: 10rpx 0;
	}

	.uni-btn-ml {
		margin-left: 10rpx;
	}
	.uni-flex-item{
		height: 100%
	}
	.status_bar {
		height: var(--status-bar-height);
	}
</style>
