<template>
  <div class="user_content">
    <div class="mine_content">
      <div class="mine_icon">
        <nut-avatar class="demo-avatar" icon="my" color="#fff" bg-color="#FA2C19"></nut-avatar>
      </div>
      <div class="mine_name">{{userName}}</div>
    </div>
    <div class="logout">
      <nut-button type="info" block @click="logout">退出登录</nut-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "Mine"
}
</script>
<script setup>
  import { ref, onMounted } from 'vue'
  import { getInfo } from "../../assets/api/user";
  import { removeToken, removeIsSuper } from "../../utils/auth";
  import { useRouter } from "vue-router";

  const userName = ref('');
  const router = useRouter()

  const init = () => {
    getInfo().then(res => {
      userName.value = res.name
    })
  }

  const logout = () => {
    removeToken()
    router.replace('/login')
    setTimeout(() => {
      location.reload()
    }, 500)
  }

  onMounted(() => {
     init()
  })

</script>

<style scoped>
.user_content {
  width: 100%;
  height: 250px;
  box-sizing: border-box;
  padding: 10px 0;
  /* background-color: #01C3F0; */
  text-align: center;
  background: #0081FF;
  position: relative;
}
.mine_content {
  margin-top: 50px;
  width: 100%;
  box-sizing: border-box;
  padding: 25px 16px 22px 30px;
  display: flex;
  align-items: center;
}
.mine_icon {
  width: 70px;
  height: 70px;
  margin-right: 60px;
  margin-top: auto;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  /*display: flex;*/
  /*align-items: center;*/
  /*background: url('https://dam.img.ifarmcloud.com:8030/images/tongwei/mine_icon.png') no-repeat;*/
  /*background-size: 100% 100%;*/
}
.mine_name {
  font-size: 18px;
  font-weight: 400;
  color: #FFFFFF;
}

.logout {
  position: absolute;
  width: 100%;
  box-sizing: border-box;
  padding: 0 20px;
  margin-top: 100px;
  /*position: absolute;*/
  /*left: 0;*/
  /*bottom: 20px;*/
}
</style>
