<template>
  <HeaderNav headerText="个人中心"></HeaderNav>
  <div class="user-center">
    <div class="user-info">
      <div class="info-left">
        <img src="../../assets/img/index/user/default-head.png" alt="" />
        <div class="left-message">
          <div class="name pf500 fs18 fc061237">用户昵称</div>
        </div>
      </div>
      <div class="info-right pf400 fs12 fcFFFFFF" @click="updateInfoFlag = true">
        编辑
      </div>
    </div>
    <div class="notifi-index">
      <div class="notifi-classifi">
        <div class="pf600 fs18 fc121212" @click="messageChange('userInfo')">个人资料</div>
        <div class="sys-notifi pf600 fs14 fcA8A8A8" @click="messageChange('safetySet')">
          安全设置
        </div>
        <div class="sys-notifi pf600 fs14 fcA8A8A8" @click="messageChange('hobbySet')">
          偏好设置
        </div>
      </div>
      <component :is="currentComponent" />
    </div>
  </div>
  <UpdateInfo v-show="updateInfoFlag" @updateInfoClose="updateInfoClose"></UpdateInfo>
</template>
<script setup>
  import HeaderNav from "./components/HeaderNav.vue";
  import HobbySet from "./user/HobbySet.vue";
  import SafetySet from "./user/SafetySet.vue";
  import UserInfo from "./user/UserInfo.vue";
  import UpdateInfo from "./dialog/UpdateInfo.vue";
  import { ref, computed } from "vue";

  const updateInfoFlag = ref(false);
  const updateInfoClose = () => {
    updateInfoFlag.value = false;
  };

  const current = ref("userInfo");
  const componentsMap = {
    hobbySet: HobbySet,
    safetySet: SafetySet,
    userInfo: UserInfo,
  };
  const currentComponent = computed(() => componentsMap[current.value]);

  const messageChange = (key) => {
    current.value = key;
  };
</script>
<style lang="less" scoped>
  .user-center {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    width: 100%;

    .user-info {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      margin-top: 48px;
      width: 345px;
      height: 56px;

      .info-left {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        height: 56px;

        img {
          width: 56px;
          height: 56px;
        }

        .left-message {
          display: flex;
          flex-direction: column;
          justify-content: center;
          margin-left: 16px;
          height: 56px;
        }
      }

      .info-right {
        width: 60px;
        height: 24px;
        line-height: 24px;
        text-align: center;
        background: #df384c;
        border-radius: 5px;
      }
    }

    .notifi-classifi {
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: flex-end;
      margin-top: 15px;
      width: 349px;
      height: 24px;

      .sys-notifi {
        margin-left: 43px;
      }
    }
  }
</style>
