<template>
	<view>
		<web-view :src="href"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				href: "",
				
				staff_num:"",
				mine_code:"",
				base_url:""
			};
		},
		onLoad() {
			this.staff_num = uni.getStorageSync('user').staff_num
			
			let mine_code = uni.getStorageSync('mine_code')
			
			if(mine_code == 'ningdongyunying'){
				this.mine_code = "ningdongyunying"
			}else if(mine_code == 'jinjiaqu' || mine_code == 'jinjiaqu_neiwang'){
				this.mine_code = "640323B0011010019259"
			}else if(mine_code == 'ningmeijituan'){
				this.mine_code = "640323B0011010019259"
				this.staff_num = '15102632'
			}
			
			if(uni.getStorageSync("mine_code").indexOf('_neiwang') != -1){
				this.base_url = "http://n.shangtang.jinjiaqu.nxjiewei.com:8011"
			}else{
				this.base_url = "http://shangtang.jinjiaqu.nxjiewei.com:8011"
			}

			this.get_token()
		},
		methods:{
			get_token(){
				uni.request({
					// 登录 获取token
					method:"POST",
					url: this.base_url + "/v1/app/token/get",
					header:{
						"Content-Type": "application/json"
					},
					data: {
						staff_num: this.staff_num,
						area_code: this.mine_code
					},
					success: (res) => {
						console.log(res)
						if(res.data.code == 0){
							console.log(res.data.data)
							// 金家渠
							this.href = this.base_url + "/h5/index.html?token=" + res.data.data.access_token
						}else{
							uni.showToast({
								icon:"none",
								title:"身份信息验证失败！"
							})
						}
					},
					fail: (err) => {
						uni.showToast({
							icon:"none",
							title:err
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
