<template>
  <div class="appStore">
    <div class="topC">
      <img @click="backPage" src="../../../assets/images/appStoreCopy/backPage.svg" alt="" />
      <div>{{ userinfo.username }}</div>
    </div>
    <div class="infoCon">
      <div style="font-size: 14px;">账户</div>
      <!-- <div class="Blo">
        <div style="display: flex;align-items: center;gap: 10px;">
          <img src="../../../assets/images/appStoreCopy/tel.svg" alt="" />
          账号
        </div>
        <span style="color: #969BA3;">{{ userinfo.accountNumber }}</span>
      </div> -->
      <div class="Blo">
        <div style="display: flex;align-items: center;gap: 10px;">
          <img src="../../../assets/images/appStoreCopy/sch.svg" alt="" />
          学校
        </div>
        <span style="color: #969BA3;">{{ userinfo.schoolName }}</span>
      </div>
      <div @click="exitLogin" class="Blo">
        <div style="display: flex;align-items: center;gap: 10px;">
          <img src="../../../assets/images/appStoreCopy/logOut.svg" alt="" />
          退出登录
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { loginOut } from '@/api/user'

export default {
  data() {
    return {}
  },
  computed: {
    ...mapGetters(['userinfo'])
  },
  methods: {
    backPage() {
      this.$router.push('/appStoreCopy')
    },
    // 退出登录
    exitLogin() {
      this.$dialog({
        message: '是否现在退出登录？你将回到登录界面',
        showCancelButton: true,
        beforeClose: (action, done) => {
          if (action === 'confirm') {
            loginOut()
              .then(res => {
                this.$toast({
                  message: '退出成功',
                  type: 'success'
                })
                this.$store.dispatch('user/logout')
                window.location.reload()
                done()
              })
              .catch(err => {
                console.error(err)
                done()
              })
          } else {
            // 拦截取消操作
            done()
          }
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.appStore {
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  // padding: 5px;
  background-color: #f9f8f8;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.topC {
  display: flex;
  justify-content: center;
  width: 100%;
  align-items: center;
  height: 50px;
  padding: 0px 12px;
  box-sizing: border-box;
  position: relative;
  font-family: PingFang HK;
  font-weight: 600;
  font-size: 15px;
  line-height: 20px;
  flex-shrink: 0;
  img {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translate(0, -50%);
    width: 23px;
  }
}
.infoCon {
  margin-top: 35px;
  padding: 15px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: PingFang HK;
  font-weight: 400;
  font-size: 14px;

  .Blo {
    display: flex;
    justify-content: space-between;
    background: #fff;
    align-items: center;
    padding: 15px 20px;
    border-radius: 10px;
  }
}
</style>
