From 170e63494a07bb7c777d514d8dc4f35afc68070f Mon Sep 17 00:00:00 2001 From: "liujw155@outlook.com" Date: Thu, 4 Mar 2021 18:04:53 +0800 Subject: [PATCH] add api --- src/js/api.js | 1 + src/pages/time/_config/_config.vue | 120 ++++++++++++++++++++++++++++++------- src/pages/time/select/select.vue | 77 ++++++++++++++++++++---- 3 files changed, 168 insertions(+), 30 deletions(-) diff --git a/src/js/api.js b/src/js/api.js index d962e9c..65621b5 100644 --- a/src/js/api.js +++ b/src/js/api.js @@ -30,6 +30,7 @@ export const API = { // 我的时间 getCoachTimeList: `${ORIGIN}/stadium/coach/getCoachTimeList`, // 场地列表 saveCoachTimeStatus: `${ORIGIN}/stadium/coach/saveCoachTimeStatus`, // 小程序-教练时间状态修改-我的时间 + setCoachTimes: `${ORIGIN}/stadium/coach/setCoachTimes`, // 小程序-我的时间-批量设置 } diff --git a/src/pages/time/_config/_config.vue b/src/pages/time/_config/_config.vue index 23093a4..7e11b63 100644 --- a/src/pages/time/_config/_config.vue +++ b/src/pages/time/_config/_config.vue @@ -4,36 +4,36 @@ 选择日期范围 - + - - + + - - + - - + + - 选择日期范围 + 选择时间范围 - + - - + + - - + - - + + @@ -42,10 +42,10 @@ 状态 - + - - + + @@ -53,16 +53,97 @@ 备注 - + - 保存 + 保存 @@ -108,7 +189,6 @@ export default { flex-shrink: 0; width: 16upx; height: 16upx; - background-color: skyblue; } } } diff --git a/src/pages/time/select/select.vue b/src/pages/time/select/select.vue index f18801c..7df6dac 100644 --- a/src/pages/time/select/select.vue +++ b/src/pages/time/select/select.vue @@ -21,13 +21,14 @@ 日期 时间 - + - 周四 + {{get_zh_day(e.day) || '-'}} {{e.day || '-'}} + {{ e.duration || '-'}} @@ -45,7 +46,7 @@ ]" @click="timeSelect({i, j, k})" > - {{k.remark || ''}} + {{k.remark || ''}} @@ -58,7 +59,7 @@ - + @@ -102,7 +103,8 @@ import { API } from '../../../js/api'; import { servers } from '../../../js/server'; import util from '../../../utils/util'; -const statusList = [ +let scrollTimer = null; +let statusList = [ { id: 1, name: '空闲', @@ -119,10 +121,13 @@ const statusList = [ status: 2 }, ] + export default { data(){ return { timeAreaScrollX: 0, // 日期时间表滚动位置 + dateAreaScrollX: 0, // 日期时间表滚动位置 + scrollStatus: 0, // 滚动区 1-> 日期 , 2-> 时间 timeSlot: { // 顶部日期 start: '', end: '', @@ -162,6 +167,7 @@ export default { }, methods: { + get_zh_day: util.get_zh_day, confiemChangeStatus: util.debounce(function(){ let { timeList, changeRemark, changeStatusIDX } = this; let _selectedArr = []; @@ -210,7 +216,10 @@ export default { this.changeStatusIDX = e.detail.value; }, timeSelect({i, j, k}){ - if(k.status ==1 || k.status ==2)return; + if(k.status ==1 || k.status ==2)return util.showModal({ + title: '备注', + content: k.remark + }); let _list = [...this.timeList]; _list[i].items[j]._selectStatus = !_list[i].items[j]._selectStatus; this.timeList = [..._list]; @@ -222,6 +231,7 @@ export default { start_date, end_date, }){ + util.showLoad(); servers.get({ url: API.getCoachTimeList, data: { @@ -231,23 +241,55 @@ export default { failMsg: '加载失败!' }) .then(res=>{ + util.hideLoad(); this.timeList = res.list || []; console.warn(res) }) }, startTimeChange(e){ this.timeSlot.start = e.detail.value; + this.getTimeList({ + start_date: e.detail.value, + end_date: this.timeSlot.end, + }) + }, endTimeChange(e){ this.timeSlot.end = e.detail.value; + this.getTimeList({ + start_date: this.timeSlot.start, + end_date: e.detail.value, + }) }, dateScroll(e){ - console.warn('dateScroll', e) + // console.warn('dateScroll', e) + + + if(this.scrollStatus == 2)return; this.timeAreaScrollX = e.detail.scrollLeft; + this.scrollStatus = 1; + if(scrollTimer){ + clearTimeout(scrollTimer); + scrollTimer = null; + } + scrollTimer = setTimeout(_=>{ + this.scrollStatus = 0; + }, 200) + }, timeScroll(e){ - console.warn('timeScroll', e) - this.timeAreaScrollX = e.detail.scrollLeft; + if(this.scrollStatus == 1)return; + // console.warn('timeScroll', e) + this.dateAreaScrollX = e.detail.scrollLeft; + this.scrollStatus = 2; + if(scrollTimer){ + clearTimeout(scrollTimer); + scrollTimer = null; + } + scrollTimer = setTimeout(_=>{ + this.scrollStatus = 0; + }, 200) + }, } @@ -257,11 +299,17 @@ export default {