|
@@ -28,6 +28,9 @@
|
|
</div>
|
|
</div>
|
|
<div
|
|
<div
|
|
class="days"
|
|
class="days"
|
|
|
|
+ @touchstart='touchStart'
|
|
|
|
+ @touchmove='touchMove'
|
|
|
|
+ @touchend='touchEnd'
|
|
v-if="daysShow"
|
|
v-if="daysShow"
|
|
>
|
|
>
|
|
<div
|
|
<div
|
|
@@ -39,6 +42,7 @@
|
|
v-for="(item, index) in items"
|
|
v-for="(item, index) in items"
|
|
:key="index"
|
|
:key="index"
|
|
class="day"
|
|
class="day"
|
|
|
|
+ :class="{'other':item.other}"
|
|
@click.stop="onChange(item)"
|
|
@click.stop="onChange(item)"
|
|
>
|
|
>
|
|
<span class="text" :class="{'active':item.isWork}">{{item.day}}</span>
|
|
<span class="text" :class="{'active':item.isWork}">{{item.day}}</span>
|
|
@@ -93,6 +97,10 @@ export default {
|
|
days: '',
|
|
days: '',
|
|
day: '',
|
|
day: '',
|
|
daysShow: false,
|
|
daysShow: false,
|
|
|
|
+ startX: 0, // 开始触摸的位置
|
|
|
|
+ moveX: 0, // 滑动时的位置
|
|
|
|
+ endX: 0, // 结束触摸的位置
|
|
|
|
+ disX: 0, // 移动距离
|
|
};
|
|
};
|
|
},
|
|
},
|
|
props: {
|
|
props: {
|
|
@@ -170,6 +178,7 @@ export default {
|
|
year: self.year,
|
|
year: self.year,
|
|
months: self.months,
|
|
months: self.months,
|
|
day: i,
|
|
day: i,
|
|
|
|
+ other: false,
|
|
week: dayInWeek,
|
|
week: dayInWeek,
|
|
// 判断当天是否有服务
|
|
// 判断当天是否有服务
|
|
isWork: self.isServerWork(dateInFor, dayInWeek),
|
|
isWork: self.isServerWork(dateInFor, dayInWeek),
|
|
@@ -190,6 +199,7 @@ export default {
|
|
months: getPreviousDate.months,
|
|
months: getPreviousDate.months,
|
|
day: previousDays,
|
|
day: previousDays,
|
|
week: dayInWeek,
|
|
week: dayInWeek,
|
|
|
|
+ other: true,
|
|
isWork: self.isServerWork(self.setDate(getPreviousDate), dayInWeek),
|
|
isWork: self.isServerWork(self.setDate(getPreviousDate), dayInWeek),
|
|
};
|
|
};
|
|
}
|
|
}
|
|
@@ -207,6 +217,7 @@ export default {
|
|
months: getNextDate.months,
|
|
months: getNextDate.months,
|
|
day: next += 1,
|
|
day: next += 1,
|
|
week: dayInWeek,
|
|
week: dayInWeek,
|
|
|
|
+ other: true,
|
|
isWork: self.isServerWork(self.setDate(getNextDate), dayInWeek),
|
|
isWork: self.isServerWork(self.setDate(getNextDate), dayInWeek),
|
|
};
|
|
};
|
|
}
|
|
}
|
|
@@ -321,10 +332,40 @@ export default {
|
|
onChange(item) {
|
|
onChange(item) {
|
|
this.$emit('time', item);
|
|
this.$emit('time', item);
|
|
},
|
|
},
|
|
|
|
+ // 滑动事件
|
|
|
|
+ touchStart(event) {
|
|
|
|
+ // ev = ev || event;
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ if (event.touches.length === 1) {
|
|
|
|
+ this.startX = event.touches[0].clientX; // 记录开始位置
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ touchMove(event) {
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ if (event.touches.length === 1) {
|
|
|
|
+ this.moveX = event.touches[0].clientX;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ touchEnd(event) {
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ if (event.changedTouches.length === 1) {
|
|
|
|
+ this.disX = this.startX - this.moveX;
|
|
|
|
+ const percentage = Math.abs(this.disX) / window.innerWidth * 100 > 10;
|
|
|
|
+ if (this.disX > 0) {
|
|
|
|
+ if (percentage) {
|
|
|
|
+ this.setNext();
|
|
|
|
+ }
|
|
|
|
+ } else if (percentage) {
|
|
|
|
+ this.setPrevious();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|
|
|
|
+ @import "../assets/style/vant.less";
|
|
|
|
+
|
|
.date-picker-wrapper {
|
|
.date-picker-wrapper {
|
|
.date {
|
|
.date {
|
|
display: flex;
|
|
display: flex;
|
|
@@ -335,7 +376,9 @@ export default {
|
|
.day {
|
|
.day {
|
|
flex: 1;
|
|
flex: 1;
|
|
text-align: center;
|
|
text-align: center;
|
|
- font-size: 16px;
|
|
|
|
|
|
+ font-size: @inputSize;
|
|
|
|
+ transform: rotate3d(0, 0, 0);
|
|
|
|
+ transition: all .3s ease-in;
|
|
width: calc(100% / 7);
|
|
width: calc(100% / 7);
|
|
height: 40px;
|
|
height: 40px;
|
|
position: relative;
|
|
position: relative;
|
|
@@ -352,17 +395,19 @@ export default {
|
|
transform: translate(-50%, 25%);
|
|
transform: translate(-50%, 25%);
|
|
}
|
|
}
|
|
.active {
|
|
.active {
|
|
|
|
+ color: red;
|
|
|
|
+ }
|
|
|
|
+ &.other {
|
|
color: white;
|
|
color: white;
|
|
- background-color: red;
|
|
|
|
- border-radius: 50%;
|
|
|
|
|
|
+ background-color: #c6c6c6;
|
|
|
|
+ .active {
|
|
|
|
+ color: #8d8d8d;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
&:last-child {
|
|
&:last-child {
|
|
border-right: 0;
|
|
border-right: 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- &:nth-child(even) {
|
|
|
|
- background-color: #0ac8ff;
|
|
|
|
- }
|
|
|
|
&:last-child {
|
|
&:last-child {
|
|
.day {
|
|
.day {
|
|
border-bottom: 0;
|
|
border-bottom: 0;
|
|
@@ -373,20 +418,33 @@ export default {
|
|
display: flex;
|
|
display: flex;
|
|
padding: 10px 0;
|
|
padding: 10px 0;
|
|
text-align: center;
|
|
text-align: center;
|
|
|
|
+ justify-content: space-between;
|
|
.flex {
|
|
.flex {
|
|
width: calc(100% / 3);
|
|
width: calc(100% / 3);
|
|
display: flex;
|
|
display: flex;
|
|
& > div {
|
|
& > div {
|
|
flex: 1;
|
|
flex: 1;
|
|
- font-size: 17px;
|
|
|
|
|
|
+ font-size: @inputSize;
|
|
line-height: 20px;
|
|
line-height: 20px;
|
|
}
|
|
}
|
|
|
|
+ &:nth-child(2) {
|
|
|
|
+ flex: 1;
|
|
|
|
+ }
|
|
|
|
+ &:nth-child(1), &:nth-child(3) {
|
|
|
|
+ flex: 0 0 100px;
|
|
|
|
+ & > div {
|
|
|
|
+ flex: 0 0 40px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.weeks {
|
|
.weeks {
|
|
background-color: #eee;
|
|
background-color: #eee;
|
|
line-height: 40px;
|
|
line-height: 40px;
|
|
border-bottom: 1px solid black;
|
|
border-bottom: 1px solid black;
|
|
|
|
+ .day {
|
|
|
|
+ background-color: #eee !important;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|