<template>
  <div>
    <div class="banner">
      <div v-for="(item, index) in list" :key="index" class="banner_roadList">
        <el-popover
          :title="item.project_name"
          width="340"
          trigger="hover"
          popper-class="popover"
          :placement="item.position"
          v-model="item.isShow"
          visible-arrow="true"
          @show="handleShow(item)"
        >
          <div v-for="(it, indexItem) in item.projectList" :key="indexItem" class="project_name">
            <AppLink :data="it">
              {{ it.name }}
            </AppLink>
          </div>
          <div class="line"></div>
          <div class="el-popover__title">未来可选目标:</div>
          <div v-for="(itTwo, index) in item.checkList" :key="itTwo.name" class="project_name">
            <AppLink :data="itTwo">
              {{ itTwo.name }}
            </AppLink>
          </div>

          <div slot="reference" class="banner_roadList_con">
            <img :src="item.icon" alt="" />
            <div class="item_title">{{ item.title }}</div>
          </div>
        </el-popover>
      </div>
      <div class="banner_homeList">
        <div v-for="(itemRoad, indexRoad) in homeList" :key="indexRoad">
          <el-popover trigger="hover" popper-class="popover" :placement="itemRoad.position" v-model="itemRoad.isShow">
            <div>
              <div v-for="(it, indexItem) in itemRoad.itemList" :key="indexItem" class="project_name">
                <AppLink :data="it">
                  {{ it.name }}
                </AppLink>
              </div>
            </div>
            <div slot="reference" class="banner_homeList_con">
              <img :src="itemRoad.icon" alt="" />
              <div class="item_title">{{ itemRoad.title }}</div>
            </div>
          </el-popover>
        </div>
      </div>
    </div>
    <div class="w1200">
      <ProjectCard
        title="在线国际学位"
        :list="internationalDegreeProjectList"
        baseUrl="/internationalDegree"
      ></ProjectCard>
      <ProjectCard title="留学中学" :list="studyAbroadProjectList" baseUrl="/studyAbroad"></ProjectCard>
      {{ $store.state.user }}
    </div>
  </div>
</template>

<script>
import { roadMapList, homeList } from './roadMap'
import ProjectCard from '@/components/ProjectCard.vue'
import AppLink from '@/components/Link.vue'

export default {
  components: { ProjectCard, AppLink },
  computed: {
    learning() {
      return this.$store.state.user.learning_info.filter(item => item.status === '1')
    },
    list() {
      if (this.learningInfo.length) {
        this.roadList.forEach(item => {
          if (item.projectList.find(it => it.tenant === this.learning[0].tenant)) {
            item.isShow = true
            item.project_name = '我的项目:'
            item.projectList = item.projectList.filter(it => it.tenant === this.learning[0].tenant)
          }
        })
        return this.roadList
      } else {
        return this.roadList
      }
    }
  },
  data() {
    return {
      learningInfo: [],
      roadList: roadMapList,
      homeList: homeList,
      // 热门专业
      internationalDegreeProjectList: [
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/pc/internationalDegree/project_kelley.png',
          href: 'https://kelley.ezijing.com/'
        },
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/pc/internationalDegree/project_ciis.png',
          href: 'https://ciis.ezijing.com/'
        },
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/pc/internationalDegree/project_marywood.png',
          href: 'https://marywood.ezijing.com/'
        }
      ],
      // 热门专业
      studyAbroadProjectList: [
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/pc/studyAbroad/project_cbu.png',
          href: 'https://cbu-plus.ezijing.com/'
        },
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/pc/studyAbroad/project_marywood_plus_1.png',
          href: 'https://marywood-plus.ezijing.com/'
        },
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/pc/studyAbroad/project_sbu.png',
          href: 'https://sbu-plus.ezijing.com/'
        }
      ]
    }
  },
  methods: {
    handleShow(val) {
      this.list.map(item => {
        if (item.title !== val.title) {
          item.isShow = false
        }
      })
    }
  }
}
</script>

<style lang="scss">
.el-popover.popover {
  background: rgba(255, 255, 255, 0.39);
  border-radius: 20px;
  padding: 26px 22px 40px 27px;
  .el-popover__title {
    font-weight: 400;
    color: #ffffff;
    font-size: 18px;
  }
  .project_name {
    font-size: 22px;
    font-weight: bold;
    color: #ffffff;
    cursor: pointer;
  }
  .project_name:hover {
    text-shadow: 2px 2px 5px rgb(143, 141, 141);
  }
  .line {
    width: 281px;
    border: 1px dashed #ccc;
    margin: 20px 0 20px 0;
  }
}

.banner {
  width: 100%;
  min-width: 1200px;
  background: url(https://webapp-pub.oss-cn-beijing.aliyuncs.com/www/pc/lifeLearning/banner.jpg);
  background-size: 100% 100%;
  height: 650px;
  position: relative;
  .banner_roadList {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;

    .banner_roadList_con {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      cursor: pointer;
      .item_title {
        font-size: 20px;
        font-weight: bold;
        color: #ffffff;
      }
    }
  }
  .banner_roadList:nth-child(1) {
    position: absolute;
    top: 325px;
    left: 21.5%;
  }
  .banner_roadList:nth-child(2) {
    position: absolute;
    top: 270px;
    left: 40%;
  }
  .banner_roadList:nth-child(3) {
    position: absolute;
    top: 250px;
    left: 47%;
  }
  .banner_roadList:nth-child(4) {
    position: absolute;
    top: 140px;
    left: 58%;
  }
  .banner_roadList:nth-child(5) {
    position: absolute;
    top: 105px;
    left: 68%;
  }
  .banner_homeList {
    width: 50%;
    position: absolute;
    left: 50%;
    bottom: 52px;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: space-around;
    align-items: center;
    .banner_homeList_con {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;

      .item_title {
        font-size: 20px;
        font-weight: bold;
        color: #ffffff;
      }
    }
  }
}
.w1200 {
  width: 1200px;
  margin: 84px auto;
}
</style>
