明梦爽
2021-11-18 1714ea49fbbeb8bcb9f9f896ffb873362e8cdca8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<template>
  <el-container class="home-container">
    <!-- 主页头部 -->
    <el-header>
      <div>
        <img src="../assets/xiaohui4.png" alt="" />
      </div>
      <div>
        <img src="../assets/bg.png" alt="">
      </div>
    </el-header>
    <!-- 主页导航栏 -->
    <el-row>
      <el-menu
        mode="horizontal"
        background-color="rgb(64, 112, 186)"
        text-color="white"
        class="menu"
        active-text-color="#000000"
        :default-active="activeIndex"
        @select="handleSelect"
      >
        <el-menu-item
          :key="index"
          v-for="(item, index) in menuList"
          :index="(item.id).toString()"
        >
          {{ item.contypeName }}
        </el-menu-item>
      </el-menu>
    </el-row>
    <el-container>
      <!-- 更变的内容区域 -->
      <el-main class="main">
        <router-view class="box"></router-view>
      </el-main>
    </el-container>
    <el-footer>@平顶山学院科学技术协会</el-footer>
  </el-container>
</template>
 
<script>
import {getNavList} from '../api/api'
export default {
  name: '',
  data() {
    return {
      activeIndex: '1',
      menuList: [],
    }
  },
  created() {
    this.getNavArr();
  },
  mounted() {},
  watch: {},
  methods: {
    //获取导航栏
    getNavArr(){
      const data ={};
      //.then() 主要用于一个函数用到另一个函数的返回值
      getNavList(data).then(res => {
        console.log('res', res)
        if(res.code == 200){
          this.menuList = res.data
        }
      }).catch(err => {
        console.log('err', err)
      })
    },
    formatterTitle(t){
      switch(t){
        case '1':
          return 'index'
        case '2':
          return 'introduce'
        case '3':
          return 'zhengce'
        case '4':
          return 'keXieXiangMu'
        case '5':
          return 'xueShuJiaoLiu'
        case '6':
          return 'banShiZhiNan'
        case '7':
          return 'kePu'
        case '8':
          return 'xueXiaoShouYe'
        case '9':
          return 'telephone'
      }
    },
    handleSelect(key, keyPath) {
      if (key == '8') {
        window.open('https://www.pdsu.edu.cn/#')
      } else {
        this.$router.push({
          path: '/home/' + this.formatterTitle(key),
          query: {
            title: this.formatterTitle(key),
            id:key
          }
        })
      }
    }
  }
}
</script>
 
<style lang="less" scoped>
.home-container {
  height: 100%;
}
.el-header {
  background-color: rgb(1, 72, 153);
}
.el-header {
  height: 120px !important;
  padding: 0 40px;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.el-menu {
  .el-menu-item {
    width: 150px;
    font-size: 15px;
    text-align: center;
  }
}
.menu {
  display: flex;
  justify-content: space-between;
}
.el-footer {
  background-color: rgb(85, 81, 82);
}
.main {
  padding: 20px 5px;
}
.el-footer {
  font-size: 15px;
  color: white;
  text-align: center;
  line-height: 60px;
}
.box {
  width: 1200px;
  margin: 0 auto;
}
</style>