<template>
    <div>
        <div style="margin-top: 20px">
            <van-cell title="用户名" :value="userInfo.username"></van-cell>
            <van-cell title="真实姓名" :value="userInfo.realname"></van-cell>
            <van-cell title="性别" :value="userInfo.sex==1?'女':'男'"></van-cell>
        </div>
        <div style="margin-top: 20px">
            <van-cell title="所属部门" :value="userInfo.orgNames"></van-cell>
            <van-cell title="所属角色" :value="userInfo.roleNames"></van-cell>
        </div>
        <div style="margin-top: 20px">
            <van-cell title="手机号" :value="userInfo.mobile"></van-cell>
            <van-cell title="个人邮箱" :value="userInfo.email"></van-cell>
            <van-cell title="联系QQ" :value="userInfo.qq"></van-cell>
        </div>
        <div style="margin: 40px auto 0;width: 80%;">
            <van-button icon="edit" block type="info" @click="_editPwd">修改密码</van-button>
        </div>
    </div>
</template>

<script>
    import {sysUser} from '../../api'

    export default {
        data() {
            return {
                userInfo: {},
                id: '',
            }
        },
        mounted() {
            this._getUserInfo()
        },
        methods: {
            //跳转
            _editPwd() {
                this.$router.push('/mine/pwd_edit');
            },
            //用户信息
            async _getUserInfo() {
                //重新获取用户信息
                let user = await sysUser.getUserInfo();
                if (user) {
                    this.$global.setUserInfo(user);
                    this.userInfo = user;
                    this.id = user.id;
                }
            },
            //退出
            _exit() {
                this.$global.logout();
                // this.$navigation.cleanRoutes(); //清空路由了，但是浏览器中的路由仍在
                this.$router.replace('/login')
            },
        }
    }
</script>
<style scoped>
    .header-top-title {
        margin: 65px auto 10px auto;
        text-align: center;
    }
</style>
