From 3d21c09f5cb2f7b29049eb4c30dec73a294d2371 Mon Sep 17 00:00:00 2001 From: SelfRidicule Date: Tue, 5 Mar 2024 17:40:50 +0800 Subject: [PATCH] 1 --- .../meetingBooked/meetingBooked.js | 34 ++++++++++++++----- .../meetingBooked/meetingBooked.wxml | 13 +++++-- .../meetingBooked/meetingBooked.wxss | 17 +++++++++- miniprogram/utils/util.js | 15 ++++++++ 4 files changed, 68 insertions(+), 11 deletions(-) diff --git a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.js b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.js index dd41d62..0b9aa4d 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.js +++ b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.js @@ -9,7 +9,8 @@ import { import { selfFormatTimeReturnSecond59, - selfFormatTimeYMDHMS + selfFormatTimeYMDHMS, + selfFormatTimeYMDH } from "../../../../utils/util.js" Page({ @@ -19,13 +20,19 @@ Page({ */ data: { meetingRoomId: null, - minTime: new Date().getTime(), + minTime: null, maxTime: null, endMaxTime: null, - startTime: new Date().getTime(), + startTime: null, endTime: null, showTime: false, dataList: [], + filterTime(type, options) { + if (type === 'minute') { + return options.filter((option) => option == '00'); + } + return options; + }, }, // 选择-开始时间 @@ -40,7 +47,7 @@ Page({ onInputEndTime(event) { let _this = this; this.setData({ - endTime: new Date(selfFormatTimeReturnSecond59(event.detail)).getTime(), + endTime: event.detail, }); }, @@ -59,15 +66,15 @@ Page({ let endTime = _this.data.endTime; let paramUrl = "?meetingRoomId=" + meetingRoomId + "&startTime=" + selfFormatTimeYMDHMS(startTime) + "&endTime=" + selfFormatTimeYMDHMS(endTime); - // 预约时间必须大于15分钟 - if ((1000 * 60 * 15) > (endTime - startTime)) { + // 预约时间不能小于1小时 + if ((1000 * 60 * 60) > (endTime - startTime)) { Notify({ type: 'danger', - message: '预约时间必须大于15分钟', + message: '预约时间不能小于1小时', duration: 1000, selector: '#notify', }); - return + return } // 当前会议室是否可以预约 @@ -111,6 +118,17 @@ Page({ maxTime: maxTime.getTime() }) this.setEndMaxTime(this.data.startTime) + // 设置最小时间 + this.setMinTime() + }, + + // 设置最小时间 + setMinTime() { + let minTime = new Date(selfFormatTimeYMDH(new Date()) + ':00:00').getTime() + this.setData({ + minTime, + startTime: minTime + }) }, // 指定天的最后一秒 diff --git a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxml b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxml index cdeecb1..7e631b7 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxml +++ b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxml @@ -18,9 +18,18 @@ - + + 请选择开始时间 + + - + + 请选择结束时间 + 确定 + + diff --git a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxss b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxss index 6348574..95d54c4 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxss +++ b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxss @@ -59,4 +59,19 @@ top: 0; background: #ffffff; transition: 1s all; -} \ No newline at end of file +} + +.selfPop .labelView{ + box-sizing: border-box; + padding: 20rpx 34rpx 20rpx 20rpx; + background: #f5f7fa; + display: flex; + justify-content: space-between; + align-items: center; +} + +.selfPop .labelView .enter{ + font-size: 32rpx; + font-weight: bold; + color: #4e96f8; +} diff --git a/miniprogram/utils/util.js b/miniprogram/utils/util.js index f2eee38..a0adb6e 100644 --- a/miniprogram/utils/util.js +++ b/miniprogram/utils/util.js @@ -98,6 +98,20 @@ function selfFormatTimeYMDHMS(time) { return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':') } + +//返回 2017-12-12 12 +function selfFormatTimeYMDH(time) { + let date = new Date(time); + let year = date.getFullYear() + let month = date.getMonth() + 1 + let day = date.getDate() + let hour = date.getHours() + let minute = date.getMinutes() + let second = date.getSeconds() + + return [year, month, day].map(formatNumber).join('-') + ' ' + [hour].map(formatNumber).join(':') +} + //返回 例 2017-12-12 function selfFormatTimeYMD(time) { let date = new Date(time) @@ -171,5 +185,6 @@ module.exports = { selfFormatTimeYMDHMS, selfFormatTimeYMD, selfFormatTimeHM, + selfFormatTimeYMDH, twoTimeInterval } \ No newline at end of file