<template>
  <div class="user-box" :class="{ 'mobile-user': isMobile }">
    <div class="title">Basic information</div>
    <div class="formBox">
      <div class="item">
        <div class="label">Nickname：</div>
        <div class="val">Linda</div>
      </div>
      <div class="item">
        <div class="label">Mobile phone number：</div>
        <div class="val">18525462514</div>
        <span class="iconfont icon-sousuo" @click="handleEdit('info')"></span>
      </div>
      <div class="item">
        <div class="label">Change password：</div>
        <!-- <div class="val"></div> -->
        <span class="iconfont icon-sousuo" @click="handleEdit('password')"></span>
      </div>
      <div class="item">
        <div class="label">Company name：</div>
        <div class="val">Wuhan Baijian Fanglue Information Consulting Co., LTD</div>
        <span class="iconfont icon-sousuo" @click="handleEdit('info')"></span>
      </div>
      <div class="item">
        <div class="label">Company position：</div>
        <div class="val">Sales Manager</div>
        <span class="iconfont icon-sousuo" @click="handleEdit('info')"></span>
      </div>
      <div class="item">
        <div class="label">Email address：</div>
        <div class="val">12454871456@163com</div>
        <span class="iconfont icon-sousuo" @click="handleEdit('info')"></span>
      </div>
      <div class="item">
        <div class="label">Contact number：</div>
        <div class="val">13512458745</div>
        <span class="iconfont icon-sousuo" @click="handleEdit('info')"></span>
      </div>
    </div>
  </div>
  <n-modal :show="editVisible" :title="editTitle" :showIcon="false" :close-on-esc="false" :mask-closable="false" @esc="editVisible = false" @mask-click="editVisible = false" @close="editVisible = false" class="modalCls" :class="{ 'login-dialog': isMobile }">
    <updatePwd v-if="editType == 'password'" @closeSginDialog="closeSginDialog"></updatePwd>
    <updateInfo :info="user" v-if="editType == 'info'" @closeSginDialog="closeSginDialog"></updateInfo>
  </n-modal>
</template>

<script lang="ts" setup>
import { ref, reactive, onMounted } from "vue";
import { createDiscreteApi } from "naive-ui";
import { set } from "~/node_modules/nuxt/dist/app/compat/capi";
import updateInfo from "./update-info.vue";
import updatePwd from "./updatePwd.vue";
import { useI18n } from "#imports";
const message = createDiscreteApi(["message"]);
const { t } = useI18n();
const props = defineProps({
  isMobile: {
    type: Boolean,
    default: false,
  },
});

const user = ref({});
const editVisible = ref(false);
const editTitle = ref(t("myInfo.modify"));
const editType = ref("password");

const getUser = async () => {
  let { code, data } = await getUser_Api();
  if (code === 200) {
    user.value = data;
  }
};

const handleEdit = (type: string) => {
  editType.value = type;
  editVisible.value = true;
  if (type == "password") {
    editTitle.value = t("myInfo.password");
  } else {
    editTitle.value = t("reportPop.title");
  }
};

const closeSginDialog = () => {
  editVisible.value = false;
  editType.value = "";
  getUser();
};
getUser();
</script>

<style lang="scss" scoped>
@import "~/assets/css/tool.scss";
.user-box {
  height: 100%;
  .title {
    font-size: 24px;
    font-family: Arial, Arial-Bold;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 44px;
    padding-bottom: 7px;
    border-bottom: 1px solid #e6e6e6;
  }
  .formBox {
    padding-bottom: 150px;
    .item {
      display: flex;
      align-items: center;
      border-bottom: 1px solid #f5f5f5;
      margin-bottom: 10px;
      .label {
        font-size: 18px;
        font-family: Arial, Arial-Regular;
        color: #666666;
        line-height: 63px;
      }
      .val {
        font-size: 18px;
        font-family: Arial, Arial-Regular;
        color: #1a1a1a;
        line-height: 63px;
      }
      .iconfont {
        color: #00b0fd;
        display: inline-block;
        margin-left: 20px;
        font-size: 18px;
        cursor: pointer;
      }
    }
  }
}
.modalCls {
  width: var(--size-720) !important;
}

@include responseTo("phone") {
  .user-box {
    .formBox {
      padding-bottom: 30px;
      margin-top: 15px;
      .item {
        align-items: baseline;
        border-bottom: 1px solid #f5f5f5;
        margin-bottom: 10px;
        .label {
          font-size: 14px;
          font-family: Arial, Arial-Regular;
          color: #666666;
          line-height: 30px;
          flex-shrink: 0;
          padding-bottom: 10px;
        }
        .val {
          font-size: 14px;
          font-family: Arial, Arial-Regular;
          color: #1a1a1a;
          line-height: 30px;
          padding-bottom: 10px;
        }
        .iconfont {
          color: #00b0fd;
          display: inline-block;
          margin-left: 20px;
          font-size: 14px;
          cursor: pointer;
        }
      }
    }
  }
}
</style>
