Index.vue 9.1 KB
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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
<template>
  <!-- 首页 -->
  <div>
    <Top :active="active"></Top>
    <!-- 主体 -->
    <div class="home_wrap">
      <!-- banner -->
      <div class="banner">
        <el-carousel :interval="3000" arrow="never" loop height="590px">
          <el-carousel-item v-for="item in list" :key="item.index">
            <img :src="item.image" alt @click="toUrl(item)" />
          </el-carousel-item>
        </el-carousel>
      </div>
      <!-- 使用流程 -->
      <div class="use_process">
        <div class="process_box">
          <!-- 标题 -->
          <div class="home_title">
            <h2>使用流程</h2>
            <p class="title_en">Use process</p>
          </div>
          <!-- 流程图 -->
          <div class="process_img layout justify_center align_center">
            <div class="process_img_l">
              <img src="@/assets/img/process_l.png" alt />
            </div>
            <div class="process_img_r">
              <img src="@/assets/img/process_r.png" alt />
            </div>
          </div>
        </div>
      </div>
      <!-- 教育新闻 -->
      <div class="educational_news">
        <div class="news_box">
          <!-- 标题 -->
          <div class="home_title clearfix">
            <h2>教育新闻</h2>
            <p class="title_en">Education news</p>
          </div>
          <!-- 详细新闻 -->
          <div class="news_det layout justify_center align_center flex_diection clearfix">
            <!-- 单个消息 -->
            <div
              class="news_single layout align_center justify"
              v-for="(item,index) in newsList"
              :key="index"
            >
              <!-- 日期 -->
              <div class="news_date" :class="{choice_date:index == 0}">
                <i class="det_date">{{item.date}}</i>
                <br />
                {{item.month}}
              </div>
              <!-- 消息 -->
              <div class="news_infor clearfix" @click="toNewsList(item)">
                <p
                  class="news_info_con news_info_title"
                  :class="{choice_news:item.newsId == 1,choice_content:index == 0}"
                >{{item.name}}</p>
                <p class="news_info_con news_info_msg">{{item.description}}</p>
              </div>
            </div>
            <!-- 全部按钮 -->
            <div class="check_all" @click="allNews()">查看全部</div>
          </div>
        </div>
      </div>
      <!-- 名校展示 -->
      <div class="school_show">
        <div class="show_box clearfix">
          <!-- 标题 -->
          <div class="home_title">
            <h2>名校展示</h2>
            <p class="title_en">Exhibition of elite schools</p>
          </div>
          <!-- 学校 -->
          <div class="school_msg layout flex_row clearfix">
            <dl class="school_single clearfix" v-for="item in schooList" :key="item.id">
              <dt class="school_dt" @mouseenter="showDetail(item)" @mouseleave="closeDetail()">
                <img :src="item.images" alt />
                <div class="school_detail_show" v-show="isSchool == item.id">
                  <div class="to_university_detail" @click="toUniversity(item)">查看详情 ></div>
                </div>
              </dt>
              <dd class="school_dd clearfix">
                <h3>{{item.name}}</h3>
                <!-- 学校简介 -->
                <div class="school_profile">{{item.description.replace(/\s*/g,"")}}</div>
              </dd>
            </dl>
          </div>
          <div class="check_all" @click="allUniversity()">查看全部</div>
        </div>
      </div>
    </div>
    <Bottom></Bottom>
  </div>
</template>
<script>
import Top from "../common/Top";
import Bottom from "../common/Bottom2";
import { post } from "@/api/http";
export default {
  data() {
    return {
      active: 0,
      //   轮播图
      list: [],
      // 新闻
      newsList: [],
      schooList: [],
      newsId: "",
      url: "",
      isSchool: -1
    };
  },
  methods: {
    showDetail(item) {
      this.isSchool = item.id;
    },
    closeDetail() {
      this.isSchool = "";
    },
    // 轮播图
    getCarouselList() {
      let url = "/api/index/getCarouselList/";
      post(url).then(res => {
        this.list = res.carousel_list;
      });
    },
    // 轮播图链接跳转
    toUrl(item) {
      this.url = item.href;
      if (this.url) {
        window.open(this.url, "_blank");
      }
    },
    // 教育新闻
    getNewsList() {
      let url = "/api/index/getNewsList/";
      post(url).then(res => {
        this.newsList = res.news_list;
        this.newsId = this.newsList[0].id;
      });
    },
    toNewsList(item) {
      this.$router.push({ path: "/NewsDetail", query: { id: item.id } });
    },
    // 全部新闻
    allNews() {
      if(this.newsList.length>0){
        this.$router.push({ path: "/NewsDetail", query: { id: this.newsId } });
      }
    },
    //名校展示
    getFamousList() {
      let url = "/api/index/getFamousList/";
      post(url).then(res => {
        this.schooList = res.famous_list;
      });
    },
    // 全部高校
    allUniversity() {
      this.$router.push({
        path: "/University"
      });
    },
    // 高校详情
    toUniversity(item) {
      this.$router.push({
        path: "/UniversityIntroduc",
        query: { id: item.id }
      });
    }
  },
  components: {
    Top,
    Bottom
  },
  mounted() {
    let test = this.$route.query.test;
    if (localStorage.getItem("token")) {
      this.getCarouselList();
      this.getNewsList();
      this.getFamousList();
    }else{
      this.$router.push({ path: "/login/"+test });
    }
  }
};
</script>
<style scoped>
.home_wrap {
  width: 100%;
  background-color: #f2f5fa;
}

/* 标题 */
.home_title {
  padding-top: 44px;
}

.home_title h2 {
  font-size: 32px;
  color: #0d1e2e;
  line-height: 47px;
}

.title_en {
  font-size: 16px;
  color: #bdc4ce;
}

/* 查看全部按钮 */
.check_all {
  width: 230px;
  height: 50px;
  border: 1px solid #409eff;
  line-height: 50px;
  text-align: center;
  font-size: 18px;
  color: #409eff;
  border-radius: 3px;
  margin: 42px auto 50px;
}

/* banner */
.banner {
  width: 100%;
  height: 590px;
}

.banner img {
  width: 100%;
  height: 100%;
}

/* 使用流程 */
.use_process {
  width: 100%;
  background: #fff;
}

.process_box {
  width: 1200px;
  height: 549px;
  margin: 0 auto;
}

/* 流程图 */
.process_img {
  margin-top: 45px;
}

.process_img_l {
  margin-right: 88px;
  margin-top: 11px;
}

/* 教育新闻 */
.educational_news {
  width: 100%;
  background-color: #f2f5fa;
}

.news_box {
  width: 1200px;
  margin: 0 auto;
}

/* 详细新闻 */
.news_det {
  margin-top: 54px;
}

/* 日期 */
.news_date {
  width: 60px;
  height: 60px;
  background: #f44a5e;
  margin-right: 50px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  margin-top: -5px;
}

/* 当天日期 */
.det_date {
  font-size: 24px;
  display: inline-block;
  margin-top: 4px;
  font-weight: bold;
}

/* 单个消息 */
.news_single {
  margin-bottom: 12px;
}

.news_infor {
  width: 882px;
  height: 70px;
  border-bottom: 1px solid #bdc4ce;
}

/* 新闻内容 */
.news_info_con {
  width: 486px;
  margin-bottom: 5px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 新闻标题 */
.news_info_title {
  font-size: 16px;
  line-height: 21px;
  color: #34485e;
}
.news_single:hover .news_date {
  background-color: #409eff;
}
.news_single:hover .news_info_title {
  color: #409eff;
}
/* 新闻简介 */
.news_info_msg {
  font-size: 14px;
  color: #8c9198;
}

/* 选中 */
.choice_news {
  color: #409eff;
}
.choice_content {
  /* color: #409eff; */
}
/* 名校展示 */
.school_show {
  width: 100%;
  background-color: #fff;
}

.show_box {
  width: 1200px;
  margin: 0 auto;
}

.school_msg {
  margin-top: 80px;
}

/* 单个学校 */

.school_single {
  width: 259px;
  height: 345px;
  margin-right: 55px;
}

/* 学校图片 */
.school_dt {
  width: 259px;
  height: 210px;
  position: relative;
}
.school_detail_show {
  position: absolute;
  width: 259px;
  height: 210px;
  background: rgba(68, 137, 245, 0.5);
  top: 0;
  left: 0;
  line-height: 210px;
}
.to_university_detail {
  width: 113px;
  height: 34px;
  background: rgba(68, 137, 245, 1);
  border-radius: 3px;
  color: #fff;
  font-size: 14px;
  line-height: 34px;
  text-align: center;
  margin: 0 auto;
  display: inline-block;
}
.school_dt img {
  width: 100%;
  height: 100%;
  border-radius: 3px;
}

/* 学校简介 */
.school_dd {
  width: 259px;
  height: 135px;
}

.school_dd h3 {
  font-size: 16px;
  padding-top: 12px;
  color: #34485e;
  font-weight: bold;
}

.school_profile {
  background-color: #fff;
  font-size: 14px;
  color: #8c9198;
  text-align: left;
  width: 90%;
  height: 58px;
  margin: 5px auto;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  /*! autoprefixer: off */
  -webkit-box-orient: vertical; /*伸缩盒子的子元素排列:从上到下*/
  /* autoprefixer: on */
}

/* 划过时效果 */
.school_single:hover {
  box-shadow: 0px 4px 18px rgba(42, 42, 42, 0.06);
  transform: translateY(-37px);
  transition: all 0.5s ease;
}
</style>