// 精选课程 <template> <div id="SelectionCourse"> <van-search v-model="searchValue" placeholder="请输入课程关键词" @search="reloadData" /> <van-tabs v-model="active" @click="tabChange"> <van-tab :title="item.text" v-for="(item, index) in typeOption" :key="index"></van-tab> </van-tabs> <van-list v-if="CourseData.length > 0" v-model="loading" :finished="finished" finished-text="没有更多了" :immediate-check="false" @load="getCourseData" > <ServiceListSecond :list="CourseData" :courseTypeLableId="typeOption[active].id"></ServiceListSecond> </van-list> <van-empty v-if="finished && CourseData.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' export default { data() { return { pageLoading: true, pageSize: 10, pageNum: 1, loading: false, finished: false, searchValue: '', CourseData: [], typeOption: [], active: 0, } }, mounted() { let userInfo = localStorage.getItem('userInfo') if (userInfo) { userInfo = JSON.parse(userInfo) this.centerNo = userInfo.centerNo } // this.getCourseData() this.getType() }, methods: { // 下拉刷新 onRefresh() { this.pageNum = 1 this.reloadData() }, reloadData() { console.log('reloadData') this.pageNum = 1 this.CourseData = [] this.getCourseData() }, // 精选活动 getCourseData() { if (this.pageNum == 1) { this.$toast.loading({ message: '加载中...', duration: 0, forbidClick: true, }) } let labelIdList = [] // 频道标签 labelIdList.push(this.typeOption[this.active].id) let areaName = '' let startPrice = '-1', endPrice = '-1' this.yxAxios .post(`${this.yanxueUrl}/api/SchoolManage/SchoolCourseListV2`, { labelIdList: labelIdList, ageType: 0, //适应对象 days: 0, //线路天数 isSelfSupport: null, //是否支持定制 // "provinceName":provinceName,//省份 // "cityName":cityName,//城市 areaName: areaName, //区 startPrice: startPrice, endPrice: endPrice, courseName: 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 CourseData = data.data console.log('活动数据:', CourseData) if (this.pageSize * this.pageNum >= data.count) { this.finished = true } else { this.pageNum++ } 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 = this.CourseData.concat(CourseData) } else { this.finished = true this.$toast(res.data.message || res.data.result) } }) }, // 获取研学类型 getType() { // this.yxAxios.post(`http://121.40.30.78:9000/StudyLabelDetail/List`, { this.yxAxios .post(`${this.yanxueUrl}/StudyLabelDetail/List`, { labelGroupId: 11, belongStation: '浙江省教育厅', platform: '电脑端', pageIndex: 1, pageSize: 10, }) .then((res) => { if (res.data.status == 1) { let data = res.data.data.data // let typeOption = [{ text: '不限', value: 0, id: '' }] let typeOption = [] for (let i in data) { typeOption.push({ text: data[i].labelName, id: data[i].id, value: Number(i) + 1, }) } console.log('研学类型:', typeOption) this.typeOption = typeOption this.getCourseData() } else { this.$toast(res.data.message) } }) }, // 返回顶部 backTop() { document.getElementById('SelectionCourse').scrollIntoView() }, // 格式化星期 formatWeek(week) { return week == 1 ? '周一' : week == 2 ? '周二' : week == 3 ? '周三' : week == 4 ? '周四' : week == 5 ? '周五' : week == 6 ? '周六' : week == 0 ? '周日' : '' }, tabChange() { this.pageNum = 1 this.CourseData = [] this.getCourseData() }, }, components: { ServiceListSecond, }, } </script> <style lang="scss"> #SelectionCourse { 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>