<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="style">
        <el-col :span="24" class="top">
          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
        </el-col>
        <el-col :span="24" class="main">
          <el-col :span="24" class="message">
            <messageInfo :info="info" :teainfo="teainfo" :jiaoshiinfo="jiaoshiinfo"></messageInfo>
          </el-col>
          <el-col :span="24" class="clickBtn">
            <clickBtn></clickBtn>
          </el-col>
        </el-col>
        <el-col :span="24" class="foot">
          <footInfo></footInfo>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import NavBar from '@/layout/common/topInfo.vue';
import footInfo from '@/layout/common/footInfo.vue';
import messageInfo from '@/layout/user/messageInfo.vue';
import clickBtn from '@/layout/user/clickBtn.vue';
import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapDirectors } = createNamespacedHelpers('director');
const { mapActions: mapStudent } = createNamespacedHelpers('student');
const { mapActions: mapTeacher } = createNamespacedHelpers('teacher');
const { mapActions: mapDept } = createNamespacedHelpers('dept');

export default {
  name: 'index',
  props: {},
  components: {
    NavBar, //头部导航
    footInfo, //底部导航
    messageInfo, //个人信息
    clickBtn, //功能按钮
  },
  data: () => ({
    info: {},
    teainfo: {},
    jiaoshiinfo: {},
    title: '',
    isleftarrow: '',
    navShow: true,
  }),
  created() {
    this.searchSite();
  },
  computed: {
    ...mapState(['user']),
  },
  mounted() {
    this.title = this.$route.meta.title;
    this.isleftarrow = this.$route.meta.isleftarrow;
  },
  watch: {
    $route(to, from) {
      this.title = to.meta.title;
      this.isleftarrow = to.meta.isleftarrow;
    },
  },
  methods: {
    ...mapDirectors({ directorQuery: 'query', directorFetch: 'fetch' }),
    ...mapStudent({ studentQuery: 'query', studentFetch: 'fetch' }),
    ...mapTeacher({ teacherlist: 'query', teacherfetch: 'fetch' }),
    ...mapDept({ deptFetch: 'fetch' }),
    // 查询登录用户信息
    async searchSite() {
      // 1:班主任，4：学生
      const res = await this.studentFetch(this.user.userid);
      this.$set(this, `info`, res.data);
    },
  },
};
</script>

<style lang="less" scoped>
.style {
  width: 100%;
  min-height: 667px;
  position: relative;
  background-color: #f9fafc;
}
.top {
  height: 46px;
  overflow: hidden;
}
.main {
  min-height: 570px;
}
.foot {
  height: 90px;
  overflow: hidden;
}
</style>
