mirror of
https://gitee.com/elegant_wings/dbd-meeting-wx-small.git
synced 2025-06-21 23:39:36 +08:00
332 lines
8.2 KiB
JavaScript
332 lines
8.2 KiB
JavaScript
const app = getApp()
|
||
|
||
import Dialog from '@vant/weapp/dialog/dialog';
|
||
import Notify from '@vant/weapp/notify/notify';
|
||
|
||
import {
|
||
meetingRoomDetailRq,
|
||
getCustomerTicketRq,
|
||
calculateMeetingRoomAmountRq,
|
||
saveMeetingRecordRq,
|
||
saveChangyangMeetingRecordRq,
|
||
selectReservationByIdRq
|
||
} from "../../../../api/meeting/meetingRoom.js"
|
||
|
||
import {
|
||
selfFormatTimeYMD,
|
||
selfFormatTimeHM,
|
||
twoTimeInterval,
|
||
selfArrSum
|
||
} from "../../../../utils/util.js"
|
||
|
||
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
rId: '',
|
||
IMG_NAME: app.IMG_NAME,
|
||
detail: {},
|
||
meetingRoomId: null,
|
||
startTime: null,
|
||
endTime: null,
|
||
selectDay: null,
|
||
selectCountTime: null,
|
||
bannerList: [],
|
||
room: {},
|
||
userData: {},
|
||
serviceList: [],
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
onLoad(options) {
|
||
console.log('onLoad', options);
|
||
this.setData({
|
||
...options,
|
||
userData: wx.getStorageSync('user'),
|
||
// selectDay: selfFormatTimeYMD(options.startTime),
|
||
// selectCountTime,
|
||
})
|
||
if (options.startTime && options.endTime) {
|
||
this.getTimeDetail(options.startTime, options.endTime)
|
||
}
|
||
// 详细信息
|
||
this.getDetail();
|
||
},
|
||
/**
|
||
* 计算并填充时间细节
|
||
* @param {*} sTime 开始时间 2024-09-18 09:04:00
|
||
* @param {*} eTime 结束时间 2024-09-18 10:04:00
|
||
*/
|
||
getTimeDetail(sTime, eTime) {
|
||
let selectCountTime = selfFormatTimeHM(sTime) + "-" + selfFormatTimeHM(eTime) + ' 共计' + twoTimeInterval(sTime, eTime)
|
||
this.setData({
|
||
selectDay: selfFormatTimeYMD(sTime),
|
||
selectCountTime,
|
||
})
|
||
},
|
||
// 详细信息
|
||
getDetail() {
|
||
let _this = this;
|
||
let _dataId = _this.data.rId
|
||
if (_dataId === '') {
|
||
console.log('新增预约')
|
||
// 为新增,新增的会议室id是传来的
|
||
let _meetingRoomId = _this.data.meetingRoomId
|
||
_this.getRoomInfo(_meetingRoomId)
|
||
_this.setData({
|
||
detail: {
|
||
orderUser: _this.data.userData.username,
|
||
orderTel: _this.data.userData.mobile,
|
||
title: '',
|
||
personNum: '',
|
||
leader: '',
|
||
depName: '',
|
||
remark: ''
|
||
}
|
||
})
|
||
} else {
|
||
// 为编辑,编辑有两种情况,一是重新选择会议室和时间,另一种是编辑基本信息
|
||
// 1. 无时间和会议室id,此时根据id获取信息,获取信息后其中有roomId
|
||
// 2. 有时间和会议室id,此时根据会议室id获取会议室信息即可
|
||
let _meetingRoomId = _this.data.meetingRoomId
|
||
if (_meetingRoomId !== null) {
|
||
_this.getRoomInfo(_meetingRoomId)
|
||
}
|
||
selectReservationByIdRq(_dataId).then(res => {
|
||
console.log('编辑,获取信息', res)
|
||
if (_meetingRoomId === null) {
|
||
_meetingRoomId = res.data.roomContentId
|
||
_this.setData({
|
||
meetingRoomId: _meetingRoomId,
|
||
startTime: res.data.startTime,
|
||
endTime: res.data.endDate
|
||
})
|
||
let serviceId = []
|
||
for (let key in res.data.reservationServes) {
|
||
let eachObj = res.data.reservationServes[key]
|
||
serviceId.push(eachObj.serveId)
|
||
}
|
||
_this.getRoomInfo(_meetingRoomId, serviceId)
|
||
// 计算日期和时间
|
||
_this.getTimeDetail(res.data.startTime, res.data.endDate)
|
||
}
|
||
_this.setData({
|
||
detail: {
|
||
orderUser: res.data.orderUser,
|
||
orderTel: res.data.orderTel,
|
||
title: res.data.title,
|
||
personNum: res.data.personNum,
|
||
leader: res.data.leader,
|
||
depName: res.data.depName,
|
||
remark: res.data.remark,
|
||
}
|
||
})
|
||
})
|
||
}
|
||
},
|
||
/**
|
||
* 获取会议室基本信息
|
||
* @param {*} roomId 会议室id
|
||
* @param {*} serveId 提供服务id,用于编辑时默认勾选
|
||
*/
|
||
getRoomInfo(roomId, serveId) {
|
||
serveId = serveId || []
|
||
// 获取会议室详情
|
||
let _this = this
|
||
meetingRoomDetailRq(this.data.meetingRoomId).then(res => {
|
||
let detail = res.roomContent;
|
||
let bannerList = []
|
||
if (detail.indoorPicUrl) {
|
||
try {
|
||
bannerList = JSON.parse(detail.indoorPicUrl).map(item => item.url)
|
||
} catch (error) {
|
||
console.log(`JSON error : ${error}`);
|
||
}
|
||
}
|
||
// 提前处理服务,不需要进入页面后获取
|
||
let serviceList = detail.roomServeList.map(item => {
|
||
let isSel = false
|
||
if (serveId.includes(item.id)) {
|
||
isSel = true
|
||
}
|
||
return {
|
||
serveId: item.id,
|
||
serveName: item.serveName,
|
||
isSelect: isSel,
|
||
num: '',
|
||
type: 'free'
|
||
}
|
||
})
|
||
_this.setData({
|
||
serviceList: serviceList,
|
||
room: detail,
|
||
bannerList
|
||
})
|
||
})
|
||
},
|
||
|
||
// input修改监听
|
||
inputChange(e) {
|
||
console.log('input change', e);
|
||
let _this = this
|
||
let name = e.currentTarget.dataset.name
|
||
let value = e.detail
|
||
let data = _this.data
|
||
data['detail'][name] = value
|
||
this.setData({
|
||
...data
|
||
})
|
||
},
|
||
|
||
// 跳转-空间设施
|
||
jumpMeetingFacilities() {
|
||
let meetingRoomId = this.data.meetingRoomId;
|
||
let serviceListJsonStr = JSON.stringify(this.data.serviceList)
|
||
wx.navigateTo({
|
||
url: `/pages/meeting/meetingRoom/meetingService/meetingService?meetingRoomId=${meetingRoomId}&serviceList=${serviceListJsonStr}`
|
||
})
|
||
},
|
||
|
||
// 提交订单
|
||
submitCase() {
|
||
let _this = this
|
||
// 参数校验
|
||
if (!_this.data.detail.title) {
|
||
// 错误提示
|
||
Notify({
|
||
type: 'danger',
|
||
message: '请输入会议名称!'
|
||
});
|
||
return;
|
||
}
|
||
if (_this.data.detail.personNum == '') {
|
||
// 错误提示
|
||
Notify({
|
||
type: 'danger',
|
||
message: '请输入参会人数!'
|
||
});
|
||
return;
|
||
}
|
||
// if (_this.data.detail.orderName == '') {
|
||
// // 错误提示
|
||
// Notify({
|
||
// type: 'danger',
|
||
// message: '无队名单位!'
|
||
// });
|
||
// return;
|
||
// }
|
||
if (!_this.data.detail.orderUser || _this.data.detail.orderUser === '') {
|
||
// 错误提示
|
||
Notify({
|
||
type: 'danger',
|
||
message: '请输入预约人!'
|
||
});
|
||
return
|
||
}
|
||
if (!_this.data.detail.orderUser || _this.data.detail.orderTel == '') {
|
||
// 错误提示
|
||
Notify({
|
||
type: 'danger',
|
||
message: '请输入联系方式!'
|
||
});
|
||
return;
|
||
}
|
||
// 处理一下serviceList
|
||
let service = []
|
||
let serviceList = _this.data.serviceList
|
||
// console.log(serviceList)
|
||
for (let key in serviceList) {
|
||
let eachObj = serviceList[key]
|
||
console.log(eachObj)
|
||
if (eachObj.isSelect === true) {
|
||
service.push(eachObj)
|
||
}
|
||
}
|
||
// console.log(service)
|
||
// return
|
||
saveChangyangMeetingRecordRq({
|
||
"roomContentId": _this.data.meetingRoomId,
|
||
"userId": _this.data.userData.id,
|
||
"customerId": _this.data.userData.icsCustomerId,
|
||
"title": _this.data.detail.title,
|
||
"personNum": _this.data.detail.personNum,
|
||
"startTime": _this.data.startTime,
|
||
"endDate": _this.data.endTime,
|
||
"orderMoney": 0,
|
||
"reservationServes": service,
|
||
"remark": _this.data.detail.remark,
|
||
"orderUser": _this.data.detail.orderUser,
|
||
"orderTel": _this.data.detail.orderTel,
|
||
"parkId": 25, // 写死,园区ID
|
||
}).then(res => {
|
||
console.log('saveMeetingRecordRq', res);
|
||
if (res.code == 0) {
|
||
wx.reLaunch({
|
||
url: '/pages/meeting/pay/waitComplete/waitComplete?id=' + res.reservationId,
|
||
})
|
||
} else {
|
||
// 错误提示
|
||
Notify({
|
||
type: 'danger',
|
||
message: res.msg
|
||
});
|
||
}
|
||
})
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow() {
|
||
console.log('onShow');
|
||
let _this = this
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage() {
|
||
|
||
}
|
||
}) |