123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528 |
- <template>
- <view>
- <view class="popup-wrapper popup-wrapper-special">
- <!-- 标题 -->
- <view class="popup-title popup-title-special popup-title-new">
- <view>请选择服务开始时间</view>
- <view v-if="selectTimeValue >= 17" class="fee-tips">您选的时间段可能会加收夜间服务费,具体以与商家的沟通为准</view>
- <!-- 选择服务者上门时段(具体服务时长以实际服务为准) -->
- </view>
- <block>
- <view class="popup-content popup-content-special">
- <view class="time-select-top" style="display: flex;">
- <scroll-view class="scroll-view_H" scroll-x="true" scroll-left="0">
- <view class="time-select-left-item" @tap="dateCheck" :data-index="index"
- :data-week="item.week" :data-date="item.date" :data-isbook="item.isBook"
- v-for="(item, index) in dateList" :key="index" style="display: inline-block;">
- <view class="date-line-wrapper">
- <view :class="[
- 'date-msg',
- dateIndex == index ? 'current-date' : '',
- item.dateMsg == '不可约' ? 'avail-date' : ''
- ]">
- {{item.weekOfDay}}
- </view>
- <view :class="[
- 'date-msg1',
- dateIndex == index ? 'current-date' : '',
- item.dateMsg == '不可约' ? 'avail-date' : ''
- ]"> {{ item.bookdate | formatDate }}</view>
- <view :class="[
- dateIndex == index ? 'current-line' : '',
- item.dateMsg == '不可约' ? 'current-line0' : ''
- ]"></view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="time-select-middle">
- <view class="noon-select">
- <view :class="'noon-item' + (noonType == '1' ? 'active-noon' : '')" data-noon="1"
- @tap="noonTab">上午</view>
- <view class="divider"></view>
- <view :class="'noon-item' + (noonType == '2' ? 'active-noon' : '')" data-noon="2"
- @tap="noonTab">下午</view>
- </view>
- <view class="time-item-wrapper">
- <view @tap="timeCheck" :data-stock="item.stock" :data-index="index" :data-msg="item.timeMsg" :data-toastmsg="item.toastMsg"
- :class="[
- 'time-msg',
- timeIndex == index ? 'current-time' : '',
- item.timeMsg == '不可约' ? 'avail-time' : ''
- ]" v-for="(item, index) in timeList" :key="index">
- <view :class="timeIndex === index ? 'current-time' : ''">{{ item.begin }}</view>
- </view>
- </view>
- <view class="appointment-tips" >
- <view> <span></span>
- <text>可预约</text>
- </view>
- <view> <span class="selected"></span>
- <text>已选择</text>
- </view>
- <view> <span class="no-appointment"></span>
- <text>不可约</text>
- </view>
- </view>
- <view class="time-select-bottom" v-if="date!==''&week!==''&time!==''">
- <span>当前选择:</span>{{date}}({{week}}){{time}}
- </view>
- </view>
- </view>
- </block>
- <!-- 确认按钮 -->
- <view class="popup-btn-wrapper">
- <view @tap="confirmTime" class="confirm-btn" style="border-radius: 16rpx;">确定</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- var util = require('@/utils/util.js');
- var api = require('@/config/api.js');
- var check = require('@/utils/check.js');
- export default {
- name: "time-select",
- props: {
- timeParams: Object
- },
- created() {
- console.log("传过来的参数", this.timeParams);
- this.getDayTime(this.timeParams)
- },
- filters: {
- formatDate: function(value, format) {
- // 这里可以根据format来格式化日期
- if (value) {
- return value.substring(0, 10).split('-').slice(1).join('-');
- }
- }
- },
- data() {
- return {
- noonType: 1,
- selectTimeValue: '',
- timeList: [],
- dateList: [],
- timeIndex: '',
- //选中的时间段
- dateIndex: 0,
- //选中的日期
- appointDate: '',
- futureDays: '',
- time: '',
- week: '',
- date: ''
- };
- },
- methods: {
- getDayTime(params) {
- uni.showLoading({
- title: '加载中'
- });
- util.request(api.everyDayTime, params, 'GET')
- .then((res) => {
- uni.hideLoading();
- if (res.errno == 0) {
- console.log("时间", res.data);
- this.setData({
- dateList: res.data,
- dateIndex: 0,
- timeIndex: -1,
- noonType: 1
- });
- let period = res.data[0].period;
- let list = period.filter((item) => {
- return item.ofTime == '上午';
- });
- this.setData({
- timeList: list
- });
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none',
- duration: 2000
- });
- this.setData({
- timeList: [],
- timeIndex: ''
- });
- }
- })
- .catch((err) => {
- console.log(err);
- uni.hideLoading();
- uni.showToast({
- title: err.errMsg,
- icon: 'none'
- });
- this.setData({
- timeList: [],
- timeIndex: ''
- });
- });
- },
- noonTab(e) {
- let noon = e.currentTarget.dataset.noon;
- console.log("noon", noon);
- this.setData({
- timeIndex: -1,
- noonType: noon,
- selectTimeValue: ''
- });
- console.log("noon1", noon);
- let period = this.dateList[this.dateIndex].period;
- let current = this.noonType == 1 ? '上午' : '下午';
- let list = period.filter((item) => {
- return item.ofTime == current;
- });
- this.setData({
- timeList: list
- });
- },
- dateCheck(e) {
- let index = e.currentTarget.dataset.index;
- let date = e.currentTarget.dataset.date;
- let week = e.currentTarget.dataset.week;
- let isbook = e.currentTarget.dataset.isbook;
- this.setData({
- dateIndex: index
- });
- let period = this.dateList[this.dateIndex].period;
- let current = this.noonType == 1 ? '上午' : '下午';
- let list = period.filter((item) => {
- return item.ofTime == current;
- });
- let bookdate = this.dateList[this.dateIndex].bookdate
- let weekOfDay = this.dateList[this.dateIndex].weekOfDay
- this.setData({
- timeList: list,
- date: bookdate,
- week: weekOfDay
- });
- let isNoTime = list.every((item) => {
- return item.timeMsg && item.timeMsg != null;
- });
- if (isNoTime) {
- this.setData({
- timeIndex: -1,
- selectTimeValue: ''
- });
- }
- },
- timeCheck(e) {
- console.log( e.currentTarget);
- let index = e.currentTarget.dataset.index;
- let msg = e.currentTarget.dataset.msg;
- let toastMsg= e.currentTarget.dataset.toastmsg;
- if (msg == null || msg == '') {
- let time = this.timeList[index].begin.split(':')[0];
- let bookTime = this.timeList[index].begin + '-' + this.timeList[index].end
- this.setData({
- timeIndex: index,
- selectTimeValue: Number(time),
- time: bookTime
- });
- }else{
- uni.showToast({
- title:toastMsg,
- icon:'none'
- })
- }
- },
- confirmTime() {
- if (this.timeIndex === '' || this.timeIndex < 0) {
- util.showErrorToast('请选择服务时间');
- return false;
- }
- let date = this.dateList[this.dateIndex].bookdate;
- let week = this.dateList[this.dateIndex].weekOfDay;
- let time = this.timeList[this.timeIndex].begin + '-' + this.timeList[this.timeIndex].end;
- let futureDays = (((new Date(date)).getTime() - (new Date()).getTime()) / (1000 * 24 * 3600));
- futureDays = Math.ceil(futureDays);
- this.setData({
- choosePopup: false,
- appointDate: date + ' ' + week + ' ' + time,
- futureDays: futureDays,
- });
- util.addLog(1, 6, 19, {
- orderId: this.orderId
- });
- this.$emit('timeShow', {
- appointDate: this.appointDate,
- futureDays: this.futureDays,
- Time: {
- date,
- week,
- time
- }
- });
- },
- },
- }
- </script>
- <style>
- .popup-wrapper view {
- color: #888;
- font-size: 30rpx;
- }
- .popup-content {
- flex: 1;
- }
- .appointment-tips {
- display: flex;
- justify-content: space-between;
- width: 178px;
- /* margin: 170px auto 10px; */
- position: absolute;
- bottom: 40px;
- left: calc(50% - 89px);
- }
- .appointment-tips view span {
- width: 20rpx;
- height: 20rpx;
- border-radius: 20rpx;
- background-color: #EDF8FD;
- display: inline-block;
- margin-right: 10rpx;
- }
- .appointment-tips view .selected {
- background-color: #00B4FE;
- }
- .appointment-tips view .no-appointment {
- background-color: #ccc;
- }
- .appointment-tips view text {
- color: #00B4FE;
- font-size: 24rpx;
- }
- .time-select-bottom {
- width: 100vw;
- background-color: #EDF8FD;
- height: 54rpx;
- font-size: 22rpx !important;
- color: #00b4fe !important;
- line-height: 54rpx;
- padding-left: 30rpx;
- position: absolute;
- bottom: 0;
- }
- .time-select-left {
- /* flex: 2; */
- border-right: 1rpx solid #ddd;
- padding: 0 8rpx 0 20rpx;
- width: 370rpx;
- }
- .time-select-right {
- flex: 1;
- /* padding: 0 8rpx; */
- height: 900rpx;
- overflow-y: hidden;
- }
- .scroll-view_H {
- white-space: nowrap;
- /* 确保子元素在同一行内显示 */
- overflow-x: scroll;
- /* 允许横向滚动 */
- }
- .time-select-left-item {
- height: 108rpx;
- display: flex;
- flex-direction: column;
- padding: 4rpx 0;
- width: 20vw;
- }
- .date-line-wrapper {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .time-select-left-item .date-msg {
- height: 36rpx;
- line-height: 36rpx;
- color: #292929;
- font-size: 36rpx;
- font-weight: bold;
- }
- .time-select-left-item .date-msg1 {
- height: 36rpx;
- line-height: 36rpx;
- color: #292929;
- font-size: 22rpx;
- margin-top: 10rpx;
- }
- .time-select-left-item .date-msg.avail-date {
- color: #999 !important;
- font-weight: bold;
- }
- .time-select-left-item .date-msg1.avail-date {
- color: #999 !important;
- font-weight: bold;
- }
- .popup-wrapper .popup-content .current-date {
- color: #09afff;
- font-weight: bold;
- }
- .current-time {
- color: #fff !important;
- font-size: 36rpx;
- font-family: AlibabaPuHuiTi_2_65_Medium;
- }
- view.popup-btn-wrapper {
- margin: 20rpx 0 0;
- padding: 0 24rpx 20rpx;
- }
- view.popup-btn-wrapper button>view {
- color: #fff;
- }
- .time-select-middle {
- background-color: #FCFCFC;
- padding: 10rpx 0rpx;
- height: 700rpx;
- position: relative;
- }
- .noon-select {
- width: 100%;
- display: flex;
- justify-content: center;
- margin: 30rpx auto;
- }
- .noon-select .divider {
- height: 40rpx;
- width: 2rpx;
- background-color: #e5e5e5;
- }
- .noon-select .noon-item {
- text-align: center;
- color: #979797;
- font-size: 36rpx;
- width: 49%;
- }
- .noon-itemactive-noon {
- text-align: center;
- color: #09afff !important;
- font-size: 36rpx !important;
- width: 49%;
- }
- .popup-title-new.popup-title {
- display: flex;
- flex-direction: column;
- font-size: 20px;
- font-weight: bold;
- text-align: left;
- padding-top: 40rpx;
- /* line-height: normal; */
- }
- .popup-title-new view {
- color: #000;
- font-size: 40rpx;
- font-weight: bold;
- }
- .popup-title-new view.fee-tips {
- color: #ff5735;
- font-size: 22rpx;
- }
- .current-line {
- width: 38rpx;
- height: 6rpx;
- background: #09AFFF;
- border-radius: 3rpx;
- margin: auto;
- opacity: 1;
- }
- .current-line0 {
- opacity: 0;
- }
- .current-time {
- color: #fff !important;
- font-family: AlibabaPuHuiTi_2_65_Medium;
- line-height: 70rpx;
- height: 70rpx;
- background-color: #00B4FE;
- border-radius: 8px;
- font-size: 36rpx;
- }
-
-
- .time-item-wrapper {
- display: flex;
- width: 90vw;
- justify-content: flex-start;
- flex-wrap: wrap;
- text-align: center;
- gap: 20px;
- margin: 10px auto;
- }
-
-
- .time-item-wrapper .time-msg {
- width: 20%;
- line-height: 70rpx;
- height: 70rpx;
- background-color: #EDF8FD;
- border-radius: 8px;
- font-size: 36rpx;
- font-weight: bold;
- }
- .time-item-wrapper .avail-time {
- width: 20%;
- line-height: 70rpx;
- height: 70rpx;
- background-color: #CCCCCC;
- border-radius: 8px;
- font-size: 36rpx;
- font-weight: bold;
- }
-
- </style>
|