Commit 4666370ddefa8f045d88ba3dc1a6873406333004

Authored by pengye
1 parent f47ab502

邀请函、商家有礼、商家详情,付款页券的活动日期、有效期调整

Showing 31 changed files with 856 additions and 114 deletions
... ... @@ -188,6 +188,8 @@ Page({
list.forEach(detail => {
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if (detail.arule) {
detail.accumulationShow = detail.arule.is_accumulation
}
... ... @@ -204,32 +206,40 @@ Page({
}
detail.checked = false;
detail.showCpupon = '0';
let cdateText = ''; //有效期开始时间(如果领取当天可用,领取之日, 否则就是次日)
let edateText = ''; //有效期截止时间(领取日期+领取后几天有效的日期)
let date = new Date(detail.cdate * 1000);
if (detail.arule.is_same_day != '1') {
date.setTime(date.getTime() + 24 * 60 * 60 * 1000); // 加一天的毫秒数
// 获取使用券的有效期
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = condition.stime;
detail.useEtime = condition.etime;
}
date.setHours(0, 0, 0, 0);
let newTimestamp = Math.floor(date.getTime() / 1000);
cdateText = util.unixtoTime(newTimestamp, 'YYYY-MM-DD')
detail.cdateText = cdateText;
if (detail.aexpiration == '0' || detail.aexpiration == '') {
edateText = util.unixtoTime(detail.etime, 'YYYY-MM-DD')
detail.deadlineDate = detail.etime
} else {
let time = new Date(detail.cdate * 1000);
time.setTime(time.getTime() + parseInt(detail.aexpiration) * 24 * 60 * 60 * 1000); // 加上有效期天数的毫秒数
time.setHours(23, 59, 0, 0);
let deadlineDate = Math.floor(time.getTime() / 1000);
detail.deadlineDate = deadlineDate
edateText = util.unixtoTime(deadlineDate, 'YYYY-MM-DD')
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if((detail.useStime>0 && detail.useEtime>0) || condition.valid_forever === '1') {
detail.endDateStr = condition.valid_forever == '1' ? '永久有效' : (util.unixtoTime(detail.useStime, 'YYYY-MM-DD') + '至' + util.unixtoTime(detail.useEtime, 'YYYY-MM-DD'));
}
detail.endDateStr = cdateText + '至' + edateText
})
// 筛选出当前时间 > 领取日期+领取后几天有效的日期
list = list.filter(item => {
return this.data.dataStr < (item.deadlineDate * 1)
return (this.data.dataStr < (item.useEtime * 1) || item.aexpiration.valid_forever == '1');
})
list.sort((a, b) => {
return (a.etime * 1) - (b.etime * 1)
... ... @@ -451,26 +461,13 @@ Page({
console.log('当前餐段、是不是法定节假日', {
...obj
});
const isTimestampInRange = (startTimestamp, endTimestamp) => {
const currentTimestamp = Math.floor(Date.now() / 1000);
return currentTimestamp >= startTimestamp && currentTimestamp <= endTimestamp;
};
list.forEach(coupon => {
const couponDate = new Date(coupon.cdate * 1000);
const startUseDate = new Date(couponDate);
const endUseDate = new Date(couponDate);
if (coupon.arule.is_same_day) {
startUseDate.setTime(couponDate.getTime() - 24 * 60 * 60 * 1000); // 前一天
} else {
startUseDate.setTime(couponDate.getTime()); // 直接设置为 couponDate 的时间
}
// 券领取天数为0或者为空 默认券可使用最晚时间是券有效期截止时间
if (coupon.aexpiration == '0' || coupon.aexpiration == '') {
let date = new Date(coupon.etime * 1000);
endUseDate.setTime(date.getTime());
} else {
endUseDate.setTime(couponDate.getTime() + parseInt(coupon.aexpiration) * 24 * 60 * 60 * 1000); // 加上有效期天数
}
endUseDate.setHours(23, 59, 59, 999);
// 今天不是领取当日,但在有效天数内 && 今天是领取当日且可用
const isUseDate = (currentDate > startUseDate && currentDate < endUseDate);
// 判断当前时间在不在 券的有效期内
const isUseDate = isTimestampInRange(coupon.useStime, coupon.useEtime);
let selectedValue = true;
let str = true
if (coupon.exp_date && coupon.exp_date.week_data && coupon.exp_date.week_data.length > 0) {
... ... @@ -511,8 +508,7 @@ Page({
if ((str && !selectedValue) || (!str && selectedValue)) {
availableDate = false
}
coupon.isOk = isUseDate && (availableDate || coupon.exp_date.week_show == '无') ? '1' : '0'; //是否在可用时间内 1可使用 2不可使用
coupon.expirationDate = coupon.deadlineDate;
coupon.isOk = (isUseDate || coupon.aexpiration.valid_forever == '1') && (availableDate || coupon.exp_date.week_show == '无') ? '1' : '0'; //是否在可用时间内 1可使用 2不可使用
});
return list;
},
... ... @@ -602,9 +598,9 @@ Page({
console.log(`两者的优惠值相同: ${maxStackableValue}`);
let copiedList1 = JSON.parse(JSON.stringify(list1));
let copiedList2 = JSON.parse(JSON.stringify(list2));
let minList1 = copiedList1.length > 0 ? Math.min(...copiedList1.map(item => item.expirationDate)) : Infinity;
let minList2 = copiedList2.length > 0 ? Math.min(...copiedList2.map(item => item.expirationDate)) : Infinity;
// 判断最小的 expirationDate 是在 list1 还是 list2
let minList1 = copiedList1.length > 0 ? Math.min(...copiedList1.map(item => item.useEtime)) : Infinity;
let minList2 = copiedList2.length > 0 ? Math.min(...copiedList2.map(item => item.useEtime)) : Infinity;
// 判断最小的 useEtime 是在 list1 还是 list2
if (minList1 <= minList2) {
console.log('最小的在 list1 中', list1);
finalList = list1
... ... @@ -640,6 +636,17 @@ Page({
finalList, // 返回可叠加和不可叠加的优惠券组合
};
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
let useStime = startDate.getTime() / 1000
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
let useEtime = endDate.getTime() / 1000
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -135,6 +135,35 @@ Page({
let detail = res.data[0];
let exp_date = util.determine(detail.exp_date);
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today)-1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow*1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday)-1) : (parseInt(condition.eday)+1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday)-1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (exp_date && exp_date.week_data) {
let mor = this.hasConsecutiveSelect(exp_date.week_data, '1').rArr.join('、')
let noon = this.hasConsecutiveSelect(exp_date.week_data, '2').rArr.join('、')
... ... @@ -224,6 +253,20 @@ Page({
phoneNumber: this.data.seller.phone
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate * 1 + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate * 1 + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return {
useStime,
useEtime
};
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -900,6 +900,8 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let detail = res.data[0]
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
... ... @@ -945,7 +947,35 @@ Page({
detail.noonText = noon;
detail.nigText = nig;
}
detail.showCoupon = (this.data.dataStr < (detail.etime * 1) && detail.is_open == '1') ? '1' : '0';
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
let data = detail.expiration_date;
detail.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && detail.is_open == '1') ? '1' : '0';
this.getDetailFun(detail)
}
})
... ... @@ -973,14 +1003,18 @@ Page({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1142,8 +1176,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1153,6 +1215,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -100,6 +100,8 @@
<view wx:if="{{item.is_type == '4' && item.desc}}" class="limitation showDesc">
<text class="font24r">消费要求</text>
</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="limitation showDesc font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="font24r nodate showDesc">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.is_type == '3' && (item.morText || item.noonText || item.nigText)}}" class="limitation showDesc">
<text class="font24r">不可用日期</text>
</view>
... ... @@ -186,6 +188,8 @@
<view wx:if="{{couponData.is_type == '4' && couponData.desc}}" class="limitation showDesc">
<text class="font24r">消费要求</text>
</view>
<view wx:if="{{(couponData.useStime && couponData.useEtime) || couponData.foreverText}}" class="limitation showDesc font24r">有效期:{{couponData.foreverText?couponData.foreverText : ''}}</view>
<view wx:if="{{couponData.useStime && couponData.useEtime}}" class="font24r nodate showDesc">{{couponData.useStime}} 至 {{couponData.useEtime}}</view>
<view wx:if="{{couponData.is_type == '3' && (couponData.morText || couponData.noonText || couponData.nigText)}}" class="limitation showDesc">
<text class="font24r">不可用日期</text>
</view>
... ...
... ... @@ -270,6 +270,10 @@
align-items: center;
}
.certificateInfo .nodate{
padding-left: 20rpx;
}
.certificateInfo .limitation {
line-height: 40rpx;
}
... ... @@ -407,6 +411,7 @@
.couponBoxWrap .showDesc {
display: flex;
align-items: center;
color: #666;
}
.bottomLimitation {
... ...
... ... @@ -941,6 +941,8 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let detail = res.data[0]
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
... ... @@ -986,7 +988,35 @@ Page({
detail.noonText = noon;
detail.nigText = nig;
}
detail.showCoupon = (this.data.dataStr < (detail.etime * 1) && detail.is_open == '1') ? '1' : '0';
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
let data = detail.expiration_date;
detail.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && detail.is_open == '1') ? '1' : '0';
let entry = this.data.titleList
if ((!this.data.is_user_comments && this.data.isComments == '1' && detail.showCoupon == '1') || (this.data.is_comments == '1' && (this.data.marketing.is_comments_coupon != '1' || detail.showCoupon != '1'))) {
entry.push({
... ... @@ -1028,14 +1058,18 @@ Page({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1211,8 +1245,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1222,6 +1284,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -137,6 +137,8 @@
<view wx:if="{{item.is_type == '4' && item.desc}}" class="limitation showDesc">
<text class="font24r">消费要求</text>
</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="limitation showDesc font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="font24r nodate showDesc">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.is_type == '3' && (item.morText || item.noonText || item.nigText)}}" class="limitation showDesc">
<text class="font24r">不可用日期</text>
</view>
... ... @@ -229,6 +231,8 @@
<view wx:if="{{couponData.is_type == '4' && couponData.desc}}" class="limitation showDesc">
<text class="font24r">消费要求</text>
</view>
<view wx:if="{{(couponData.useStime && couponData.useEtime) || couponData.foreverText}}" class="limitation showDesc font24r">有效期:{{couponData.foreverText?couponData.foreverText : ''}}</view>
<view wx:if="{{couponData.useStime && couponData.useEtime}}" class="font24r nodate showDesc">{{couponData.useStime}} 至 {{couponData.useEtime}}</view>
<view wx:if="{{couponData.is_type == '3' && (couponData.morText || couponData.noonText || couponData.nigText)}}" class="limitation showDesc">
<text class="font24r">不可用日期</text>
</view>
... ...
... ... @@ -274,6 +274,10 @@
background: #efefef;
}
.preferentialCoupon .nodate{
padding-left: 20rpx;
}
.preferentialCoupon .limitation {
display: flex;
flex-direction: column;
... ...
... ... @@ -956,6 +956,8 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let detail = res.data[0]
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
... ... @@ -1001,7 +1003,35 @@ Page({
detail.noonText = noon;
detail.nigText = nig;
}
detail.showCoupon = (this.data.dataStr < (detail.etime * 1) && detail.is_open == '1') ? '1' : '0';
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
let data = detail.expiration_date;
detail.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && detail.is_open == '1') ? '1' : '0';
let entry = this.data.titleList
if ((!this.data.is_user_comments && this.data.isComments == '1' && detail.showCoupon == '1') || (this.data.is_comments == '1' && (this.data.marketing.is_comments_coupon != '1' || detail.showCoupon != '1'))) {
entry.push({
... ... @@ -1043,14 +1073,18 @@ Page({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1226,8 +1260,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1237,6 +1299,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -181,6 +181,8 @@
<view wx:if="{{item.is_type == '4' && item.desc}}" class="limitation showDesc">
<text class="font24r">消费要求</text>
</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="limitation showDesc font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="font24r nodate showDesc">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.is_type == '3' && (item.morText || item.noonText || item.nigText)}}" class="limitation showDesc">
<text class="font24r">不可用日期</text>
</view>
... ... @@ -267,6 +269,8 @@
<view wx:if="{{couponData.is_type == '4' && couponData.desc}}" class="limitation showDesc">
<text class="font24r">消费要求</text>
</view>
<view wx:if="{{(couponData.useStime && couponData.useEtime) || couponData.foreverText}}" class="limitation showDesc font24r">有效期:{{couponData.foreverText?couponData.foreverText : ''}}</view>
<view wx:if="{{couponData.useStime && couponData.useEtime}}" class="font24r nodate showDesc">{{couponData.useStime}} 至 {{couponData.useEtime}}</view>
<view wx:if="{{couponData.is_type == '3' && (couponData.morText || couponData.noonText || couponData.nigText)}}" class="limitation showDesc">
<text class="font24r">不可用日期</text>
</view>
... ...
... ... @@ -312,6 +312,10 @@
width: 100%;
}
.preferentialCoupon .nodate{
padding-left: 20rpx;
}
.preferentialCoupon .limitation {
color: #000;
}
... ...
... ... @@ -930,8 +930,9 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let couponData = res.data[0]
let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : '';
// showCoupon 代表赠送的券没过有效期 && 是开启状态
couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0';
couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0';
console.log('邀请函--------------------评价赠送的优惠券',couponData);
this.setData({
couponData:res.data[0]
... ... @@ -944,15 +945,19 @@ Page({
App.Activity.GetActivityById({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1114,8 +1119,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1125,6 +1158,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -110,7 +110,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...
... ... @@ -885,8 +885,9 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let couponData = res.data[0]
let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : '';
// showCoupon 代表赠送的券没过有效期 && 是开启状态
couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0';
couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0';
console.log('邀请函--------------------评价赠送的优惠券',couponData);
this.setData({
couponData:res.data[0]
... ... @@ -899,15 +900,19 @@ Page({
App.Activity.GetActivityById({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1069,8 +1074,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1080,6 +1113,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -116,7 +116,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...
... ... @@ -886,8 +886,9 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let couponData = res.data[0]
let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : '';
// showCoupon 代表赠送的券没过有效期 && 是开启状态
couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0';
couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0';
console.log('邀请函--------------------评价赠送的优惠券',couponData);
this.setData({
couponData:res.data[0]
... ... @@ -900,15 +901,19 @@ Page({
App.Activity.GetActivityById({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1070,8 +1075,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1081,6 +1114,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -99,7 +99,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...
... ... @@ -884,8 +884,9 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let couponData = res.data[0]
let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : '';
// showCoupon 代表赠送的券没过有效期 && 是开启状态
couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0';
couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0';
console.log('邀请函--------------------评价赠送的优惠券',couponData);
this.setData({
couponData:res.data[0]
... ... @@ -898,15 +899,19 @@ Page({
App.Activity.GetActivityById({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1068,8 +1073,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1079,6 +1112,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -97,7 +97,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...
... ... @@ -841,8 +841,9 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let couponData = res.data[0]
let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : '';
// showCoupon 代表赠送的券没过有效期 && 是开启状态
couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0';
couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0';
console.log('邀请函--------------------评价赠送的优惠券',couponData);
this.setData({
couponData:res.data[0]
... ... @@ -855,15 +856,19 @@ Page({
App.Activity.GetActivityById({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1025,8 +1030,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1036,6 +1069,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -119,7 +119,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...
... ... @@ -885,8 +885,9 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let couponData = res.data[0]
let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : '';
// showCoupon 代表赠送的券没过有效期 && 是开启状态
couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0';
couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0';
console.log('邀请函--------------------评价赠送的优惠券',couponData);
this.setData({
couponData:res.data[0]
... ... @@ -899,15 +900,19 @@ Page({
App.Activity.GetActivityById({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1069,8 +1074,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1080,6 +1113,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -112,7 +112,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...
... ... @@ -884,8 +884,9 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let couponData = res.data[0]
let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : '';
// showCoupon 代表赠送的券没过有效期 && 是开启状态
couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0';
couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0';
console.log('邀请函--------------------评价赠送的优惠券',couponData);
this.setData({
couponData:res.data[0]
... ... @@ -899,14 +900,18 @@ Page({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1068,8 +1073,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1079,6 +1112,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -109,7 +109,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...
... ... @@ -918,8 +918,9 @@ Page({
}).then(res => {
if (res.data.length > 0) {
let couponData = res.data[0]
let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : '';
// showCoupon 代表赠送的券没过有效期 && 是开启状态
couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0';
couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0';
console.log('邀请函--------------------评价赠送的优惠券',couponData);
this.setData({
couponData:res.data[0]
... ... @@ -933,14 +934,18 @@ Page({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -1102,8 +1107,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -1113,6 +1146,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -114,7 +114,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...
... ... @@ -210,15 +210,19 @@ Page({
App.Activity.GetActivityById({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -294,8 +298,36 @@ Page({
}, []);
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
this.setData({
... ... @@ -322,6 +354,17 @@ Page({
}
return couponList
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -30,7 +30,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...
... ... @@ -244,15 +244,19 @@ Page({
App.Activity.GetActivityById({
id: obj.map(item => item.id).join(','),
}).then(res => {
if (res.data.length > 0) {
if (res.data.length > 0) {
// valid_forever 1永久 0非永久
let list = res.data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
let data = item.expiration_date ? util.determine(item.expiration_date) : '';
return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1'
})
list.forEach(detail => {
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
detail.use = detail.use ? util.determine(detail.use) : '';
detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
let cash = detail.use.cash * 1;
let price = detail.price * 1;
... ... @@ -414,8 +418,36 @@ Page({
}
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx!== null && idx!== undefined && coupon_dataList[idx]) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
if (idx !== null && idx !== undefined && coupon_dataList[idx]) {
const detail = coupon_dataList[idx];
detail.resultCoupon = '1'; // 显示已领取
detail.cdate = detail.cdate * 1;
detail.useStime = '';
detail.useEtime = '';
let condition = detail.aexpiration
if (condition.valid_forever === '0' && condition.stime && condition.etime) {
detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD');
detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD');
}
if (condition.valid_forever === '1') {
detail.foreverText = '永久有效';
}
if (condition.valid_forever === '0' && condition.today) {
let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.tomorrow) {
let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
if (condition.valid_forever === '0' && condition.sday && condition.eday) {
let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1)
let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday);
detail.useStime = obj.useStime;
detail.useEtime = obj.useEtime;
}
}
})
console.log('未领取的券列表-----------', couponArr);
... ... @@ -425,6 +457,17 @@ Page({
}
})
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD');
const endDate = new Date((cdate + endOffset * 86400) * 1000);
endDate.setHours(23, 59, 59, 0);
const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD');
return { useStime, useEtime };
},
// 处理优惠券不可用日期数据
hasConsecutiveSelect(arr, type) {
let firstTitle = null;
... ...
... ... @@ -45,7 +45,8 @@
</view>
</block>
<block wx:if="{{item.is_type == '3' || item.is_type == '4'}}">
<view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view>
<view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view>
<view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view>
<view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view>
<view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view>
<view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view>
... ...