<template>
  <div class="home-main">
    <Row>
      <Col span="8">
        <Card>
          <Row type="flex" class="user-infor">
            <Col span="8">
              <Row
                class-name="made-child-con-middle"
                type="flex"
                align="middle"
              >
                <img class="avator-img" src="@/assets/images/header.jpg" />
              </Row>
            </Col>
            <Col span="16" style="padding-left: 6px">
              <Row
                class-name="made-child-con-middle"
                type="flex"
                align="middle"
              >
                <div>
                  <b class="card-user-infor-name">{{
                    userLog.user.userName
                  }}</b>
                  <p>
                    {{ userLog && userLog.user ? userLog.user.role : "" }}
                  </p>
                  <p>
                    {{
                      userLog && userLog.user.basicSchool
                        ? userLog.user.basicSchool.name
                        : ""
                    }}
                  </p>
                </div>
              </Row>
            </Col>
          </Row>
          <div class="line-gray"></div>
          <Row class="margin-top-8">
            <Col span="8"><p class="notwrap">上次登录时间:</p></Col>
            <Col span="16" class="padding-left-8">{{
              userLog.loginTime | dateFormat
            }}</Col>
          </Row>
        </Card>
      </Col>
    </Row>
  </div>
</template>

<script>
import { axios } from "../../libs/http";

export default {
  name: "home",
  data() {
    return {
      userLog: {
        user: {
          userName: "",
          role: "",
        },
        loginTime: "",
      },
    };
  },
  computed: {
    avatorPath() {
      return localStorage.avatorImgPath;
    },
  },
  methods: {
    queryLastTimeLogUser() {
      axios.post("/system/user/userLog").then((response) => {
        let result = response.data;
        this.userLog = result.data;
      });
    },
  },
  mounted() {
    this.queryLastTimeLogUser();
  },
};
</script>
