This commit is contained in:
SelfRidicule 2024-03-05 16:00:04 +08:00
parent a1f0a7ebf0
commit c94f6d0d73
3 changed files with 61 additions and 8 deletions

View File

@ -71,9 +71,14 @@ Page({
// 点击-选择优惠卷
couponSelect(e) {
console.log('couponSelect', e);
let _this = this;
if (!e.currentTarget.dataset.isdisable) {
this.setData({
couponId: e.currentTarget.dataset.id,
let couponId = e.currentTarget.dataset.id;
if(_this.data.couponId == couponId){
couponId = ''
}
_this.setData({
couponId
});
}
},

View File

@ -1,7 +1,8 @@
const app = getApp()
import {
meetingRoomDetailRq
meetingRoomDetailRq,
getCustomerTicketRq
} from "../../../../api/meeting/meetingRoom.js"
import {
@ -29,6 +30,10 @@ Page({
room: {},
userData: {},
couponId: '',
couponData : {},
couponList: [],
couponUseList: [],
couponNotUseList: [],
},
/**
@ -45,6 +50,8 @@ Page({
})
// 详细信息
this.getDetail();
// 获取优惠卷
this.getCustomerTicket();
},
// 详细信息
@ -58,6 +65,39 @@ Page({
})
},
// 获取优惠卷
getCustomerTicket() {
let _this = this;
getCustomerTicketRq({
"userId": _this.data.userData.id,
"customerId": _this.data.userData.icsCustomerId,
"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)
_this.setData({
couponList: dataList,
couponUseList: useList,
couponNotUseList: notUseList,
})
})
},
// 跳转-空间设施
jumpMeetingFacilities() {
let meetingRoomId = this.data.meetingRoomId;
@ -107,8 +147,16 @@ Page({
/**
* 生命周期函数--监听页面显示
*/
onShow(options) {
console.log('onShow' , options);
onShow() {
console.log('onShow');
let _this = this
_this.data.couponData
if(_this.data.couponId){
let couponData = _this.data.couponList.find(item=> item.id == _this.data.couponId)
_this.setData({
couponData
})
}
},
/**

View File

@ -56,7 +56,7 @@
<view class="itemView" bind:tap="jumpMeetingCoupon">
<view class="label">优惠券</view>
<view class="content">
<view class="coupon">5张可用</view>
<view class="coupon">{{couponId? couponData.ticketName : couponUseList.length + '张可用' + '(共计'+ couponList.length +'张)'}}</view>
<van-icon name="arrow" size="44rpx"/>
</view>
</view>