<template>
  <div class="main">
    <!-- 搜索 -->
    <search-bar
      readonly
      @click.native="$router.push({ name: 'search' })"
    ></search-bar>
    <!-- banner -->
    <div class="banner"><img src="img/home_banner.png" /></div>
    <!-- 导航 -->
    <div class="nav">
      <ul class="nav-list">
        <li
          class="nav-item"
          v-for="(item, index) in navList"
          :key="index"
          @click="handleNavClick(item)"
        >
          <div class="pic"><img :src="item.url" /></div>
          <div class="title">{{ item.title }}</div>
        </li>
      </ul>
    </div>
    <!-- 排行榜 -->
    <div class="top-bar">
      <ul class="top-bar-list">
        <li
          class="top-bar-item top-bar-item__group"
          @click="$router.push({ name: 'group' })"
        >
          组织排行榜
        </li>
        <li
          class="top-bar-item top-bar-item__activity"
          @click="$router.push({ name: 'activity' })"
        >
          活动热度榜
        </li>
      </ul>
    </div>
    <card title="最新活动">
      <activity-list :params="{ newest: 1 }"></activity-list>
    </card>
    <tab-bar></tab-bar>
  </div>
</template>

<script>
// components
import SearchBar from '@/components/SearchBar'
import TabBar from '@/components/TabBar'
import Card from '@/components/Card'
import ActivityList from '@/components/ActivityList'
export default {
  name: 'HomeIndex',
  components: { SearchBar, TabBar, Card, ActivityList },
  data() {
    return {
      navList: [
        { url: 'img/home_nav_01.png', title: '公益行', type: 1 },
        { url: 'img/home_nav_02.png', title: '去游学', type: 2 },
        { url: 'img/home_nav_03.png', title: '直播课', type: 3 },
        // { url: 'img/home_nav_04.png', title: '找工作', type: 4 },
        { url: 'img/home_nav_04.png', title: '运动家', type: 5 }
      ]
    }
  },
  methods: {
    handleNavClick({ type }) {
      this.$router.push({ name: 'activity', query: { type } })
    }
  }
}
</script>

<style lang="scss">
.banner {
  margin: 10px 0;
  img {
    width: 100%;
  }
}
.nav {
  padding: 10px 0;
}
.nav-list {
  display: flex;
  justify-content: space-between;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  .pic {
    width: 40px;
    height: 40px;
    img {
      width: 100%;
    }
  }
  .title {
    margin-top: 4px;
    color: #666;
  }
}
.top-bar {
  padding: 20px 0;
}
.top-bar-list {
  display: flex;
  justify-content: space-between;
}
.top-bar-item {
  width: 42%;
  height: 40px;
  font-size: 14px;
  font-weight: 600;
  line-height: 40px;
  color: #fff;
  text-align: center;
  border-radius: 40px;
  cursor: pointer;
}
.top-bar-item__group {
  background: linear-gradient(
    180deg,
    rgba(255, 201, 44, 1) 0%,
    rgba(255, 116, 42, 1) 100%
  );
  box-shadow: 0px 5px 20px 0px rgba(253, 3, 20, 0.3);
}
.top-bar-item__activity {
  background: linear-gradient(
    180deg,
    rgba(2, 236, 228, 1) 0%,
    rgba(18, 186, 244, 1) 100%
  );
  box-shadow: 0px 5px 20px 0px rgba(17, 187, 243, 0.3);
}
</style>
