471615499@qq.com 84c9e6f7c4 会议预约功能
修改预约时间,允许设置时间(避免input变化的BUG),修复列表页、添加是无parkId导致查不出数据的BUG;
2024-09-16 23:14:30 +08:00

252 lines
5.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const app = getApp()
import Dialog from '@vant/weapp/dialog/dialog';
import Notify from '@vant/weapp/notify/notify';
import {
meetingRoomDetailRq,
getCustomerTicketRq,
calculateMeetingRoomAmountRq,
saveMeetingRecordRq,
saveChangyangMeetingRecordRq,
meetingRoomBookedRecordRq
} from "../../../../api/meeting/meetingRoom.js"
import {
selfFormatTimeYMD,
selfFormatTimeHM,
twoTimeInterval,
selfArrSum
} from "../../../../utils/util.js"
Page({
/**
* 页面的初始数据
*/
data: {
id: '',
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);
let selectCountTime = selfFormatTimeHM(options.startTime) + "-" + selfFormatTimeHM(options.endTime) + ' 共计' + twoTimeInterval(options.startTime, options.endTime)
this.setData({
...options,
userData: wx.getStorageSync('user'),
selectDay: selfFormatTimeYMD(options.startTime),
selectCountTime
})
// 详细信息
this.getDetail();
},
// 详细信息
getDetail() {
let _this = this;
let _dataId = _this.data.id
if (_dataId === '') {
// 为新增新增的会议室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 {
// 为编辑此时根据id获取信息获取信息后其中有roomId
meetingRoomBookedRecordRq(_dataId).then(res => {
console.log(res)
})
}
},
getRoomInfo(roomId) {
// 获取会议室详情
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}`);
}
}
_this.setData({
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 == '') {
// 错误提示
Notify({
type: 'danger',
message: '请输入预约人!'
});
return;
}
if (_this.data.detail.orderTel == '') {
// 错误提示
Notify({
type: 'danger',
message: '请输入联系方式!'
});
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": _this.data.serviceList,
"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() {
}
})