<template>
<u-popup :show="show" mode="bottom" @close="close" @open="open" :closeable="true">
<view class="">
<view class="title">选择服务时间 </view>
<view class="workTime">
<view class="t1" @click="choseType('am')">{{startTime}}</view>
<view class="t2">{{workTime}}小时</view>
<view class="t1" @click="choseType('pm')">{{endTime}}</view>
</view>
<view class="workTime">
<view :class="timeType=='am'?'t1 typecolor' :'t1'" @click="timeType='am';"
style="border: none;" >00:00-11:59</view>
<view class="t2"> </view>
<view :class="timeType=='pm'?'t1 typecolor' :'t1'" @click="timeType='pm'"
style="border: none;" >12:00-23:59</view>
</view>
<view class="timebox">
<view class="time" v-if="timeType=='am'">
<view v-for="(item,index) in amlist" :key="index" :class="startTime==item ? 'activetime' : ''"
@click="changetime(item,'am')">
{{item}}
</view>
</view>
<view class="time" v-if="timeType=='pm'">
<view v-for="(it,i) in pmlist" :key="'pm'+i" :class="endTime==it ? 'activetime' : ''"
@click="changetime(it,'pm')">
{{it}}
</view>
</view>
</view>
<view class="woodsbtn btn" @click="handleTime">
确定
</view>
</view>
</u-popup>
</template>
<script>
import calculateTimeDifference from "@/utils/calculateTimeDifference.js"
export default {
name:"choseTime",
data() {
return {
show:true,
startTime:"",
endTime:"",
amlist:["7:00","7:30","8:00","8:30"],
pmlist:["12:00","13:30","14:00","19:30"],
workTime:"0",
timeType:"am"
};
},
methods:{
handleTime(){
if(this.workTime==0){
uni.showToast({
title:'请选择服务时间',
icon:'none'
})
return
}
this.$emit('handleTime',{
startTime:this.startTime,
endTime:this.endTime,
workTime:this.workTime
})
this.show = false
},
open() {
// console.log('open');
},
close() {
this.show = false
},
choseType(type){
this.timeType=type
},
changetime(item,type){
if (type=='am') {
this.startTime=item
this.timeType='pm'
}else if (type=='pm') {
this.endTime=item
}
if(this.startTime && this.endTime){
this.workTime=calculateTimeDifference(this.startTime,this.endTime)
}
},
}
}
</script>
<style scoped lang="scss">
.title{
text-align: center;
line-height: 50rpx;
font-weight: bold;
padding: 30rpx;
}
.workTime{
display: flex;
align-items: center;
justify-content: center;
padding: 20rpx;
.t1{
border-bottom: 1px solid #EEEEEE;
width: 220rpx;
margin: 0 30rpx;
height:60rpx;
text-align: center;
}
.t2{
height: 60rpx;
width: 160rpx;
text-align: center;
font-size: 28rpx;
color: #999999;
}
.typecolor{
font-weight: bold;
font-size: 32rpx;
color: #277EEF;
}
}
.timebox{
padding: 10rpx 0;
.timetitile{
font-size: 36rpx;
font-weight: bold;
padding: 0 30rpx;
}
.time{
display: flex;
align-items: center;
flex-wrap: wrap;
margin-top: 20rpx;
margin-bottom: 60rpx;
>view{
// width: 120rpx;
padding:20rpx 35rpx;
margin: 15rpx;
// height: 60rpx;
background-color: #F2F2F2;
border-radius: 8rpx
}
.activetime{
border: 1px solid #277EEF;
color: #277EEF;
}
}
}
.chosetime{
position: fixed;
left: 5%;
bottom: 80rpx;
width: 90%;
background: linear-gradient(#FF7134,#FF3A3E);
border-radius:20rpx;
padding: 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
.tleft{
color: #fff;
text{
font-size: 36rpx;
color: #fff;
}
}
.tright{
width: 200rpx;
height:80rpx;
background: #ffc368;
border-radius: 12rpx;
text-align: center;
line-height: 80rpx;
color: #594423;
}
}
.btn{
width: 90%;
margin-bottom: 40rpx;
}
</style>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
- 79.
- 80.
- 81.
- 82.
- 83.
- 84.
- 85.
- 86.
- 87.
- 88.
- 89.
- 90.
- 91.
- 92.
- 93.
- 94.
- 95.
- 96.
- 97.
- 98.
- 99.
- 100.
- 101.
- 102.
- 103.
- 104.
- 105.
- 106.
- 107.
- 108.
- 109.
- 110.
- 111.
- 112.
- 113.
- 114.
- 115.
- 116.
- 117.
- 118.
- 119.
- 120.
- 121.
- 122.
- 123.
- 124.
- 125.
- 126.
- 127.
- 128.
- 129.
- 130.
- 131.
- 132.
- 133.
- 134.
- 135.
- 136.
- 137.
- 138.
- 139.
- 140.
- 141.
- 142.
- 143.
- 144.
- 145.
- 146.
- 147.
- 148.
- 149.
- 150.
- 151.
- 152.
- 153.
- 154.
- 155.
- 156.
- 157.
- 158.
- 159.
- 160.
- 161.
- 162.
- 163.
- 164.
- 165.
- 166.
- 167.
- 168.
- 169.
- 170.
- 171.
- 172.
- 173.
- 174.
- 175.
- 176.
- 177.
- 178.
- 179.
- 180.
- 181.
- 182.
- 183.
- 184.
- 185.
- 186.
- 187.
- 188.
- 189.
- 190.
- 191.
- 192.
- 193.
- 194.
- 195.
- 196.