<template>
	<view class="app">
		<view class="user">
			<!-- <view>
				<image class="img" mode=""></image>
			</view> -->
			<view class="img">
				<image src="../../static/users.png" mode=""></image>
			</view>
			<view class="phone">
			</view>
			<view class="nickname" v-if="userlist">
				{{userlist.username}}
			</view>
			<!-- <view class="modify">
				修改信息
			</view> -->
		</view>
		<view class="information" v-if="userlist">
			<view class="item" v-if="userlist.loginName">
				登录账号：{{userlist.loginName}}
			</view>
			<view class="item" v-else>
				登录账号：
			</view>
			<view v-if="userlist.username" class="item">
				用户名：{{userlist.username}}
			</view>
			<view class="item" v-else>
				用户名：
			</view>
			<view v-if="userlist.roleName" class="item">
				角色名称：{{userlist.roleName}}
			</view>
			<view class="item" v-else>
				角色名称：
			</view>
			<!-- <view v-if="userlist.bumen" class="item"
				style="height:100%;border-bottom: none;border-radius: 0 0 20rpx 20rpx ;">
				机构名称：{{userlist.bumen}}
			</view>
			<view class="item" v-else style="height:100%;border-bottom: none;border-radius: 0 0 20rpx 20rpx ;">
				机构名称：
			</view> -->
			<view class="signout" @tap='remove'>
				退出账号
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getUserInfo
	} from '@/api/user/index.js'
	export default {
		data() {
			return {
				userlist: null,
				timer: null,
			}
		},
		onShow() {
			this.info();
		},
		onLoad(options) {

		},
		methods: {
			info() {
				getUserInfo().then(res => {
					this.userlist = res.data
				})
			},
			remove() {
				let that = this
				uni.showModal({
					title: '提示',
					content: '确认要退出此账号吗',
					success: function(res) {
						if (res.confirm) {
							uni.removeStorageSync('token')
							if (that.timer) {
								clearTimeout(that.timer)
							}
							that.timer = setTimeout(e => {
								uni.reLaunch({
									url: '/pages/login/login'
								})
							}, 1000)
						} else if (res.cancel) {}
					}
				});
			},
		},
	}
</script>
<style lang="scss">
	@import "./user.scss";
</style>
