SearchResult.vue 6.59 KB
// 课程
<template>
  <div id="SearchResult">
    <van-tabs v-model="active">
      <van-tab title="基地"></van-tab>
      <van-tab title="课程"></van-tab>
      <van-tab title="资讯"></van-tab>
    </van-tabs>

    <van-list v-if="active == 0 && BaseData.length > 0">
      <BaseList :list="BaseData"></BaseList>
    </van-list>
    <van-empty v-if="active == 0 && BaseData.length == 0" :image="require('@/assets/empty.png')" description="暂无基地" />

    <van-list v-if="active == 1 && CourseData.length > 0">
      <ServiceListSecond :list="CourseData"></ServiceListSecond>
    </van-list>
    <van-empty v-if="active == 1 && CourseData.length == 0" :image="require('@/assets/empty.png')" description="暂无课程" />

    <van-list v-if="active == 2 && ArticleData.length > 0">
      <ArticleList :list="ArticleData"></ArticleList>
    </van-list>
    <van-empty v-if="active == 2 && ArticleData.length == 0" :image="require('@/assets/empty.png')" description="暂无资讯" />

    <van-icon name="back-top" class="backtop" @click="backTop" />
  </div>
</template>

<script>
import ServiceListSecond from '@/views/Service/component/ServiceListSecond.vue'
import BaseList from '@/views/Service/component/c_BaseList.vue'
import ArticleList from '@/views/Article/c_ArticleList.vue'
export default {
  data() {
    return {
      BaseData: [],
      CourseData: [],
      typeOption: [],
      ArticleData: [],
      active: 0,
    }
  },
  mounted() {
    let search = this.$route.query.search
    if (search) {
      this.getCourseData(search)
      this.getBaseData(search)
      this.getArticleData(search)
    } else {
      this.$toast('搜索失败,请返回重试')
    }
  },
  methods: {
    // 基地
    getBaseData(search) {
      this.$toast.loading({
        message: '加载中...',
        duration: 0,
        forbidClick: true,
      })

      this.yxAxios
        .post(`${this.yanxueUrl}/api/SchoolManage/SchoolStudyBaseList`, {
          labelIdList: '',
          provinceName: '',
          cityName: '',
          areaName: '',
          levelName: '',
          type: 0,
          StartPeopleCount: -1,
          EndPeopleCount: -1,
          baseName: search,
          pageIndex: 1,
          pageSize: 999,
        })
        .then((res) => {
          this.$toast.clear()
          if (res.data.status == 1) {
            let data = res.data.data
            let BaseData = data.data
            console.log('基地数据:', BaseData)
            this.BaseData = BaseData
          } else {
            this.$toast(res.data.message || res.data.result)
          }
        })
    },
    // 精选活动
    getCourseData(search) {
      this.$toast.loading({
        message: '加载中...',
        duration: 0,
        forbidClick: true,
      })
      this.yxAxios
        .post(`${this.yanxueUrl}/api/SchoolManage/SchoolCourseListV2`, {
          labelIdList: '',
          ageType: 0, //适应对象
          days: 0, //线路天数
          isSelfSupport: '', //是否支持定制
          areaName: '', //区
          startPrice: -1,
          endPrice: -1,
          courseName: search,
          stype: 1,
          pageIndex: 1,
          pageSize: 999,
        })
        .then((res) => {
          this.$toast.clear()
          if (res.data.status == 1) {
            let data = res.data.data
            let CourseData = data.data
            console.log('活动数据:', CourseData)
            for (let i in CourseData) {
              CourseData[i].course_labels = CourseData[i].course_labels?.split(',')
              if (CourseData[i].startDate) {
                CourseData[i].week = this.formatWeek(this.Moment(CourseData[i].startDate).format('d'))
                CourseData[i].startDate = this.Moment(CourseData[i].startDate).format('YYYY.M.D')
                CourseData[i].endDate = this.Moment(CourseData[i].endDate).format('YYYY.M.D')
              }
            }
            this.CourseData = CourseData
          } else {
            this.$toast(res.data.message || res.data.result)
          }
        })
    },
    // 资讯
    getArticleData(search) {
      this.$toast.loading({
        message: '加载中...',
        duration: 0,
        forbidClick: true,
      })

      this.yxAxios
        .post(`${this.proxyUrl}/manage/info/content/listWithNoContent`, { pageNum: 1, pageSize: 999, title: search })
        .then((res) => {
          if (res.data.code == 200) {
            let all = res.data.rows
            let tempList = []
            all.forEach((item) => {
              item.createTime = this.Moment(new Date(item.createTime)).format('YYYY-MM-DD')
              tempList.push(item)
            })
            this.ArticleData = tempList
          } else {
            this.$toast.fail(res.data.message)
          }
        })
    },
    // 返回顶部
    backTop() {
      document.getElementById('SearchResult').scrollIntoView()
    },
    // 格式化星期
    formatWeek(week) {
      return week == 1
        ? '周一'
        : week == 2
        ? '周二'
        : week == 3
        ? '周三'
        : week == 4
        ? '周四'
        : week == 5
        ? '周五'
        : week == 6
        ? '周六'
        : week == 0
        ? '周日'
        : ''
    },
  },
  components: {
    ServiceListSecond,
    BaseList,
    ArticleList,
  },
}
</script>
<style lang="scss">
#SearchResult {
  width: 100%;
  min-height: 100%;
  background: #fff;
  padding-bottom: 40px;
  .drop_down_box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .filter {
      flex-shrink: 0;
      font-size: 28px;
      padding: 0 30px;
    }
  }
  .characteristic_label {
    white-space: nowrap;
    overflow-x: auto;
    padding: 0 30px;
    padding-top: 20px;
    &::-webkit-scrollbar {
      display: none;
    }
    span {
      display: inline-block;
      padding: 10px;
      font-size: 24px;
      background: #f5f6fa;
      border-radius: 8px;
      border: 1px solid #f5f6fa;
      margin-right: 12px;
      &.active {
        background: #ebf4ff;
        color: #1373ea;
        border-color: #1373ea;
      }
    }
  }
  .page_loading {
    font-size: 24px;
    text-align: center;
    padding-top: 40px;
  }
  .backtop {
    position: fixed;
    bottom: 100px;
    right: 40px;
    font-size: 60px;
    background: #eee;
    border-radius: 10px;
    padding: 10px;
  }
  // .van-tab {
  //   font-size: 32px;
  // }
  // .van-dropdown-menu__bar {
  //   box-shadow: none;
  // }
  // .van-dropdown-menu__item {
  //   flex: none;
  //   width: 180px;
  // }
  // .van-dropdown-menu__title {
  //   font-size: 28px;
  //   color: #999;
  // }
  // .van-cell {
  //   color: #999;
  // }
}
</style>