148 lines
3.4 KiB
JavaScript
Raw Normal View History

2024-02-27 17:58:38 +08:00
const app = getApp()
2024-03-05 15:04:23 +08:00
import {
getCustomerTicketRq
} from "../../../../api/meeting/meetingRoom.js"
import {
selfFormatTimeYMD
} from "../../../../utils/util.js"
2024-02-27 17:58:38 +08:00
Page({
/**
* 页面的初始数据
*/
data: {
IMG_NAME: app.IMG_NAME,
2024-03-06 18:35:47 +08:00
couponId: null,
2024-03-19 15:04:58 +08:00
meetingRoomId: null,
2024-03-05 15:04:23 +08:00
dataList: [],
userDetail: {}
2024-02-27 17:58:38 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
2024-03-05 15:04:23 +08:00
let _this = this;
2024-03-05 15:29:46 +08:00
console.log('onLoad options', typeof options.couponId);
2024-03-05 15:04:23 +08:00
_this.setData({
2024-03-05 15:29:46 +08:00
type: options.type,
2024-03-19 15:04:58 +08:00
meetingRoomId: options.meetingRoomId,
2024-03-05 15:29:46 +08:00
couponId: parseInt(options.couponId),
2024-03-05 15:04:23 +08:00
userDetail: wx.getStorageSync('user')
})
// 获取优惠卷
_this.getDataList()
2024-02-27 17:58:38 +08:00
},
2024-03-05 15:04:23 +08:00
// 获取优惠卷
getDataList() {
let _this = this;
getCustomerTicketRq({
"userId": _this.data.userDetail.id,
"customerId": _this.data.userDetail.icsCustomerId,
2024-03-19 15:04:58 +08:00
"meetingId" : _this.data.meetingRoomId,
2024-03-05 15:04:23 +08:00
"type": _this.data.type
}).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)
dataList = useList.concat(notUseList)
_this.setData({
2024-03-05 15:29:46 +08:00
dataList,
2024-03-05 15:04:23 +08:00
})
})
2024-02-27 17:58:38 +08:00
},
2024-02-28 09:39:59 +08:00
// 点击-选择优惠卷
couponSelect(e) {
console.log('couponSelect', e);
2024-03-05 16:00:04 +08:00
let _this = this;
2024-03-05 15:04:23 +08:00
if (!e.currentTarget.dataset.isdisable) {
2024-03-05 16:00:04 +08:00
let couponId = e.currentTarget.dataset.id;
if(_this.data.couponId == couponId){
couponId = ''
}
_this.setData({
couponId
2024-03-05 15:04:23 +08:00
});
}
},
// 确定
submit() {
let _this = this;
let pages = getCurrentPages(); //获取page
let prevPage = pages[pages.length - 2]; //上一个页面(父页面)
prevPage.setData({
2024-03-05 15:29:46 +08:00
couponId: _this.data.couponId
2024-03-05 15:04:23 +08:00
})
wx.navigateBack();
2024-02-28 09:39:59 +08:00
},
2024-02-27 17:58:38 +08:00
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})