<template>
  <div>
    <div class="banner">
      <div v-if="roadList && roadList.length">
        <div v-for="(item, index) in list" :key="index" class="roadList">
          <el-popover
            title="我的项目"
            trigger="click"
            popper-class="popover"
            :placement="item.position"
            v-model="item.isShow"
            visible-arrow="true"
            @show="handleShow(item)"
          >
            <div>
              <!-- 我的项目 -->
              <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="(it, indexItem) in item.checkList" :key="it.name" class="project_name">{{ it.name }}</div>
            </div>
            <div slot="reference" class="roadList_con">
              <img :src="item.icon" alt="" />
              <div class="title">{{ item.title }}</div>
            </div>
          </el-popover>
        </div>
      </div>
      <div class="homeList" v-if="homeList && homeList.length">
        <div class="homeList_con" v-for="(itemRoad, index) in homeList" :key="index">
          <el-popover trigger="click" 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="homeList_con_item">
              <img :src="itemRoad.icon" alt="" />
              <div class="title">{{ itemRoad.title }}</div>
            </div>
          </el-popover>
        </div>
      </div>
    </div>
    <div class="content">
      <ProjectCard
        title="在线国际学位"
        :list="internationalDegreeProjectList"
        baseUrl="/internationalDegree"
      ></ProjectCard>
      <ProjectCard title="留学中学" :list="studyAbroadProjectList" baseUrl="/studyAbroad"></ProjectCard>
    </div>
  </div>
</template>

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

export default {
  components: { AppLink, ProjectCard },
  computed: {
    learning() {
      return this.$store.state.user.learning_info.filter(item => item.status === '1')
    },
    list() {
      if (this.learning.length) {
        this.roadList.forEach(item => {
          console.log(item, '000')
          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 {
      roadList: roadMapList,
      homeList: homeList,
      internationalDegreeProjectList: [
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/h5/lifeLearning/img1.png',
          href: 'https://kelley.ezijing.com/'
        },
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/h5/lifeLearning/img2.png',
          href: 'https://ciis.ezijing.com/'
        },
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/h5/lifeLearning/img3.png',
          href: 'https://marywood.ezijing.com/'
        }
      ],
      // 热门专业
      studyAbroadProjectList: [
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/h5/lifeLearning/img4.png',
          href: 'https://cbu-plus.ezijing.com/'
        },
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/h5/lifeLearning/img5.png',
          href: 'https://marywood-plus.ezijing.com/'
        },
        {
          imgUrl: 'https://webapp-pub.ezijing.com/www/h5/lifeLearning/img6.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: 0.1rem;
  padding: 0.13rem 0.11rem 0.2rem 0.13rem;

  .el-popover__title {
    font-weight: 400;
    color: #ffffff;
    font-size: 0.09rem;
  }
  .project_name {
    font-size: 0.11rem;
    font-weight: bold;
    color: #ffffff;
    cursor: pointer;
  }
  .line {
    width: 90%;
    border: 1px dashed #ccc;
    margin: 0.1rem 0 0.1rem 0;
  }
}
.banner {
  width: 100%;
  height: 6.31rem;
  background: url(https://webapp-pub.oss-cn-beijing.aliyuncs.com/www/h5/lifeLearning/banner.png);
  background-size: 100% 100%;
  position: relative;
  .roadList {
    height: 0.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    position: absolute;
    .roadList_con {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      cursor: pointer;
    }
    .title {
      font-size: 0.14rem;
      font-weight: 500;
      color: #ffffff;
    }
  }
  .roadList:nth-child(1) {
    position: absolute;
    z-index: 100000;
    top: 0.35rem;
    left: 50%;
    transform: translateX(-50%);
    img {
      width: 0.2rem;
    }
  }
  .roadList:nth-child(2) {
    position: absolute;
    z-index: 100000;
    top: 1.43rem;
    left: 50%;
    transform: translateX(-50%);
    img {
      width: 0.21rem;
    }
  }
  .roadList:nth-child(3) {
    position: absolute;
    z-index: 100000;
    top: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    img {
      width: 0.32rem;
    }
  }
  .roadList:nth-child(4) {
    position: absolute;
    z-index: 100000;
    top: 3.57rem;
    left: 50%;
    transform: translateX(-50%);

    img {
      width: 0.25rem;
    }
  }
  .roadList:nth-child(5) {
    position: absolute;
    z-index: 100000;
    top: 4.44rem;
    left: 50%;
    transform: translateX(-50%);

    img {
      width: 0.19rem;
    }
  }
  .homeList {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: 5.35rem;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;

    .homeList_con {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      .project_name {
        font-size: 0.11rem;
        font-weight: bold;
        color: #ffffff;
        cursor: pointer;
      }
      .homeList_con_item {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        cursor: pointer;

        .title {
          font-size: 0.14rem;
          font-weight: 500;
          color: #ffffff;
        }
        img {
          width: 0.4rem;
          height: 100%;
        }
      }
    }
  }
}
.content {
  padding: 0.28rem 0.21rem 0 0.21rem;
  .content_top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .top_title {
      font-size: 0.17rem;
      font-weight: bold;
      color: #424242;
    }
    .top_more {
      font-size: 0.1rem;
      font-weight: 300;
      color: #9b9b9b;
    }
  }
  .content_bottom {
    width: 100%;
    img {
      width: 100%;
      height: 100%;
    }
  }
}
.content1 {
  margin-bottom: 0.28rem;
}
</style>
