297 lines
8.0 KiB
JavaScript
Raw Permalink Normal View History

2024-02-27 12:00:47 +08:00
const app = getApp()
2024-03-05 19:18:13 +08:00
import Dialog from '@vant/weapp/dialog/dialog';
2024-03-05 20:07:13 +08:00
import Notify from '@vant/weapp/notify/notify';
2024-03-05 19:18:13 +08:00
2024-03-04 17:10:32 +08:00
import {
2024-03-05 16:00:04 +08:00
meetingRoomDetailRq,
2024-03-05 19:18:13 +08:00
getCustomerTicketRq,
2024-03-05 20:07:13 +08:00
calculateMeetingRoomAmountRq,
saveMeetingRecordRq
2024-03-04 17:10:32 +08:00
} from "../../../../api/meeting/meetingRoom.js"
2024-03-04 18:00:27 +08:00
import {
selfFormatTimeYMD,
selfFormatTimeHM,
2024-04-10 10:42:06 +08:00
twoTimeInterval,
selfArrSum
2024-03-04 18:00:27 +08:00
} from "../../../../utils/util.js"
2024-02-27 12:00:47 +08:00
Page({
/**
* 页面的初始数据
*/
data: {
IMG_NAME: app.IMG_NAME,
2024-02-27 16:06:54 +08:00
protocolFlag: true,
protocolTitle: '《会议室服务协议》',
2024-03-04 17:10:32 +08:00
meetingRoomId: null,
startTime: null,
endTime: null,
2024-03-04 18:00:27 +08:00
selectDay: null,
selectCountTime: null,
2024-03-04 17:10:32 +08:00
bannerList: [],
room: {},
2024-03-04 18:00:27 +08:00
userData: {},
2024-03-05 16:00:04 +08:00
couponId: '',
2024-03-05 19:18:13 +08:00
couponData: {},
2024-03-05 16:00:04 +08:00
couponList: [],
2024-04-10 10:42:06 +08:00
couponCount: 0,
2024-03-05 16:00:04 +08:00
couponUseList: [],
2024-04-10 10:42:06 +08:00
couponUseCount: 0,
2024-03-05 16:00:04 +08:00
couponNotUseList: [],
2024-04-10 10:42:06 +08:00
couponNotUseCount: 0,
2024-03-05 19:18:13 +08:00
countAmount: '',
totalAmount: '',
2024-03-28 16:26:33 +08:00
priceDialogShow: false,
2024-02-27 12:00:47 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
2024-03-04 14:38:21 +08:00
console.log('onLoad', options);
2024-03-05 16:00:04 +08:00
let selectCountTime = selfFormatTimeHM(options.startTime) + "-" + selfFormatTimeHM(options.endTime) + ' 共计' + twoTimeInterval(options.startTime, options.endTime)
2024-03-04 14:38:21 +08:00
this.setData({
2024-03-04 18:00:27 +08:00
...options,
userData: wx.getStorageSync('user'),
selectDay: selfFormatTimeYMD(options.startTime),
selectCountTime
2024-03-04 14:38:21 +08:00
})
2024-03-04 17:10:32 +08:00
// 详细信息
this.getDetail();
2024-03-05 16:00:04 +08:00
// 获取优惠卷
this.getCustomerTicket();
2024-03-04 17:10:32 +08:00
},
// 详细信息
getDetail() {
let _this = this;
meetingRoomDetailRq(this.data.meetingRoomId).then(res => {
let detail = res.roomContent;
let bannerList = []
if (detail.indoorPicUrl) {
try {
2024-04-10 10:42:06 +08:00
bannerList = JSON.parse(detail.indoorPicUrl).map(item => item.url)
} catch (error) {
console.log(`JSON error : ${error}`);
}
}
2024-03-04 17:10:32 +08:00
_this.setData({
room: detail,
bannerList
2024-03-04 17:10:32 +08:00
})
})
2024-02-27 12:00:47 +08:00
},
2024-03-05 16:00:04 +08:00
// 获取优惠卷
getCustomerTicket() {
let _this = this;
getCustomerTicketRq({
"userId": _this.data.userData.id,
"customerId": _this.data.userData.icsCustomerId,
2024-03-19 15:11:11 +08:00
"meetingId": _this.data.meetingRoomId,
2024-03-05 16:00:04 +08:00
"type": '1'
}).then(res => {
let nowTime = new Date().getTime();
let dataList = res.data.map(item => {
item.startTime = selfFormatTimeYMD(item.startTime)
item.endDate = selfFormatTimeYMD(item.endDate)
let kaishiTime = new Date(item.startTime + " 00:00:00")
let jieshuTime = new Date(item.endDate + " 23:59:59")
if (nowTime >= kaishiTime && nowTime <= jieshuTime) {
item.isDisable = false
} else {
item.isDisable = true
}
return item;
})
// 可用
let useList = res.data.filter(item => !item.isDisable)
// 不可用
let notUseList = res.data.filter(item => item.isDisable)
2024-04-10 10:42:06 +08:00
2024-03-05 16:00:04 +08:00
_this.setData({
couponList: dataList,
2024-04-10 10:42:06 +08:00
couponCount: selfArrSum(dataList.map(item => item.num)),
2024-03-05 16:00:04 +08:00
couponUseList: useList,
2024-04-10 10:42:06 +08:00
couponUseCount: selfArrSum(useList.map(item => item.num)),
2024-03-05 16:00:04 +08:00
couponNotUseList: notUseList,
2024-04-10 10:42:06 +08:00
couponNotUseCount: selfArrSum(notUseList.map(item => item.num)),
2024-03-05 16:00:04 +08:00
})
})
},
2024-04-10 10:42:06 +08:00
2024-03-05 20:07:13 +08:00
// 主题修改监听
titleChange(event) {
this.setData({
title: event.detail
})
},
2024-02-27 17:58:38 +08:00
// 跳转-空间设施
jumpMeetingFacilities() {
2024-03-04 17:10:32 +08:00
let meetingRoomId = this.data.meetingRoomId;
2024-02-27 17:58:38 +08:00
wx.navigateTo({
2024-03-04 17:10:32 +08:00
url: '/pages/meeting/meetingRoom/meetingFacilities/meetingFacilities?meetingRoomId=' + meetingRoomId,
2024-02-27 17:58:38 +08:00
})
},
// 跳转-优惠卷
jumpMeetingCoupon() {
2024-03-05 15:29:46 +08:00
let _this = this;
2024-02-27 17:58:38 +08:00
wx.navigateTo({
2024-03-28 16:26:33 +08:00
url: `/pages/meeting/meetingRoom/meetingCoupon/meetingCoupon?type=1&couponId=${_this.data.couponId}&meetingRoomId=${_this.data.meetingRoomId}`,
2024-02-27 17:58:38 +08:00
})
},
2024-02-27 15:38:56 +08:00
// 协议点击
2024-02-27 16:06:54 +08:00
protocolChange() {
2024-02-27 15:38:56 +08:00
let _this = this;
_this.setData({
protocolFlag: !_this.data.protocolFlag
2024-02-27 16:06:54 +08:00
});
},
// 跳转协议
jumpProtocol() {
let _this = this;
wx.navigateTo({
2024-02-27 17:58:38 +08:00
url: "/pages/meeting/meetingRoom/meetingProtocol/meetingProtocol?title=" + _this.data.protocolTitle,
2024-02-27 16:06:54 +08:00
})
2024-02-27 15:38:56 +08:00
},
2024-03-05 19:18:13 +08:00
// 价格明细
priceDetail() {
2024-03-07 08:54:47 +08:00
let _this = this
2024-03-28 16:26:33 +08:00
_this.setData({
priceDialogShow: true
})
2024-03-05 19:18:13 +08:00
},
2024-02-28 13:41:19 +08:00
// 提交订单
submitCase() {
2024-03-05 20:07:13 +08:00
let _this = this
// 参数校验
if (!_this.data.title) {
// 错误提示
Notify({
type: 'danger',
message: '请输入会议主题!'
});
return;
}
2024-03-07 11:20:58 +08:00
if (!_this.data.protocolFlag) {
// 错误提示
Notify({
type: 'danger',
message: `请同意${_this.data.protocolTitle}!`
});
return;
}
2024-03-05 20:07:13 +08:00
saveMeetingRecordRq({
"roomContentId": _this.data.meetingRoomId,
"userId": _this.data.userData.id,
"ticketId": _this.data.couponId,
"customerId": _this.data.userData.icsCustomerId,
"title": _this.data.title,
"startTime": _this.data.startTime,
"endDate": _this.data.endTime,
"orderMoney": _this.data.totalAmount,
}).then(res => {
console.log('saveMeetingRecordRq', res);
if (res.code == 0) {
2024-03-19 14:42:50 +08:00
// 支付金额大于0需要付款
if (_this.data.totalAmount > 0) {
wx.redirectTo({
url: "/pages/meeting/pay/waitPay/waitPay?id=" + res.reservationId,
})
} else {
wx.reLaunch({
2024-03-28 16:26:33 +08:00
url: '/pages/meeting/reservationRecord/meetingRecord/meetingRecord',
2024-03-19 14:42:50 +08:00
})
}
2024-03-05 20:07:13 +08:00
} else {
// 错误提示
Notify({
type: 'danger',
message: res.msg
});
}
2024-02-28 13:41:19 +08:00
})
},
2024-02-27 12:00:47 +08:00
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
2024-03-05 16:00:04 +08:00
onShow() {
console.log('onShow');
let _this = this
2024-03-05 19:18:13 +08:00
// 更新选择的优惠卷
if (_this.data.couponId) {
2024-03-06 18:35:47 +08:00
let couponData = _this.data.couponList.find(item => item.ticketId == _this.data.couponId)
2024-03-05 16:00:04 +08:00
_this.setData({
couponData
})
}
2024-03-05 19:18:13 +08:00
// 查询金额
calculateMeetingRoomAmountRq({
"startTime": _this.data.startTime,
"endDate": _this.data.endTime,
"roomContentId": _this.data.meetingRoomId,
"ticketId": _this.data.couponId
}).then(res => {
console.log('calculateMeetingRoomAmountRq', res);
_this.setData({
countAmount: res.amount.totalMoney,
totalAmount: res.amount.paidMoney,
})
})
2024-02-27 12:00:47 +08:00
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})