<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 {
		querySysDictionaryDetailsByCode,
	} from '@/servers/purchaseList.js'
	import { getClientByApp } from '@/servers/address.js'
	import { mapState } from '@/utils/vuex-shim.js'
	export default {
		data() {
			return {
				token: '',
				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.token = res
					this.getSelectDictDataOrigin()
					// this.src = 'https://yingxiao.wuliangye.com.cn/webroot/login/jxsLogin_test.html?'+res //测试环境
					// this.src = 'https://yingxiao.wuliangye.com.cn/webroot/login/jxsLogin.html?'+res  //生产环境
					// this.src = 'https://vls.wuliangyegroup.com.cn:8090/webroot/decision?'+res  //25.6.23生产环境
				}else{
					uni.showToast({
						title: '权限校验不通过',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				
			},
			getSelectDictDataOrigin() {
			  querySysDictionaryDetailsByCode({'code': 'thirdSysUrl'})
				.then(res => {
					const arr = res.data.Rows
					if(arr.length > 0){
						const result = arr.find(item => item.name === 'kanban');
						this.src = result.value + this.token
					}
				})
				.catch(() => {})
			},
			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: 44px;
	}
</style>
