diff --git a/miniprogram/api/meeting/meetingRoom.js b/miniprogram/api/meeting/meetingRoom.js index b82b69a..028cb2b 100644 --- a/miniprogram/api/meeting/meetingRoom.js +++ b/miniprogram/api/meeting/meetingRoom.js @@ -34,4 +34,13 @@ export function meetingRoomBookedRecordRq(id) { url: '/api/roomContent/getMeetingRoomRecord/' + id, method: "get", }); +} + +// 当前会议室是否可以预约 +export function selectFreeMeetingRoomRq(data) { + return request({ + url: '/api/roomContent/selectFreeMeetingRoom', + method: "post", + data + }); } \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index b935a26..5375e41 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -1,10 +1,10 @@ App({ APPID: 'wxd9f93ef41a607dd5', // 本地测试时不用加/api - // DOMAIN_NAME: 'http://192.168.0.11:9227', //接口域名 - // IMG_NAME: 'http://192.168.0.11:9227', - DOMAIN_NAME: 'http://222.184.49.22:9227', //接口域名 - IMG_NAME: 'http://222.184.49.22:9227', + DOMAIN_NAME: 'http://192.168.0.11:9227', //接口域名 + IMG_NAME: 'http://192.168.0.11:9227', + // DOMAIN_NAME: 'http://222.184.49.22:9227', //接口域名 + // IMG_NAME: 'http://222.184.49.22:9227', globals: { refreshMyPages: false, homedata: {}, diff --git a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.js b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.js index 8142a57..565eba3 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.js +++ b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.js @@ -1,9 +1,16 @@ const app = getApp() + +import Notify from '@vant/weapp/notify/notify'; + import { - meetingRoomBookedRecordRq + meetingRoomBookedRecordRq, + selectFreeMeetingRoomRq } from "../../../../api/meeting/meetingRoom.js" -import {selfFormatTimeReturnSecond59} from "../../../../utils/util.js" +import { + selfFormatTimeReturnSecond59, + selfFormatTimeYMDHMS +} from "../../../../utils/util.js" Page({ @@ -46,15 +53,35 @@ Page({ // 确认时间 confirmTime() { - let meetingRoomId = this.data.meetingRoomId; - let startTime = this.data.startTime; - let endTime = this.data.endTime; + let _this = this; + let meetingRoomId = _this.data.meetingRoomId; + let startTime = _this.data.startTime; + let endTime = _this.data.endTime; let paramUrl = "?meetingRoomId=" + meetingRoomId + "&startTime=" + startTime + "&endTime=" + endTime; - wx.navigateTo({ - url: "/pages/meeting/meetingRoom/meetingOrder/meetingOrder" + paramUrl, - }) - this.setData({ - showTime: false + + // 当前会议室是否可以预约 + selectFreeMeetingRoomRq({ + "roomContentId": meetingRoomId, + "startTime": selfFormatTimeYMDHMS(startTime), + "endDate": selfFormatTimeYMDHMS(endTime) + }).then(res => { + console.log('selectFreeMeetingRoomRq', res); + // 可以预约 + if (!res.count) { + wx.navigateTo({ + url: "/pages/meeting/meetingRoom/meetingOrder/meetingOrder" + paramUrl, + }) + _this.setData({ + showTime: false + }) + } else { // 不能预约 + Notify({ + type: 'danger', + message: res.msg, + duration: 1000, + selector: '#notify', + }); + } }) }, @@ -83,7 +110,7 @@ Page({ }) }, - + /** * 生命周期函数--监听页面加载 */ diff --git a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.json b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.json index e70bbe5..b97c1d1 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.json +++ b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.json @@ -1,7 +1,8 @@ { "usingComponents": { "van-datetime-picker": "@vant/weapp/datetime-picker/index", - "van-popup": "@vant/weapp/popup/index" + "van-popup": "@vant/weapp/popup/index", + "van-notify": "@vant/weapp/notify/index" }, "navigationBarTitleText": "会议室已预约" } \ No newline at end of file diff --git a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxml b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxml index 655e0b8..cdeecb1 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxml +++ b/miniprogram/pages/meeting/meetingRoom/meetingBooked/meetingBooked.wxml @@ -4,9 +4,9 @@ 会议预约情况 - + {{item.nowDate}} - + {{record.startTime}}~{{record.endDate}} {{record.statusName}} @@ -18,13 +18,12 @@ - + - + + + \ No newline at end of file diff --git a/miniprogram/pages/meeting/meetingRoom/meetingOrder/meetingOrder.wxml b/miniprogram/pages/meeting/meetingRoom/meetingOrder/meetingOrder.wxml index 0eb60d0..cada9f7 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingOrder/meetingOrder.wxml +++ b/miniprogram/pages/meeting/meetingRoom/meetingOrder/meetingOrder.wxml @@ -19,7 +19,7 @@ ¥ 200.00/ - 半小时 起 + 小时 起 diff --git a/miniprogram/utils/util.js b/miniprogram/utils/util.js index f486ff6..02df8d9 100644 --- a/miniprogram/utils/util.js +++ b/miniprogram/utils/util.js @@ -85,6 +85,19 @@ function selfFormatTimeReturnSecond59(time) { return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, '59'].map(formatNumber).join(':') } +//返回 2017-12-12 12:30:59 +function selfFormatTimeYMDHMS(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, minute, second].map(formatNumber).join(':') +} + const formatNumber = n => { n = n.toString() @@ -98,5 +111,6 @@ module.exports = { formatDate2: formatDate2, formatHour: formatHour, formatTime2: formatTime2, - selfFormatTimeReturnSecond59 + selfFormatTimeReturnSecond59, + selfFormatTimeYMDHMS } \ No newline at end of file