描述:优惠券选择

This commit is contained in:
SelfRidicule 2024-04-10 10:42:06 +08:00
parent a036458531
commit 6034fb6e76
5 changed files with 31 additions and 8 deletions

View File

@ -18,7 +18,8 @@ Page({
couponId: null, couponId: null,
meetingRoomId: null, meetingRoomId: null,
dataList: [], dataList: [],
userDetail: {} userDetail: {},
parkName : wx.getStorageSync('parkName')
}, },
/** /**
@ -54,8 +55,10 @@ Page({
let jieshuTime = new Date(item.endDate + " 23:59:59") let jieshuTime = new Date(item.endDate + " 23:59:59")
if (nowTime >= kaishiTime && nowTime <= jieshuTime) { if (nowTime >= kaishiTime && nowTime <= jieshuTime) {
item.isDisable = false item.isDisable = false
item.bgUrl = '/profile/static/meeting/coupon/couponBg.png'
} else { } else {
item.isDisable = true item.isDisable = true
item.bgUrl = '/profile/static/meeting/coupon/couponBgDisabled.png'
} }
return item; return item;
}) })

View File

@ -5,7 +5,7 @@
<van-radio-group value="{{ couponId }}"> <van-radio-group value="{{ couponId }}">
<view class="item" wx:for="{{dataList}}" wx:key="*this" data-id="{{item.ticketId}}" data-isDisable="{{item.isDisable}}" bind:tap="couponSelect"> <view class="item" wx:for="{{dataList}}" wx:key="*this" data-id="{{item.ticketId}}" data-isDisable="{{item.isDisable}}" bind:tap="couponSelect">
<view class="imgView"> <view class="imgView">
<image class="img" src="{{IMG_NAME + '/profile/static/meeting/coupon/couponBg.png'}}" mode="aspectFill"></image> <image class="img" src="{{IMG_NAME + item.bgUrl}}" mode="aspectFill"></image>
<view class="timeView"> <view class="timeView">
<view class="title" wx:if="{{item.type == 1}}">{{item.duration}}小时</view> <view class="title" wx:if="{{item.type == 1}}">{{item.duration}}小时</view>
<view class="type" wx:if="{{item.type == 1}}">抵用券</view> <view class="type" wx:if="{{item.type == 1}}">抵用券</view>
@ -14,9 +14,10 @@
</view> </view>
</view> </view>
<view class="contentView"> <view class="contentView">
<view class="title">{{item.ticketName}}</view> <view class="title">{{item.ticketName}} x {{item.num}}张</view>
<view class="platform">适用平台: {{item.content}}</view> <view class="platform">{{parkName}}</view>
<view class="validityTime">{{item.startTime}}~{{item.endDate}}</view> <view class="validityTime">{{item.startTime}}~{{item.endDate}}</view>
<view class="validityTime">单次可用一张</view>
</view> </view>
<van-radio name="{{item.ticketId}}" disabled="{{item.isDisable}}"></van-radio> <van-radio name="{{item.ticketId}}" disabled="{{item.isDisable}}"></van-radio>
</view> </view>

View File

@ -13,7 +13,8 @@ import {
import { import {
selfFormatTimeYMD, selfFormatTimeYMD,
selfFormatTimeHM, selfFormatTimeHM,
twoTimeInterval twoTimeInterval,
selfArrSum
} from "../../../../utils/util.js" } from "../../../../utils/util.js"
@ -37,8 +38,11 @@ Page({
couponId: '', couponId: '',
couponData: {}, couponData: {},
couponList: [], couponList: [],
couponCount: 0,
couponUseList: [], couponUseList: [],
couponUseCount: 0,
couponNotUseList: [], couponNotUseList: [],
couponNotUseCount: 0,
countAmount: '', countAmount: '',
totalAmount: '', totalAmount: '',
priceDialogShow: false, priceDialogShow: false,
@ -70,7 +74,7 @@ Page({
let bannerList = [] let bannerList = []
if (detail.indoorPicUrl) { if (detail.indoorPicUrl) {
try { try {
bannerList = JSON.parse(detail.indoorPicUrl).map(item=>item.url) bannerList = JSON.parse(detail.indoorPicUrl).map(item => item.url)
} catch (error) { } catch (error) {
console.log(`JSON error : ${error}`); console.log(`JSON error : ${error}`);
} }
@ -108,14 +112,19 @@ Page({
let useList = res.data.filter(item => !item.isDisable) let useList = res.data.filter(item => !item.isDisable)
// 不可用 // 不可用
let notUseList = res.data.filter(item => item.isDisable) let notUseList = res.data.filter(item => item.isDisable)
_this.setData({ _this.setData({
couponList: dataList, couponList: dataList,
couponCount: selfArrSum(dataList.map(item => item.num)),
couponUseList: useList, couponUseList: useList,
couponUseCount: selfArrSum(useList.map(item => item.num)),
couponNotUseList: notUseList, couponNotUseList: notUseList,
couponNotUseCount: selfArrSum(notUseList.map(item => item.num)),
}) })
}) })
}, },
// 主题修改监听 // 主题修改监听
titleChange(event) { titleChange(event) {
this.setData({ this.setData({

View File

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

View File

@ -206,6 +206,15 @@ const formatNumber = n => {
return n[1] ? n : '0' + n return n[1] ? n : '0' + n
} }
// 数组sum合计
function selfArrSum(list) {
let count = 0;
list.map(item => {
count = count + item
})
return count
}
module.exports = { module.exports = {
formatTime: formatTime, formatTime: formatTime,
formatDate: formatDate, formatDate: formatDate,
@ -220,5 +229,6 @@ module.exports = {
selfFormatTimeHM, selfFormatTimeHM,
selfFormatTimeYMDH, selfFormatTimeYMDH,
twoTimeInterval, twoTimeInterval,
twoTimeIntervalReturnHours twoTimeIntervalReturnHours,
selfArrSum
} }