225 lines
5.5 KiB
JavaScript
Raw Normal View History

2024-03-04 14:38:21 +08:00
const app = getApp()
2024-03-04 16:37:45 +08:00
import Notify from '@vant/weapp/notify/notify';
2024-03-04 14:38:21 +08:00
import {
2024-03-04 16:37:45 +08:00
meetingRoomBookedRecordRq,
selectFreeMeetingRoomRq
2024-03-04 14:38:21 +08:00
} from "../../../../api/meeting/meetingRoom.js"
2024-03-04 16:37:45 +08:00
import {
selfFormatTimeReturnSecond59,
2024-03-05 17:40:50 +08:00
selfFormatTimeYMDHMS,
selfFormatTimeYMDH
2024-03-04 16:37:45 +08:00
} from "../../../../utils/util.js"
2024-03-04 15:49:05 +08:00
2024-03-02 18:14:38 +08:00
Page({
/**
* 页面的初始数据
*/
data: {
2024-03-28 09:32:11 +08:00
IMG_NAME: app.IMG_NAME,
2024-03-04 14:38:21 +08:00
meetingRoomId: null,
2024-03-05 17:40:50 +08:00
minTime: null,
2024-03-04 14:38:21 +08:00
maxTime: null,
endMaxTime: null,
2024-03-05 17:40:50 +08:00
startTime: null,
2024-03-04 14:38:21 +08:00
endTime: null,
showTime: false,
dataList: [],
2024-03-05 17:40:50 +08:00
filterTime(type, options) {
if (type === 'minute') {
return options.filter((option) => (parseInt(option) % 10) == 0);
}
2024-03-05 17:40:50 +08:00
return options;
},
2024-03-02 18:14:38 +08:00
},
2024-03-04 14:38:21 +08:00
// 选择-开始时间
onInputStartTime(event) {
this.setData({
startTime: event.detail,
});
this.setEndMaxTime(event.detail)
},
2024-03-02 18:14:38 +08:00
2024-03-04 14:38:21 +08:00
// 选择-结束时间
onInputEndTime(event) {
let _this = this;
2024-03-02 18:14:38 +08:00
this.setData({
2024-03-05 17:40:50 +08:00
endTime: event.detail,
2024-03-02 18:14:38 +08:00
});
},
2024-03-04 14:38:21 +08:00
// 预约时间
reservationTime() {
this.setData({
showTime: true
})
},
// 确认时间
confirmTime() {
2024-03-04 16:37:45 +08:00
let _this = this;
let meetingRoomId = _this.data.meetingRoomId;
2024-03-05 15:04:23 +08:00
let startTime = _this.data.startTime;
let endTime = _this.data.endTime;
let paramUrl = "?meetingRoomId=" + meetingRoomId + "&startTime=" + selfFormatTimeYMDHMS(startTime) + "&endTime=" + selfFormatTimeYMDHMS(endTime);
// 预约时间不能小于10分钟
if ((1000 * 60 * 10) > (endTime - startTime)) {
Notify({
type: 'danger',
message: '预约时间不能小于10分钟',
duration: 1000,
selector: '#notify',
});
return
}
2024-03-04 16:37:45 +08:00
// 当前会议室是否可以预约
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',
});
}
2024-03-04 14:38:21 +08:00
})
},
// 取消时间
cancelTime() {
this.setData({
showTime: false
2024-03-02 18:14:38 +08:00
})
},
2024-03-04 14:38:21 +08:00
// 初始化时间
initParamTime() {
let maxTime = new Date();
maxTime.setFullYear(maxTime.getFullYear() + 3)
this.setData({
maxTime: maxTime.getTime()
})
this.setEndMaxTime(this.data.startTime)
2024-03-05 17:40:50 +08:00
// 设置最小时间
this.setMinTime()
},
// 设置最小时间
setMinTime() {
let minTime = new Date(selfFormatTimeYMDHMS(new Date()).substring(0,15) + '0:00').getTime()
// let minTime = new Date().getTime()
2024-03-05 17:40:50 +08:00
this.setData({
minTime,
startTime: minTime
})
2024-03-04 14:38:21 +08:00
},
// 指定天的最后一秒
setEndMaxTime(time) {
let endMaxTime = new Date(new Date(time).toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1;
this.setData({
endMaxTime: endMaxTime
})
},
2024-03-04 16:37:45 +08:00
2024-03-02 18:14:38 +08:00
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
2024-03-04 14:38:21 +08:00
console.log('onLoad', options);
// 获取传递参数
this.setData({
...options
})
// 初始化时间
this.initParamTime()
2024-03-02 18:14:38 +08:00
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
2024-03-04 14:38:21 +08:00
console.log('onShow', 111);
let _this = this;
meetingRoomBookedRecordRq(this.data.meetingRoomId).then(res => {
console.log('meetingRoomBookedRecordRq', res);
let dataList = res.data;
dataList.map(item => {
item.nowDate = item.nowDate.substring(0, 10);
item.reservations = item.reservations.map(record => {
record.startTime = record.startTime.substring(11)
record.endDate = record.endDate.substring(11)
// record.userName = record.userName.substring(0,1) + "某"
// record.phone = record.phone.substring(0,3) + "****" + record.phone.substring(7,record.phone.length)
2024-03-04 14:38:21 +08:00
return record;
})
return item
})
_this.setData({
dataList
})
})
2024-03-02 18:14:38 +08:00
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})