diff --git a/pages/coach/course/list.vue b/pages/coach/course/list.vue index 03413f0..bccd081 100644 --- a/pages/coach/course/list.vue +++ b/pages/coach/course/list.vue @@ -45,7 +45,7 @@ - + 查看更多 @@ -189,6 +189,21 @@ + + + + + + + + @@ -242,11 +257,27 @@ export default { value: '2' } ], + + //日历选择相关 + show_calendar:false,//是否展示日期 + startDate:'',//开始日期 + endDate:'',//结束日期 + calendarSelected: [],//日历打点 } }, + onLoad() { }, + onShow(){ + this.init()//初始化 + }, methods: { + //初始化 + async init(){ + this.getDateRange() + this.setCalendarSelected() + }, + //选中课程下拉菜单点击事件 clickCourse(e){ console.log(e) @@ -281,6 +312,53 @@ export default { url: '/pages/coach/course/info' }) }, + + //日历选择相关 + // 获取日期范围 + 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]) + }, + //设置日期打点 + setCalendarSelected(){ + this.calendarSelected = [ + { + date: '2025-04-07', + }, + { + date: '2025-04-08', + }, + { + date: '2025-04-09', + } + ] + }, + //日历选择 + changeCalendar(e){ + console.log('日历',e) + this.show_calendar = false + }, + } }