描述:选择优惠卷

This commit is contained in:
SelfRidicule 2024-03-05 15:04:23 +08:00
parent c19367dd88
commit 1fefce9a97
6 changed files with 118 additions and 30 deletions

View File

@ -44,3 +44,15 @@ export function selectFreeMeetingRoomRq(data) {
data data
}); });
} }
// 获取优惠卷
// "userId":10000,
// "customerId":33,
// "type":1 类型 1.会议室2.展厅
export function getCustomerTicketRq(data) {
return request({
url: '/api/roomContent/getCustomerTicket',
method: "post",
data
});
}

View File

@ -55,9 +55,20 @@ Page({
confirmTime() { confirmTime() {
let _this = this; let _this = this;
let meetingRoomId = _this.data.meetingRoomId; let meetingRoomId = _this.data.meetingRoomId;
let startTime = selfFormatTimeYMDHMS(_this.data.startTime); let startTime = _this.data.startTime;
let endTime = selfFormatTimeYMDHMS(_this.data.endTime); let endTime = _this.data.endTime;
let paramUrl = "?meetingRoomId=" + meetingRoomId + "&startTime=" + startTime + "&endTime=" + endTime; let paramUrl = "?meetingRoomId=" + meetingRoomId + "&startTime=" + selfFormatTimeYMDHMS(startTime) + "&endTime=" + selfFormatTimeYMDHMS(endTime);
// 预约时间必须大于15分钟
if ((1000 * 60 * 15) > (endTime - startTime)) {
Notify({
type: 'danger',
message: '预约时间必须大于15分钟',
duration: 1000,
selector: '#notify',
});
return
}
// 当前会议室是否可以预约 // 当前会议室是否可以预约
selectFreeMeetingRoomRq({ selectFreeMeetingRoomRq({

View File

@ -1,5 +1,13 @@
const app = getApp() const app = getApp()
import {
getCustomerTicketRq
} from "../../../../api/meeting/meetingRoom.js"
import {
selfFormatTimeYMD
} from "../../../../utils/util.js"
Page({ Page({
/** /**
@ -8,28 +16,75 @@ Page({
data: { data: {
IMG_NAME: app.IMG_NAME, IMG_NAME: app.IMG_NAME,
couponId: '', couponId: '',
dataList: [],
userDetail: {}
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
let _this = this;
_this.setData({
...options,
userDetail: wx.getStorageSync('user')
})
// 获取优惠卷
_this.getDataList()
}, },
// 选择优惠卷 // 获取优惠卷
couponChange(event) { getDataList() {
this.setData({ let _this = this;
couponId: event.detail, getCustomerTicketRq({
}); "userId": _this.data.userDetail.id,
"customerId": _this.data.userDetail.icsCustomerId,
"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({
dataList
})
})
}, },
// 点击-选择优惠卷 // 点击-选择优惠卷
couponSelect(e) { couponSelect(e) {
console.log('couponSelect', e); console.log('couponSelect', e);
this.setData({ if (!e.currentTarget.dataset.isdisable) {
couponId: e.currentTarget.dataset.id, this.setData({
}); couponId: e.currentTarget.dataset.id,
});
}
},
// 确定
submit() {
let _this = this;
let pages = getCurrentPages(); //获取page
let prevPage = pages[pages.length - 2]; //上一个页面(父页面)
prevPage.setData({
couponId: _this.couponId
})
wx.navigateBack();
}, },
/** /**

View File

@ -3,26 +3,24 @@
<!-- 优惠卷列表 --> <!-- 优惠卷列表 -->
<view class="couponView"> <view class="couponView">
<van-radio-group value="{{ couponId }}"> <van-radio-group value="{{ couponId }}">
<view class="item" wx:for="{{3}}" wx:for-index="idx" data-id="{{idx}}" bind:tap="couponSelect"> <view class="item" wx:for="{{dataList}}" wx:key="*this" data-id="{{item.id}}" data-isDisable="{{item.isDisable}}" bind:tap="couponSelect">
<view class="imgView"> <view class="imgView">
<view class="img"></view> <image class="img" src="{{IMG_NAME + '/profile/static/meeting/coupon/couponBg.png'}}" mode="aspectFill"></image>
<view class="timeView"> <view class="timeView">
<view class="title">4小时</view> <view class="title">{{item.duration}}小时</view>
<view class="type">抵用券</view> <view class="type">抵用券</view>
</view> </view>
</view> </view>
<view class="contentView"> <view class="contentView">
<view class="title">会议室预约抵用券</view> <view class="title">{{item.ticketName}}</view>
<view class="platform">适用平台: xxx楼</view> <view class="platform">适用平台: {{item.content}}</view>
<view class="validityTime">有效期至: 2024-01-01</view> <view class="validityTime">{{item.startTime}}~{{item.endDate}}</view>
</view> </view>
<van-radio name="{{item.id}}" disabled="{{item.isDisable}}"></van-radio>
<van-radio name="{{idx}}"></van-radio>
</view> </view>
</van-radio-group> </van-radio-group>
</view> </view>
<view class="submitBtn">确认</view> <view class="submitBtn" bind:tap="submit">确认</view>
</view> </view>

View File

@ -16,14 +16,13 @@
.couponView .item .imgView { .couponView .item .imgView {
position: relative; position: relative;
width: 260rpx; width: 257rpx;
height: 260rpx; height: 222rpx;
} }
.couponView .item .imgView .img { .couponView .item .imgView .img {
width: 100%; width: 100%;
height: 100%; height: 100%;
background: red;
} }
.couponView .item .imgView .timeView { .couponView .item .imgView .timeView {
@ -52,6 +51,7 @@
flex: 1; flex: 1;
margin: 0 20rpx; margin: 0 20rpx;
color: gray; color: gray;
word-break: break-all;
} }
.couponView .item .contentView .title { .couponView .item .contentView .title {
@ -59,14 +59,26 @@
font-weight: bold; font-weight: bold;
} }
.couponView .item .contentView .platform, .couponView .item .contentView .platform {
.couponView .item .contentView .validityTime {
margin-top: 20rpx; margin-top: 20rpx;
font-size: 24rpx; font-size: 24rpx;
opacity: 0.6; opacity: 0.6;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
} }
.submitBtn{ .couponView .item .contentView .validityTime {
margin-top: 20rpx;
font-size: 22rpx;
opacity: 0.6;
}
.submitBtn {
box-sizing: border-box; box-sizing: border-box;
position: absolute; position: absolute;
width: 600rpx; width: 600rpx;

View File

@ -68,7 +68,7 @@ Page({
// 跳转-优惠卷 // 跳转-优惠卷
jumpMeetingCoupon() { jumpMeetingCoupon() {
wx.navigateTo({ wx.navigateTo({
url: "/pages/meeting/meetingRoom/meetingCoupon/meetingCoupon", url: "/pages/meeting/meetingRoom/meetingCoupon/meetingCoupon?type=1",
}) })
}, },