SelectionBase.vue 8.21 KB
// 研学基地
<template>
  <div id="SelectionBase">
    <van-search v-model="searchValue" placeholder="请输入基地关键词" @search="reloadData"/>
    <div class="drop_down_box">
      <selection-base-drop-down class="drop_down" ref="dropdown" @dropdownChange="dropdownChange"></selection-base-drop-down>
      <p class="filter" @click="handleFilter">
        筛选
        <van-icon name="arrow-down" />
      </p>
    </div>
    <div class="characteristic_label">
      <span
        :class="item.isSelect ? 'active' : ''"
        v-for="(item, index) in CharacteristicLabelList"
        :key="index"
        @click="CharacteristicLabelChange(index)"
        >{{ item.labelName }}</span
      >
    </div>
    <van-list
      v-if="BaseData.length > 0"
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      :immediate-check="false"
      @load="getBaseData"
    >
      <BaseList :list="BaseData"></BaseList>
    </van-list>
    <van-empty v-if="finished && BaseData.length == 0" :image="require('@/assets/empty.png')" description="暂无基地" />
    <van-icon name="back-top" class="backtop" @click="backTop" />
    <selection-base-filter ref="filter" @filterChange="filterChange"></selection-base-filter>
  </div>
</template>

<script>
import BaseList from '@/views/Service/component/c_BaseList.vue'
import SelectionBaseFilter from './c_SelectionBaseFilter.vue'
import SelectionBaseDropDown from './c_SelectionBaseDropDown.vue'
export default {
  data() {
    return {
      searchValue: '',
      frequencyId: '', //频道标签
      pageLoading: true,
      pageSize: 10,
      pageNum: 1,
      loading: false,
      finished: false,

      BaseData: [],
      CharacteristicLabelList: [
        // {
        //   labelName:'测试1',
        //   value:'JP666'
        // },
        // {
        //   labelName:'测试2',
        //   value:'JP777'
        // }
      ],
      active: 0,
      dropdownObj: { type: '', course: '', destination: '' }, //下拉菜单数据
      filterObj: { Count: '', Type: '', Level: '' }, //右侧筛选
    }
  },
  mounted() {
    let userInfo = localStorage.getItem('userInfo')
    if (userInfo) {
      userInfo = JSON.parse(userInfo)
      this.centerNo = userInfo.centerNo
    }
    this.frequencyId = this.$route.query.frequencyId

    this.getBaseData()
  },
  methods: {
    handleFilter() {
      this.$refs.filter.openShow()
    },
    // 下拉刷新
    onRefresh() {
      this.pageNum = 1
      this.reloadData()
    },
    reloadData() {
      console.log('reloadData')
      this.pageNum = 1
      this.BaseData = []
      this.getBaseData()
    },
    // 精选活动
    getBaseData() {
      if (this.pageNum == 1) {
        this.$toast.loading({
          message: '加载中...',
          duration: 0,
          forbidClick: true,
        })
      }

      let labelIdList = ''
      // 平铺
      for (let i in this.CharacteristicLabelList) {
        if (this.CharacteristicLabelList[i].isSelect) {
          labelIdList = this.CharacteristicLabelList[i].value
          break
        }
      }
      // // 下拉
      let dropdownObj = this.dropdownObj
      // // 右侧
      let filterObj = this.filterObj
      if (filterObj.Type) {
      }
      let StartPeopleCount = '-1',
        EndPeopleCount = '-1'
      if (filterObj.Count) {
        if (filterObj.Count == 1) {
          StartPeopleCount = 0
          EndPeopleCount = 200
        }
        if (filterObj.Count == 2) {
          StartPeopleCount = 200
          EndPeopleCount = 500
        }
        if (filterObj.Count == 3) {
          StartPeopleCount = 500
          EndPeopleCount = 1000
        }
        if (filterObj.Count == 4) {
          StartPeopleCount = 1000
          EndPeopleCount = -1
        }
      }
      //筛选标签
      // let CharacteristicLabel = '';
      this.yxAxios
        .post(`${this.yanxueUrl}/api/SchoolManage/SchoolStudyBaseList`, {
          labelIdList: labelIdList,
          provinceName: '浙江省',
          cityName: dropdownObj.destination,
          areaName: dropdownObj.destination2,
          levelName: filterObj.Level,
          type: filterObj.Type || 0,
          StartPeopleCount: StartPeopleCount,
          EndPeopleCount: EndPeopleCount,
          baseName:this.searchValue,
          stype:1,
          pageIndex: this.pageNum,
          pageSize: this.pageSize,
        })
        .then((res) => {
          this.$toast.clear()
          if (res.data.status == 1) {
            let data = res.data.data
            this.loading = false
            let BaseData = data.data
            console.log('活动数据:', BaseData)
            if (this.pageSize * this.pageNum >= data.count) {
              this.finished = true
            } else {
              this.pageNum++
            }
            // for (let i in BaseData) {
            //   BaseData[i].course_labels = BaseData[i].course_labels?.split(',');
            //   if (BaseData[i].startDate) {
            //     BaseData[i].week = this.formatWeek(this.Moment(BaseData[i].startDate).format('d'));
            //     BaseData[i].startDate = this.Moment(BaseData[i].startDate).format('YYYY.M.D');
            //     BaseData[i].endDate = this.Moment(BaseData[i].endDate).format('YYYY.M.D');
            //   }

            // }
            this.BaseData = this.BaseData.concat(BaseData)
          } else {
            this.finished = true
            this.$toast(res.data.message || res.data.result)
          }
        })
    },
    // 返回顶部
    backTop() {
      document.getElementById('SelectionBase').scrollIntoView()
    },
    // 格式化星期
    formatWeek(week) {
      return week == 1
        ? '周一'
        : week == 2
        ? '周二'
        : week == 3
        ? '周三'
        : week == 4
        ? '周四'
        : week == 5
        ? '周五'
        : week == 6
        ? '周六'
        : week == 0
        ? '周日'
        : ''
    },
    CharacteristicLabelChange(index) {
      let CharacteristicLabelList = [...this.CharacteristicLabelList]
      if (!CharacteristicLabelList[index].isSelect) {
        for (let i in CharacteristicLabelList) {
          CharacteristicLabelList[i].isSelect = false
        }
        CharacteristicLabelList[index].isSelect = true
      } else {
        CharacteristicLabelList[index].isSelect = false
      }
      this.CharacteristicLabelList = CharacteristicLabelList
      this.reloadData()
    },
    filterChange(obj) {
      console.log(obj)
      this.filterObj = obj
      this.reloadData()
    },
    dropdownChange(obj) {
      console.log(obj)
      this.dropdownObj = obj
      this.reloadData()
    },
  },
  components: {
    BaseList,
    SelectionBaseFilter,
    SelectionBaseDropDown,
  },
}
</script>
<style lang="scss">
#SelectionBase {
  width: 100%;
  min-height: 100%;
  background: #fff;
  padding-bottom: 40px;
  .drop_down_box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .drop_down {
    }
    .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;
    margin-right: 40px;
  }
  .van-dropdown-menu__title {
    font-size: 28px;
    color: #999;
  }
  .van-cell {
    color: #999;
  }
}
</style>
<style lang="scss">
// 长辈版
.elder {
  .select_popup .filter_title,.select_popup .select_item,#SelectionBase .drop_down_box .filter,#SelectionBase .van-dropdown-menu__title{
    font-size: 36px;
  }
  
}
</style>