200 lines
4.7 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: '',
},
/**
* 生命周期函数--监听页面加载
*/
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}`
})
},
// 提交订单
submitCase() {
let _this = this
// 参数校验
if (!_this.data.title) {
// 错误提示
Notify({
type: 'danger',
message: '请输入会议主题!'
});
return;
}
if (_this.data.personNum == '') {
// 错误提示
Notify({
type: 'danger',
message: '请输入参会人数!'
});
return;
}
saveChangyangMeetingRecordRq({
"roomContentId": _this.data.meetingRoomId,
"userId": _this.data.userData.id,
"customerId": _this.data.userData.icsCustomerId,
"title": _this.data.title,
"personNum": _this.data.personNum,
"startTime": _this.data.startTime,
"endDate": _this.data.endTime,
"orderMoney": 0,
"reservationServes" : _this.data.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() {
}
})