<template>
	<view class="uni-container" style="height: 90%;">
		<view class="uni-header-logo">
			<image class="uni-header-image" src="/static/avatar.png"></image>
		</view>
		<view class="uni-hello-text">
			<view class="hello-text">当前用户：{{ username }}</view>
		</view>
		<uni-section title="当前基地" type="line">
			<view class="uni-px-5 uni-pb-5">
				<uni-data-select v-model="currProId" :localdata="proList" :clear="false" @input="changePro">
				</uni-data-select>
			</view>
		</uni-section>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				baseUrl: "http://192.168.3.23:8086",
				userInfo: {},
				currProInfo: {},
				username: '',
				currProId: 0,
				proList: []
			}
		},
		onShow() {
			this.loadData()
			this.refresh()
		},
		methods: {
			loadData() {
				this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
				this.username = this.userInfo.user.username
				this.currProInfo = JSON.parse(uni.getStorageSync('currProInfo'))
				this.currProId = this.currProInfo.value
				this.proList = JSON.parse(uni.getStorageSync('proList'))
			},
			changePro(e) {
				this.currProInfo = this.proList.filter(item=>{
					return item.value==this.currProId
				})[0]
				uni.setStorageSync('currProInfo', JSON.stringify(this.currProInfo))
			},
			refresh() {
				uni.setNavigationBarTitle({
					title: `我的设置`
				});
			}	
		}
	}
</script>
<style>
	@import '../../../common/uni-nvue.css';

	page {
		width: 100% !important;
		height: 100% !important;
		background-color: #f8f8f8;
	}

	::v-deep .uni-icons {
		display: none;
	}

	.uni-hello-text {
		text-align: center;
	}

	.text {
		font-size: 12px;
		color: #666;
		margin-top: 5px;
	}

	.uni-px-5 {
		padding-left: 10px;
		padding-right: 10px;
	}

	.uni-pb-5 {
		padding-bottom: 10px;
	}
	
	.uni-header-logo{
		display: flex;
	}
</style>
