Browse Source

feat(coach/course/list & student/timetable): 新增日历选择功能

- 为教练端课程列表和学生端课表页面添加日历选择功能
- 实现日期范围获取、日历打点设置和日期选择逻辑
-优化课程列表数据加载和分页功能
- 调整课程列表和课表的展示方式
master
liutong 12 months ago
parent
commit
303ca664d4
  1. 286
      pages/coach/course/list.vue
  2. 95
      pages/student/timetable/index.vue

286
pages/coach/course/list.vue

@ -9,40 +9,12 @@
<view class="main_section">
<view class="section_1">
<view class="ul">
<view class="li">
<text>周日</text>
<text>14</text>
<text></text>
</view>
<view class="li">
<text>周一</text>
<text>14</text>
<text></text>
</view>
<view class="li">
<text>周二</text>
<text>14</text>
<text></text>
</view>
<view class="li">
<text>周日</text>
<text class="today"></text>
<text class=""></text>
</view>
<view class="li">
<text>周一</text>
<text>14</text>
<text class="select_plan"></text>
</view>
<view class="li">
<text>周二</text>
<text>14</text>
<text></text>
</view>
<view class="li">
<text>周二</text>
<text>14</text>
<text></text>
<view class="li" v-for="(v,k) in dateList" :key="k" @click="selectDate(v.date)">
<text>{{v.week}}</text>
<text :class="[filteredData.schedule_date == v.date ? 'today':'']">{{today == v.date ? '今':v.today}}</text>
<text :class="[v.status == 2 ?'select_plan':'']"></text>
</view>
</view>
<view class="btn" @click="show_calendar=true">
@ -74,109 +46,46 @@
<!-- </view>-->
<view class="section_3">
<view class="ul">
<view class="li" @click="openViewCourseInfoList({id:2})">
<view class="top_box">
<view class="center_box">
<view>班级少年班</view>
<view>时间2020-05-25 15:30 - 17:30</view>
<view>课室302
</view>
<view>课程篮球少儿课
</view>
</view>
<view class="right_box">
<view class="tag" style="background:#20caaf;">未开始</view>
<!-- <view class="tag" style="background:#1cd188;">待上课</view>-->
</view>
</view>
<view class="bottom_box">
<view class="list_box" style="margin-top: 0;">
<view class="hint">
人数30
</view>
<view class="btn">
详情
</view>
</view>
</view>
</view>
<view class="li" @click="openViewCourseInfo({id:1})">
<view class="top_box">
<view class="center_box">
<view>班级少年班</view>
<view>时间2020-05-25 15:30 - 17:30</view>
<view>课室302
</view>
<view>课程篮球少儿课
</view>
</view>
<view class="right_box">
<view class="tag" style="background:#fad24e;">上课中</view>
<!-- <view class="tag" style="background:#1cd188;">待上课</view>-->
</view>
</view>
<view class="bottom_box">
<view class="hint">
已签到学生 (15/34)
</view>
<view class="list_box">
<view class="list">
<view class="itme">
<image src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image>
</view>
<view class="itme">
<image src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image>
</view>
<view class="itme">
<image src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image>
</view>
<view class="itme">
<image src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image>
</view>
</view>
<view class="btn">
详情
</view>
</view>
</view>
</view>
<view class="li" @click="openViewCourseInfo({id:2})">
<scroll-view
class="section_3"
scroll-y="true"
:lower-threshold="lowerThreshold"
@scrolltolower="loadMoreData"
style="height: 100vh;"
>
<view class="ul">
<view
class="li"
v-for="(v,k) in tableList"
:key="k"
@click="openViewCourseInfoList(v)"
>
<view class="top_box">
<view class="center_box">
<view>班级少年班</view>
<view>时间2020-05-25 15:30 - 17:30</view>
<view>课室302
<view>班级{{v.classes_name}}</view>
<view>时间{{v.date}}</view>
<view>课室{{v.address}}
</view>
<view>课程篮球少儿课
<view>课程{{v.courses_name}}
</view>
</view>
<view class="right_box">
<view class="tag" style="background:#e2e2e2;">已结束</view>
<!-- v.status|1=未开始,2=进行中,3=已结束-->
<view class="tag" :style="{background: v.status == 1 ? '#1cd188' : v.status == 2 ? '#fad24e' : '#ff4d4f'}">
{{ v.status === 1 ? '未开始' : v.status === 2 ? '上课中' : '已结束' }}</view>
<!-- <view class="tag" style="background:#1cd188;">待上课</view>-->
</view>
</view>
<view class="bottom_box">
<view class="hint">
已签到学生 (15/34)
已签到学生 ({{v.sign_list.length }}/{{v.max_students.split(',').length }})
</view>
<view class="list_box">
<view class="list">
<view class="itme">
<image src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image>
</view>
<view class="itme">
<image src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image>
</view>
<view class="itme">
<image src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image>
</view>
<view class="itme">
<image src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image>
<view class="itme" v-for="(item,index) in v.sign_list || 0" :key="index">
<image :src="$util.img(item.header)"></image>
</view>
</view>
<view class="btn">
@ -186,7 +95,7 @@
</view>
</view>
</view>
</view>
</scroll-view>
</view>
<!-- 日历选择-->
@ -211,6 +120,7 @@
<script>
// import user from '@/api/user.js';
import memberApi from '@/api/member.js';
import commonApi from '@/api/common.js';
import AQTabber from "@/components/AQ/AQTabber.vue"
@ -221,6 +131,21 @@ export default {
},
data() {
return {
loading: false,//
lowerThreshold: 100,//
isReachedBottom: false,//|true=|false=
//
filteredData: {
page: 1,//
limit: 10,//
total: 10,//
schedule_date: '',//
venue_id: '',//id
},
tableList: [],//
venuesInfo: {},//
formData:{},
//
@ -259,6 +184,10 @@ export default {
}
],
//
today: '',
dateList: [],//
//
show_calendar:false,//
startDate:'',//
@ -272,9 +201,20 @@ export default {
onShow(){
this.init()//
},
//
async onPullDownRefresh() {
//
let schedule_date = this.filteredData.schedule_date
await this.loadData()
this.filteredData.schedule_date = schedule_date
await this.getList()
},
methods: {
//
async init(){
await this.getThisDate()
await this.getHeadDate()
await this.getList()
this.getDateRange()
this.setCalendarSelected()
},
@ -315,6 +255,108 @@ export default {
})
},
//
async getHeadDate() {
let res = await commonApi.getDate()
if (res.code != 1) {
//
uni.showToast({
title: res.msg,
icon: 'none',
})
return
}
this.dateList = []
res.data.forEach((v, k) => {
let today = v.date.split("-")[2]; // "09"
this.dateList.push({
date: v.date,
status: v.status,//1 2
week: v.week,
today: today,
})
})
console.log('xxx', res)
},
//
async getThisDate() {
let date = new Date();
let year = date.getFullYear();
let month = String(date.getMonth() + 1).padStart(2, '0'); //
let day = String(date.getDate()).padStart(2, '0'); //
let hour = date.getHours();
let minute = date.getMinutes();
let second = date.getSeconds();
let res = `${year}-${month}-${day}`; //
this.today = res;
this.filteredData.schedule_date = res;
},
//
async selectDate(date) {
this.loadData()
this.filteredData.schedule_date = date
this.getList()
},
//()
loadMoreData() {
//
if (!this.isReachedBottom) {
this.isReachedBottom = true;//
this.getList();
}
},
//
async loadData() {
this.isReachedBottom = false; // 便
this.filteredData.page = 1//
this.filteredData.limit = 10//
this.filteredData.total = 10//
},
//
async getList() {
this.loading = true
let data = {...this.filteredData}
//
if (this.filteredData.page * this.filteredData.limit > this.filteredData.total || this.filteredData.limit > this.filteredData.total) {
this.loading = false
uni.showToast({
title: '暂无更多',
icon: 'none'
})
return
}
let res = await memberApi.courseList(data)
this.loading = false
this.isReachedBottom = false;
if (res.code != 1) {
uni.showToast({
title: res.msg,
icon: 'none'
})
return
}
this.tableList = res.data.list.data
//
this.venuesInfo = res.data.venues_info
this.filteredData.total = res.data.list.total
this.filteredData.page++
},
//
//
getDateRange() {

95
pages/student/timetable/index.vue

@ -17,6 +17,9 @@
<text :class="[v.status == 2 ?'select_plan':'']"></text>
</view>
</view>
<view class="btn" @click="show_calendar=true">
查看更多 <fui-icon name="arrowdown" color="#A4ADB3" size="45"></fui-icon>
</view>
</view>
<view class="section_2">
@ -63,7 +66,7 @@
<image :src="$util.img(item.header)"></image>
</view>
</view>
<view class="btn" @click="openViewTimetableInfo(v)">
<view class="btn">
详情
</view>
</view>
@ -76,6 +79,20 @@
</view>
<!-- 日历选择-->
<fui-bottom-popup :show="show_calendar" @close="show_calendar=false">
<view class="fui-custom__wrap">
<uni-calendar
:insert="true"
:lunar="false"
:selected="calendarSelected"
:startDate="startDate"
:endDate="endDate"
@change="changeCalendar"
/>
</view>
</fui-bottom-popup>
<!-- 底部导航-->
<AQTabber/>
</view>
@ -112,6 +129,12 @@ export default {
//
today: '',
dateList: [],//
//
show_calendar:false,//
startDate:'',//
endDate:'',//
calendarSelected: [],//
}
},
onLoad(options) {
@ -229,8 +252,8 @@ export default {
//
this.venuesInfo = res.data.venues_info
this.total = res.data.list.total
this.page++
this.filteredData.total = res.data.list.total
this.filteredData.page++
},
//
@ -240,6 +263,72 @@ export default {
this.getList()
},
//
//
getDateRange() {
const today = new Date(); //
const startDate = new Date(today); //
const endDate = new Date(today); //
// startDate 1
startDate.setMonth(today.getMonth() - 1);
// endDate 1
endDate.setMonth(today.getMonth() + 2);
// YYYY-MM-DD
const formatDate = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
};
// data startDate endDate
this.startDate = formatDate(startDate);
this.endDate = formatDate(endDate);
console.log([this.startDate,this.endDate])
},
//
async setCalendarSelected(){
//
let month = new Date().getMonth() + 1;
let res = await commonApi.getMonthDate({month:month})
if (res.code != 1){
//
uni.showToast({
title: res.msg,
icon: 'none',
duration: 2000
})
return
}
this.calendarSelected = []
res.data.forEach((v,k)=>{
this.calendarSelected.push({
date: v.date,
})
})
// this.calendarSelected = [
// {
// date: '2025-04-07',
// },
// {
// date: '2025-04-08',
// },
// {
// date: '2025-04-09',
// }
// ]
},
//
changeCalendar(e){
console.log('日历',e)
this.show_calendar = false
},
//
openViewCourseInfo(item) {

Loading…
Cancel
Save