2024-09-03 14:28:29 +08:00

212 lines
5.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
} from "../../../../api/meeting/meetingRoom.js"
import {
selfFormatTimeYMD,
selfFormatTimeHM,
twoTimeInterval,
selfArrSum
} from "../../../../utils/util.js"
Page({
/**
* 页面的初始数据
*/
data: {
IMG_NAME: app.IMG_NAME,
meetingRoomId: null,
startTime: null,
endTime: null,
selectDay: null,
selectCountTime: null,
bannerList: [],
room: {},
userData: {},
serviceList: [],
title: '',
personNum: '',
reservationPersonList: [],
},
/**
* 生命周期函数--监听页面加载
*/
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;
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[name] = value
this.setData({
...data
})
},
// 跳转-空间设施
jumpMeetingFacilities() {
let meetingRoomId = this.data.meetingRoomId;
let startTime = this.data.startTime;
let serviceListJsonStr = JSON.stringify(this.data.serviceList)
wx.navigateTo({
url: `/pages/meeting/meetingRoom/meetingService/meetingService?meetingRoomId=${meetingRoomId}&serviceList=${serviceListJsonStr}&startTime=${startTime}`
})
},
// 跳转-人员列表
jumpMeetingPerson() {
let ids = JSON.stringify(this.data.reservationPersonList.map(item => item.id))
wx.navigateTo({
url: `/pages/meeting/meetingRoom/meetingPerson/meetingPerson?pageType=add&ids=${ids}`
})
},
// 提交订单
submitCase() {
let _this = this
// 参数校验
// 主题
if (!_this.data.title) {
app.vantNotifyErr(Notify, '请输入会议主题!')
return;
}
// 参会人数
if (!_this.data.personNum) {
app.vantNotifyErr(Notify, '请输入参会人数!')
return;
}
// 参会人员
let reservationPersonList = _this.data.reservationPersonList.map(item => {
return {
userId: item.id
}
})
// 过滤选择的服务
let serviceList = _this.data.serviceList.filter(item => item.isSelect)
saveChangyangMeetingRecordRq({
"roomContentId": _this.data.meetingRoomId,
"userId": _this.data.userData.id,
"customerId": _this.data.userData.icsCustomerId,
"title": _this.data.title,
"personNum": _this.data.personNum,
reservationPersonList,
"startTime": _this.data.startTime,
"endDate": _this.data.endTime,
"orderMoney": 0,
"reservationServes": serviceList,
}).then(res => {
console.log('saveMeetingRecordRq', res);
if (res.code == 0) {
wx.reLaunch({
url: '/pages/meeting/pay/waitComplete/waitComplete',
})
} else {
// 错误提示
Notify({
type: 'danger',
message: res.msg
});
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
console.log('onShow');
let _this = this
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})