<template>
	<view style="height: 100vh" class="bg-white">
		<view class="cu-bar bg-white solid-bottom">
			<view class="action">
				<text class="cuIcon-title text-orange "></text> 用户信息
			</view>
		</view>
		<view class="cu-list menu">
			<view class="cu-item">
				<view class="content">
					<view class="text-gray">用户账号</view>
				</view>
				<view class="content">
					<view class="text-gray">{{userInfo.account}}</view>
				</view>
			</view>
			<view class="cu-item">
				<view class="content">
					<view class="text-gray">用户名称</view>
				</view>
				<view class="content">
					<view class="text-gray">{{userInfo.name}}</view>
				</view>
			</view>
			<view class="cu-item">
				<view class="content">
					<view class="text-gray">是否管理员</view>
				</view>
				<view class="content">
					<view class="text-gray"> {{userInfo.adminType == 1?"是":"否"}}</view>
				</view>
			</view>
		</view>
		<u-line></u-line>
		<view class="content" style="margin-top: 50rpx;display: flex;text-align: center;">
			<view style="width: 50%;">
				<button class="cu-btn bg-blue shadow" style="height: 80rpx;" @click="modifyPassword">修改密码</button>
			</view>
			<view style="width: 50%;">
				<button class="cu-btn bg-blue shadow" style="height: 80rpx;" @click="logout">注销登录</button>
			</view>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import {
		getLoginUserInfo
	} from '@/api/system/user.js'
	export default {
		data() {
			return {
				userInfo: {},
			}
		},
		methods: {
			modifyPassword() {
				uni.navigateTo({
					url: '/pages/user/modify-password?userId=' + this.userInfo.id
				})
			},
			getSysUserInfo() {
				getLoginUserInfo().then(res => {
					if (res.success) {
						this.userInfo = res.data
					}
				})
			},
			logout() {
				this.$store.dispatch("LogOut").then(res => {
					uni.navigateTo({
						url: '/pages/login/index'
					})
				})
			}
		},
		onLoad() {
			this.getSysUserInfo()
		}
	}
</script>

<style>
</style>
