ServiceList.vue 9.13 KB
/*
    两行:一行两个,
    下面:一行一个
 */
<template>
  <div class="tab_content abroad" :class="notab?'notab':''">
    <!-- <div class="tab_btn_box">
      <van-button class="tab_btn" :class="active==0?'active':''" @click="active=0">课程学习</van-button>
      <van-button class="tab_btn" :class="active==1?'active':''" @click="active=1">研学活动</van-button>
      <van-button class="tab_btn" :class="active==2?'active':''" @click="active=2">升学咨询</van-button>
    </div> -->
    <div class="padding_box">
      <template v-for="(item,index) in list">
        <div class="uni_item_mini" :key="index" @click="handleUniDetail(item)" v-if="index<=3">
          <div class="img_box">
            <img :src="item.coverUrl?item.coverUrl:defaultImg" alt="">
            <p class="time" v-if="item.startDate==item.endDate">活动时间:{{item.startDate}} {{item.week}}</p>
            <p class="time" v-else>活动时间:{{item.startDate}}-{{item.endDate}}</p>
            <div class="bottom" v-if="item.cityAddress||item.areaAddress">
              <span class="address">
                <van-icon name="location" /> {{item.cityAddress}}{{item.cityAddress&&item.areaAddress?'·':''}}{{item.areaAddress}}
              </span>
            </div>
          </div>
          <div class="content">
            <p class="title">{{item.course_name}}</p>
            <div class="tag_box">
              <template v-for="(tag,index2) in item.course_labels">
                <span class="tag" v-if="tag" :key="index2">{{tag}}</span>
              </template>
            </div>
            <div class="flex_box">
              <p class="price" v-if="item.showPrice>0"><span class="icon">¥</span>{{item.showPrice}}<span class="tint">起 </span><span class="limit">/限{{item.minPeopleCount}}人</span></p>
              <p class="price free" v-else>免费 <span class="limit">/限{{item.minPeopleCount}}人</span></p>
              <span class="count">
                <van-icon name="eye-o" /> {{item.read_count}}
              </span>
            </div>
          </div>
        </div>
      </template>
    </div>
    <div class="line" v-if="list.length>4"></div>
    <template v-for="(item,index) in list">
      <div class="uni_item" :key="index" @click="handleUniDetail(item)" v-if="index>3">
        <div class="img_box">
          <img :src="item.coverUrl?item.coverUrl:defaultImg" alt="">
          <div class="bottom">
            <span class="count">
              <van-icon name="eye-o" /> {{item.read_count}}
            </span>
          </div>
        </div>
        <div class="content">
          <div class="top">
            <p class="title">{{item.course_name}}</p>
            <p class="des">{{item.course_info}}</p>
          </div>
          <div class="bottom">
            <p class="price" v-if="item.showPrice>0"><span class="icon">¥</span>{{item.showPrice}}<span class="tint">起 </span><span class="limit">/限{{item.minPeopleCount}}人</span></p>
            <p class="price free" v-else>免费 <span class="limit">/限{{item.minPeopleCount}}人</span></p>
            <div class="tag_box">
              <template v-for="(tag,index2) in item.course_labels">
                <span class="tag" v-if="tag" :key="index2">{{tag}}</span>
              </template>
            </div>
            <p class="address" v-if="item.startDate==item.endDate">{{item.cityAddress}}{{item.cityAddress&&item.areaAddress?'·':''}}{{item.areaAddress}} {{item.startDate}} {{item.week}}</p>
            <p class="address" v-else>{{item.cityAddress}}{{item.cityAddress&&item.areaAddress?'·':''}}{{item.areaAddress}} {{item.startDate}}-{{item.endDate}}</p>
          </div>
        </div>
      </div>
    </template>
  </div>
</template>
<script>
export default {
  props: {
    list: {
      type: Array,
      default: []
    },
    notab: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      active: 0,
      defaultImg: require('@/assets/service/defCoure.jpg'),
    }
  },
  methods: {
    handleUniDetail (item) {
      this.$router.push({ name: 'ServiceAbroadDetail', query: { courseId: item.id} })
    },
  }
}
</script>
<style lang="scss" scoped>
.tab_content {
  height: calc(100vh - 140px - 196px);
  box-sizing: border-box;
  overflow: auto;
  &.notab {
    height: calc(100vh - 196px);
  }
}
.tab_btn_box {
  .tab_btn {
    width: 178px;
    height: 52px;
    border-radius: 16px;
    border: none;
    background: rgba(255, 255, 255, 0.36);
    color: #666666;
    padding: 0;
    margin-right: 16px;
    &.active {
      background: #ffffff;
      color: #4092ff;
    }
  }
}
.abroad {
  padding: 18px 0;
  .padding_box {
    padding: 0 28px;
    padding-bottom: 16px;
  }
  .uni_item_mini {
    position: relative;
    margin-top: 16px;
    display: inline-block;
    width: 336px;
    vertical-align: top;
    &:nth-of-type(2n-1) {
      margin-right: 22px;
      clear: both;
    }
    .img_box {
      position: relative;
      border-radius: 16px;
      overflow: hidden;
      img {
        width: 336px;
        height: 336px;
      }
      .time {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        line-height: 52px;
        font-size: 21px;
        font-weight: bold;
        background: rgba(0, 0, 0, 0.27);
        border-radius: 16px;
        color: #fff;
        text-align: center;
      }
      .bottom {
        position: absolute;
        bottom: 0;
        left: 0;
        color: #fff;
        height: 64px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        box-sizing: border-box;
        padding: 0 20px;
        background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5));
        .address {
          font-size: 24px;
        }
      }
    }
    .content {
      margin-top: 6px;
      .title {
        display: -webkit-box;
        font-size: 28px;
        -webkit-line-clamp: 2;
        text-overflow: ellipsis;
        overflow: hidden;
        -webkit-box-orient: vertical;
      }
      .address {
        font-size: 24px;
        margin-top: 8px;
      }
      .tag_box {
        padding-top: 6px;
        .tag {
          display: inline-block;
          margin-bottom: 10px;
          margin-right: 10px;
          color: #4092ff;
          font-size: 20px;
          border-radius: 4px;
          border: 2px solid #4092ff;
          padding: 0px 6px;
        }
      }
      .flex_box {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .count {
        font-size: 24px;
        color: #999;
      }
      .price {
        font-size: 34px;
        font-weight: bold;
        .icon {
          font-size: 24px;
        }
        .limit {
          font-size: 22px;
          font-weight: normal;
        }
        .tint {
          font-size: 22px;
          font-weight: normal;
          color:#909399
        }
      }
      .free {
        font-size: 28px;
      }
    }
  }
  .line {
    width: 100%;
    height: 16px;
    background: #f5f6fa;
  }
  .uni_item {
    position: relative;
    margin-top: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    width: 694px;
    margin-top: 24px;
    padding: 0 28px;
    .img_box {
      position: relative;
      border-radius: 16px;
      overflow: hidden;
      width: 274px;
      img {
        width: 274px;
        height: 274px;
      }
      .time {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        line-height: 52px;
        font-size: 20px;
        background: rgba(0, 0, 0, 0.27);
        border-radius: 16px;
        color: #fff;
        text-align: center;
      }
      .bottom {
        position: absolute;
        bottom: 0;
        left: 0;
        color: #fff;
        height: 64px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        box-sizing: border-box;
        padding: 0 20px;
        background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5));
        .address {
          font-size: 24px;
        }
        .count {
          font-size: 24px;
        }
      }
    }
    .content {
      width: 400px;
      height: 276px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .title {
        font-size: 28px;
      }
      .des {
        font-size: 24px;
        color: #999999;
        margin-top: 10px;
      }
      .address {
        font-size: 24px;
        margin-top: 10px;
      }
      .tag_box {
        .tag {
          display: inline-block;
          margin-top: 10px;
          margin-right: 10px;
          color: #4092ff;
          font-size: 20px;
          border-radius: 4px;
          border: 2px solid #4092ff;
          padding: 0px 6px;
        }
      }
      .price {
        font-size: 34px;
        font-weight: bold;
        margin-top: 12px;
        .icon {
          font-size: 24px;
        }
        .tint {
          font-size: 22px;
          font-weight: normal;
          color:#909399
        }
        .limit {
          font-size: 22px;
          font-weight: normal;
        }
      }
      .free {
        font-size: 28px;
      }
    }
  }
}
</style>