Showing
31 changed files
with
856 additions
and
114 deletions
| @@ -188,6 +188,8 @@ Page({ | @@ -188,6 +188,8 @@ Page({ | ||
| 188 | list.forEach(detail => { | 188 | list.forEach(detail => { |
| 189 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 189 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 190 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 190 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 191 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 192 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 191 | if (detail.arule) { | 193 | if (detail.arule) { |
| 192 | detail.accumulationShow = detail.arule.is_accumulation | 194 | detail.accumulationShow = detail.arule.is_accumulation |
| 193 | } | 195 | } |
| @@ -204,32 +206,40 @@ Page({ | @@ -204,32 +206,40 @@ Page({ | ||
| 204 | } | 206 | } |
| 205 | detail.checked = false; | 207 | detail.checked = false; |
| 206 | detail.showCpupon = '0'; | 208 | detail.showCpupon = '0'; |
| 207 | - let cdateText = ''; //有效期开始时间(如果领取当天可用,领取之日, 否则就是次日) | ||
| 208 | - let edateText = ''; //有效期截止时间(领取日期+领取后几天有效的日期) | ||
| 209 | - let date = new Date(detail.cdate * 1000); | ||
| 210 | - if (detail.arule.is_same_day != '1') { | ||
| 211 | - date.setTime(date.getTime() + 24 * 60 * 60 * 1000); // 加一天的毫秒数 | 209 | + // 获取使用券的有效期 |
| 210 | + detail.cdate = detail.cdate * 1; | ||
| 211 | + detail.useStime = ''; | ||
| 212 | + detail.useEtime = ''; | ||
| 213 | + let condition = detail.aexpiration | ||
| 214 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 215 | + detail.useStime = condition.stime; | ||
| 216 | + detail.useEtime = condition.etime; | ||
| 212 | } | 217 | } |
| 213 | - date.setHours(0, 0, 0, 0); | ||
| 214 | - let newTimestamp = Math.floor(date.getTime() / 1000); | ||
| 215 | - cdateText = util.unixtoTime(newTimestamp, 'YYYY-MM-DD') | ||
| 216 | - detail.cdateText = cdateText; | ||
| 217 | - if (detail.aexpiration == '0' || detail.aexpiration == '') { | ||
| 218 | - edateText = util.unixtoTime(detail.etime, 'YYYY-MM-DD') | ||
| 219 | - detail.deadlineDate = detail.etime | ||
| 220 | - } else { | ||
| 221 | - let time = new Date(detail.cdate * 1000); | ||
| 222 | - time.setTime(time.getTime() + parseInt(detail.aexpiration) * 24 * 60 * 60 * 1000); // 加上有效期天数的毫秒数 | ||
| 223 | - time.setHours(23, 59, 0, 0); | ||
| 224 | - let deadlineDate = Math.floor(time.getTime() / 1000); | ||
| 225 | - detail.deadlineDate = deadlineDate | ||
| 226 | - edateText = util.unixtoTime(deadlineDate, 'YYYY-MM-DD') | 218 | + if (condition.valid_forever === '1') { |
| 219 | + detail.foreverText = '永久有效'; | ||
| 220 | + } | ||
| 221 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 222 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 223 | + detail.useStime = obj.useStime; | ||
| 224 | + detail.useEtime = obj.useEtime; | ||
| 225 | + } | ||
| 226 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 227 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 228 | + detail.useStime = obj.useStime; | ||
| 229 | + detail.useEtime = obj.useEtime; | ||
| 230 | + } | ||
| 231 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 232 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 233 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 234 | + detail.useStime = obj.useStime; | ||
| 235 | + detail.useEtime = obj.useEtime; | ||
| 236 | + } | ||
| 237 | + if((detail.useStime>0 && detail.useEtime>0) || condition.valid_forever === '1') { | ||
| 238 | + detail.endDateStr = condition.valid_forever == '1' ? '永久有效' : (util.unixtoTime(detail.useStime, 'YYYY-MM-DD') + '至' + util.unixtoTime(detail.useEtime, 'YYYY-MM-DD')); | ||
| 227 | } | 239 | } |
| 228 | - detail.endDateStr = cdateText + '至' + edateText | ||
| 229 | }) | 240 | }) |
| 230 | - // 筛选出当前时间 > 领取日期+领取后几天有效的日期 | ||
| 231 | list = list.filter(item => { | 241 | list = list.filter(item => { |
| 232 | - return this.data.dataStr < (item.deadlineDate * 1) | 242 | + return (this.data.dataStr < (item.useEtime * 1) || item.aexpiration.valid_forever == '1'); |
| 233 | }) | 243 | }) |
| 234 | list.sort((a, b) => { | 244 | list.sort((a, b) => { |
| 235 | return (a.etime * 1) - (b.etime * 1) | 245 | return (a.etime * 1) - (b.etime * 1) |
| @@ -451,26 +461,13 @@ Page({ | @@ -451,26 +461,13 @@ Page({ | ||
| 451 | console.log('当前餐段、是不是法定节假日', { | 461 | console.log('当前餐段、是不是法定节假日', { |
| 452 | ...obj | 462 | ...obj |
| 453 | }); | 463 | }); |
| 464 | + const isTimestampInRange = (startTimestamp, endTimestamp) => { | ||
| 465 | + const currentTimestamp = Math.floor(Date.now() / 1000); | ||
| 466 | + return currentTimestamp >= startTimestamp && currentTimestamp <= endTimestamp; | ||
| 467 | + }; | ||
| 454 | list.forEach(coupon => { | 468 | list.forEach(coupon => { |
| 455 | - const couponDate = new Date(coupon.cdate * 1000); | ||
| 456 | - const startUseDate = new Date(couponDate); | ||
| 457 | - const endUseDate = new Date(couponDate); | ||
| 458 | - if (coupon.arule.is_same_day) { | ||
| 459 | - startUseDate.setTime(couponDate.getTime() - 24 * 60 * 60 * 1000); // 前一天 | ||
| 460 | - } else { | ||
| 461 | - startUseDate.setTime(couponDate.getTime()); // 直接设置为 couponDate 的时间 | ||
| 462 | - } | ||
| 463 | - | ||
| 464 | - // 券领取天数为0或者为空 默认券可使用最晚时间是券有效期截止时间 | ||
| 465 | - if (coupon.aexpiration == '0' || coupon.aexpiration == '') { | ||
| 466 | - let date = new Date(coupon.etime * 1000); | ||
| 467 | - endUseDate.setTime(date.getTime()); | ||
| 468 | - } else { | ||
| 469 | - endUseDate.setTime(couponDate.getTime() + parseInt(coupon.aexpiration) * 24 * 60 * 60 * 1000); // 加上有效期天数 | ||
| 470 | - } | ||
| 471 | - endUseDate.setHours(23, 59, 59, 999); | ||
| 472 | - // 今天不是领取当日,但在有效天数内 && 今天是领取当日且可用 | ||
| 473 | - const isUseDate = (currentDate > startUseDate && currentDate < endUseDate); | 469 | + // 判断当前时间在不在 券的有效期内 |
| 470 | + const isUseDate = isTimestampInRange(coupon.useStime, coupon.useEtime); | ||
| 474 | let selectedValue = true; | 471 | let selectedValue = true; |
| 475 | let str = true | 472 | let str = true |
| 476 | if (coupon.exp_date && coupon.exp_date.week_data && coupon.exp_date.week_data.length > 0) { | 473 | if (coupon.exp_date && coupon.exp_date.week_data && coupon.exp_date.week_data.length > 0) { |
| @@ -511,8 +508,7 @@ Page({ | @@ -511,8 +508,7 @@ Page({ | ||
| 511 | if ((str && !selectedValue) || (!str && selectedValue)) { | 508 | if ((str && !selectedValue) || (!str && selectedValue)) { |
| 512 | availableDate = false | 509 | availableDate = false |
| 513 | } | 510 | } |
| 514 | - coupon.isOk = isUseDate && (availableDate || coupon.exp_date.week_show == '无') ? '1' : '0'; //是否在可用时间内 1可使用 2不可使用 | ||
| 515 | - coupon.expirationDate = coupon.deadlineDate; | 511 | + coupon.isOk = (isUseDate || coupon.aexpiration.valid_forever == '1') && (availableDate || coupon.exp_date.week_show == '无') ? '1' : '0'; //是否在可用时间内 1可使用 2不可使用 |
| 516 | }); | 512 | }); |
| 517 | return list; | 513 | return list; |
| 518 | }, | 514 | }, |
| @@ -602,9 +598,9 @@ Page({ | @@ -602,9 +598,9 @@ Page({ | ||
| 602 | console.log(`两者的优惠值相同: ${maxStackableValue}`); | 598 | console.log(`两者的优惠值相同: ${maxStackableValue}`); |
| 603 | let copiedList1 = JSON.parse(JSON.stringify(list1)); | 599 | let copiedList1 = JSON.parse(JSON.stringify(list1)); |
| 604 | let copiedList2 = JSON.parse(JSON.stringify(list2)); | 600 | let copiedList2 = JSON.parse(JSON.stringify(list2)); |
| 605 | - let minList1 = copiedList1.length > 0 ? Math.min(...copiedList1.map(item => item.expirationDate)) : Infinity; | ||
| 606 | - let minList2 = copiedList2.length > 0 ? Math.min(...copiedList2.map(item => item.expirationDate)) : Infinity; | ||
| 607 | - // 判断最小的 expirationDate 是在 list1 还是 list2 | 601 | + let minList1 = copiedList1.length > 0 ? Math.min(...copiedList1.map(item => item.useEtime)) : Infinity; |
| 602 | + let minList2 = copiedList2.length > 0 ? Math.min(...copiedList2.map(item => item.useEtime)) : Infinity; | ||
| 603 | + // 判断最小的 useEtime 是在 list1 还是 list2 | ||
| 608 | if (minList1 <= minList2) { | 604 | if (minList1 <= minList2) { |
| 609 | console.log('最小的在 list1 中', list1); | 605 | console.log('最小的在 list1 中', list1); |
| 610 | finalList = list1 | 606 | finalList = list1 |
| @@ -640,6 +636,17 @@ Page({ | @@ -640,6 +636,17 @@ Page({ | ||
| 640 | finalList, // 返回可叠加和不可叠加的优惠券组合 | 636 | finalList, // 返回可叠加和不可叠加的优惠券组合 |
| 641 | }; | 637 | }; |
| 642 | }, | 638 | }, |
| 639 | + // 计算免费券有效期的起始、结束日期 | ||
| 640 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 641 | + console.log(cdate, startOffset, endOffset); | ||
| 642 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 643 | + startDate.setHours(0, 0, 0, 0); | ||
| 644 | + let useStime = startDate.getTime() / 1000 | ||
| 645 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 646 | + endDate.setHours(23, 59, 59, 0); | ||
| 647 | + let useEtime = endDate.getTime() / 1000 | ||
| 648 | + return { useStime, useEtime }; | ||
| 649 | + }, | ||
| 643 | // 处理优惠券不可用日期数据 | 650 | // 处理优惠券不可用日期数据 |
| 644 | hasConsecutiveSelect(arr, type) { | 651 | hasConsecutiveSelect(arr, type) { |
| 645 | let firstTitle = null; | 652 | let firstTitle = null; |
| @@ -135,6 +135,35 @@ Page({ | @@ -135,6 +135,35 @@ Page({ | ||
| 135 | let detail = res.data[0]; | 135 | let detail = res.data[0]; |
| 136 | let exp_date = util.determine(detail.exp_date); | 136 | let exp_date = util.determine(detail.exp_date); |
| 137 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 137 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 138 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 139 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 140 | + detail.cdate = detail.cdate * 1; | ||
| 141 | + detail.useStime = ''; | ||
| 142 | + detail.useEtime = ''; | ||
| 143 | + let condition = detail.aexpiration | ||
| 144 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 145 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 146 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 147 | + } | ||
| 148 | + if (condition.valid_forever === '1') { | ||
| 149 | + detail.foreverText = '永久有效'; | ||
| 150 | + } | ||
| 151 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 152 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today)-1); | ||
| 153 | + detail.useStime = obj.useStime; | ||
| 154 | + detail.useEtime = obj.useEtime; | ||
| 155 | + } | ||
| 156 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 157 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow*1); | ||
| 158 | + detail.useStime = obj.useStime; | ||
| 159 | + detail.useEtime = obj.useEtime; | ||
| 160 | + } | ||
| 161 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 162 | + let eday = condition.sday == '1' ? (parseInt(condition.eday)-1) : (parseInt(condition.eday)+1) | ||
| 163 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday)-1, eday); | ||
| 164 | + detail.useStime = obj.useStime; | ||
| 165 | + detail.useEtime = obj.useEtime; | ||
| 166 | + } | ||
| 138 | if (exp_date && exp_date.week_data) { | 167 | if (exp_date && exp_date.week_data) { |
| 139 | let mor = this.hasConsecutiveSelect(exp_date.week_data, '1').rArr.join('、') | 168 | let mor = this.hasConsecutiveSelect(exp_date.week_data, '1').rArr.join('、') |
| 140 | let noon = this.hasConsecutiveSelect(exp_date.week_data, '2').rArr.join('、') | 169 | let noon = this.hasConsecutiveSelect(exp_date.week_data, '2').rArr.join('、') |
| @@ -224,6 +253,20 @@ Page({ | @@ -224,6 +253,20 @@ Page({ | ||
| 224 | phoneNumber: this.data.seller.phone | 253 | phoneNumber: this.data.seller.phone |
| 225 | }) | 254 | }) |
| 226 | }, | 255 | }, |
| 256 | + // 计算免费券有效期的起始、结束日期 | ||
| 257 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 258 | + console.log(cdate, startOffset, endOffset); | ||
| 259 | + const startDate = new Date((cdate * 1 + startOffset * 86400) * 1000); | ||
| 260 | + startDate.setHours(0, 0, 0, 0); | ||
| 261 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 262 | + const endDate = new Date((cdate * 1 + endOffset * 86400) * 1000); | ||
| 263 | + endDate.setHours(23, 59, 59, 0); | ||
| 264 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 265 | + return { | ||
| 266 | + useStime, | ||
| 267 | + useEtime | ||
| 268 | + }; | ||
| 269 | + }, | ||
| 227 | // 处理优惠券不可用日期数据 | 270 | // 处理优惠券不可用日期数据 |
| 228 | hasConsecutiveSelect(arr, type) { | 271 | hasConsecutiveSelect(arr, type) { |
| 229 | let firstTitle = null; | 272 | let firstTitle = null; |
| @@ -900,6 +900,8 @@ Page({ | @@ -900,6 +900,8 @@ Page({ | ||
| 900 | }).then(res => { | 900 | }).then(res => { |
| 901 | if (res.data.length > 0) { | 901 | if (res.data.length > 0) { |
| 902 | let detail = res.data[0] | 902 | let detail = res.data[0] |
| 903 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 904 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 903 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 905 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 904 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 906 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 905 | detail.use = detail.use ? util.determine(detail.use) : ''; | 907 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| @@ -945,7 +947,35 @@ Page({ | @@ -945,7 +947,35 @@ Page({ | ||
| 945 | detail.noonText = noon; | 947 | detail.noonText = noon; |
| 946 | detail.nigText = nig; | 948 | detail.nigText = nig; |
| 947 | } | 949 | } |
| 948 | - detail.showCoupon = (this.data.dataStr < (detail.etime * 1) && detail.is_open == '1') ? '1' : '0'; | 950 | + detail.cdate = detail.cdate * 1; |
| 951 | + detail.useStime = ''; | ||
| 952 | + detail.useEtime = ''; | ||
| 953 | + let condition = detail.aexpiration | ||
| 954 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 955 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 956 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 957 | + } | ||
| 958 | + if (condition.valid_forever === '1') { | ||
| 959 | + detail.foreverText = '永久有效'; | ||
| 960 | + } | ||
| 961 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 962 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 963 | + detail.useStime = obj.useStime; | ||
| 964 | + detail.useEtime = obj.useEtime; | ||
| 965 | + } | ||
| 966 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 967 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 968 | + detail.useStime = obj.useStime; | ||
| 969 | + detail.useEtime = obj.useEtime; | ||
| 970 | + } | ||
| 971 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 972 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 973 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 974 | + detail.useStime = obj.useStime; | ||
| 975 | + detail.useEtime = obj.useEtime; | ||
| 976 | + } | ||
| 977 | + let data = detail.expiration_date; | ||
| 978 | + detail.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && detail.is_open == '1') ? '1' : '0'; | ||
| 949 | this.getDetailFun(detail) | 979 | this.getDetailFun(detail) |
| 950 | } | 980 | } |
| 951 | }) | 981 | }) |
| @@ -973,14 +1003,18 @@ Page({ | @@ -973,14 +1003,18 @@ Page({ | ||
| 973 | id: obj.map(item => item.id).join(','), | 1003 | id: obj.map(item => item.id).join(','), |
| 974 | }).then(res => { | 1004 | }).then(res => { |
| 975 | if (res.data.length > 0) { | 1005 | if (res.data.length > 0) { |
| 1006 | + // valid_forever 1永久 0非永久 | ||
| 976 | let list = res.data.filter(item => { | 1007 | let list = res.data.filter(item => { |
| 977 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 1008 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 1009 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 978 | }) | 1010 | }) |
| 979 | list.forEach(detail => { | 1011 | list.forEach(detail => { |
| 980 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 1012 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 981 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 1013 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 982 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 1014 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 983 | detail.use = detail.use ? util.determine(detail.use) : ''; | 1015 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 1016 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 1017 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 984 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 1018 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 985 | let cash = detail.use.cash * 1; | 1019 | let cash = detail.use.cash * 1; |
| 986 | let price = detail.price * 1; | 1020 | let price = detail.price * 1; |
| @@ -1142,8 +1176,36 @@ Page({ | @@ -1142,8 +1176,36 @@ Page({ | ||
| 1142 | } | 1176 | } |
| 1143 | list.forEach(item=>{ | 1177 | list.forEach(item=>{ |
| 1144 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1178 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1145 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1146 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1179 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1180 | + const detail = coupon_dataList[idx]; | ||
| 1181 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1182 | + detail.cdate = detail.cdate * 1; | ||
| 1183 | + detail.useStime = ''; | ||
| 1184 | + detail.useEtime = ''; | ||
| 1185 | + let condition = detail.aexpiration | ||
| 1186 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1187 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1188 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1189 | + } | ||
| 1190 | + if (condition.valid_forever === '1') { | ||
| 1191 | + detail.foreverText = '永久有效'; | ||
| 1192 | + } | ||
| 1193 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1194 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1195 | + detail.useStime = obj.useStime; | ||
| 1196 | + detail.useEtime = obj.useEtime; | ||
| 1197 | + } | ||
| 1198 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1199 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1200 | + detail.useStime = obj.useStime; | ||
| 1201 | + detail.useEtime = obj.useEtime; | ||
| 1202 | + } | ||
| 1203 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1204 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1205 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1206 | + detail.useStime = obj.useStime; | ||
| 1207 | + detail.useEtime = obj.useEtime; | ||
| 1208 | + } | ||
| 1147 | } | 1209 | } |
| 1148 | }) | 1210 | }) |
| 1149 | console.log('未领取的券列表-----------', couponArr); | 1211 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1153,6 +1215,17 @@ Page({ | @@ -1153,6 +1215,17 @@ Page({ | ||
| 1153 | } | 1215 | } |
| 1154 | }) | 1216 | }) |
| 1155 | }, | 1217 | }, |
| 1218 | + // 计算免费券有效期的起始、结束日期 | ||
| 1219 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1220 | + console.log(cdate, startOffset, endOffset); | ||
| 1221 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1222 | + startDate.setHours(0, 0, 0, 0); | ||
| 1223 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1224 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1225 | + endDate.setHours(23, 59, 59, 0); | ||
| 1226 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1227 | + return { useStime, useEtime }; | ||
| 1228 | + }, | ||
| 1156 | // 处理优惠券不可用日期数据 | 1229 | // 处理优惠券不可用日期数据 |
| 1157 | hasConsecutiveSelect(arr, type) { | 1230 | hasConsecutiveSelect(arr, type) { |
| 1158 | let firstTitle = null; | 1231 | let firstTitle = null; |
| @@ -100,6 +100,8 @@ | @@ -100,6 +100,8 @@ | ||
| 100 | <view wx:if="{{item.is_type == '4' && item.desc}}" class="limitation showDesc"> | 100 | <view wx:if="{{item.is_type == '4' && item.desc}}" class="limitation showDesc"> |
| 101 | <text class="font24r">消费要求</text> | 101 | <text class="font24r">消费要求</text> |
| 102 | </view> | 102 | </view> |
| 103 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="limitation showDesc font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> | ||
| 104 | + <view wx:if="{{item.useStime && item.useEtime}}" class="font24r nodate showDesc">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 103 | <view wx:if="{{item.is_type == '3' && (item.morText || item.noonText || item.nigText)}}" class="limitation showDesc"> | 105 | <view wx:if="{{item.is_type == '3' && (item.morText || item.noonText || item.nigText)}}" class="limitation showDesc"> |
| 104 | <text class="font24r">不可用日期</text> | 106 | <text class="font24r">不可用日期</text> |
| 105 | </view> | 107 | </view> |
| @@ -186,6 +188,8 @@ | @@ -186,6 +188,8 @@ | ||
| 186 | <view wx:if="{{couponData.is_type == '4' && couponData.desc}}" class="limitation showDesc"> | 188 | <view wx:if="{{couponData.is_type == '4' && couponData.desc}}" class="limitation showDesc"> |
| 187 | <text class="font24r">消费要求</text> | 189 | <text class="font24r">消费要求</text> |
| 188 | </view> | 190 | </view> |
| 191 | + <view wx:if="{{(couponData.useStime && couponData.useEtime) || couponData.foreverText}}" class="limitation showDesc font24r">有效期:{{couponData.foreverText?couponData.foreverText : ''}}</view> | ||
| 192 | + <view wx:if="{{couponData.useStime && couponData.useEtime}}" class="font24r nodate showDesc">{{couponData.useStime}} 至 {{couponData.useEtime}}</view> | ||
| 189 | <view wx:if="{{couponData.is_type == '3' && (couponData.morText || couponData.noonText || couponData.nigText)}}" class="limitation showDesc"> | 193 | <view wx:if="{{couponData.is_type == '3' && (couponData.morText || couponData.noonText || couponData.nigText)}}" class="limitation showDesc"> |
| 190 | <text class="font24r">不可用日期</text> | 194 | <text class="font24r">不可用日期</text> |
| 191 | </view> | 195 | </view> |
| @@ -270,6 +270,10 @@ | @@ -270,6 +270,10 @@ | ||
| 270 | align-items: center; | 270 | align-items: center; |
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | +.certificateInfo .nodate{ | ||
| 274 | + padding-left: 20rpx; | ||
| 275 | +} | ||
| 276 | + | ||
| 273 | .certificateInfo .limitation { | 277 | .certificateInfo .limitation { |
| 274 | line-height: 40rpx; | 278 | line-height: 40rpx; |
| 275 | } | 279 | } |
| @@ -407,6 +411,7 @@ | @@ -407,6 +411,7 @@ | ||
| 407 | .couponBoxWrap .showDesc { | 411 | .couponBoxWrap .showDesc { |
| 408 | display: flex; | 412 | display: flex; |
| 409 | align-items: center; | 413 | align-items: center; |
| 414 | + color: #666; | ||
| 410 | } | 415 | } |
| 411 | 416 | ||
| 412 | .bottomLimitation { | 417 | .bottomLimitation { |
| @@ -941,6 +941,8 @@ Page({ | @@ -941,6 +941,8 @@ Page({ | ||
| 941 | }).then(res => { | 941 | }).then(res => { |
| 942 | if (res.data.length > 0) { | 942 | if (res.data.length > 0) { |
| 943 | let detail = res.data[0] | 943 | let detail = res.data[0] |
| 944 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 945 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 944 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 946 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 945 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 947 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 946 | detail.use = detail.use ? util.determine(detail.use) : ''; | 948 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| @@ -986,7 +988,35 @@ Page({ | @@ -986,7 +988,35 @@ Page({ | ||
| 986 | detail.noonText = noon; | 988 | detail.noonText = noon; |
| 987 | detail.nigText = nig; | 989 | detail.nigText = nig; |
| 988 | } | 990 | } |
| 989 | - detail.showCoupon = (this.data.dataStr < (detail.etime * 1) && detail.is_open == '1') ? '1' : '0'; | 991 | + detail.cdate = detail.cdate * 1; |
| 992 | + detail.useStime = ''; | ||
| 993 | + detail.useEtime = ''; | ||
| 994 | + let condition = detail.aexpiration | ||
| 995 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 996 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 997 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 998 | + } | ||
| 999 | + if (condition.valid_forever === '1') { | ||
| 1000 | + detail.foreverText = '永久有效'; | ||
| 1001 | + } | ||
| 1002 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1003 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1004 | + detail.useStime = obj.useStime; | ||
| 1005 | + detail.useEtime = obj.useEtime; | ||
| 1006 | + } | ||
| 1007 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1008 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1009 | + detail.useStime = obj.useStime; | ||
| 1010 | + detail.useEtime = obj.useEtime; | ||
| 1011 | + } | ||
| 1012 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1013 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1014 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1015 | + detail.useStime = obj.useStime; | ||
| 1016 | + detail.useEtime = obj.useEtime; | ||
| 1017 | + } | ||
| 1018 | + let data = detail.expiration_date; | ||
| 1019 | + detail.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && detail.is_open == '1') ? '1' : '0'; | ||
| 990 | let entry = this.data.titleList | 1020 | let entry = this.data.titleList |
| 991 | 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'))) { | 1021 | 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'))) { |
| 992 | entry.push({ | 1022 | entry.push({ |
| @@ -1028,14 +1058,18 @@ Page({ | @@ -1028,14 +1058,18 @@ Page({ | ||
| 1028 | id: obj.map(item => item.id).join(','), | 1058 | id: obj.map(item => item.id).join(','), |
| 1029 | }).then(res => { | 1059 | }).then(res => { |
| 1030 | if (res.data.length > 0) { | 1060 | if (res.data.length > 0) { |
| 1061 | + // valid_forever 1永久 0非永久 | ||
| 1031 | let list = res.data.filter(item => { | 1062 | let list = res.data.filter(item => { |
| 1032 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 1063 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 1064 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 1033 | }) | 1065 | }) |
| 1034 | list.forEach(detail => { | 1066 | list.forEach(detail => { |
| 1035 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 1067 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 1036 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 1068 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 1037 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 1069 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 1038 | detail.use = detail.use ? util.determine(detail.use) : ''; | 1070 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 1071 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 1072 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 1039 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 1073 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 1040 | let cash = detail.use.cash * 1; | 1074 | let cash = detail.use.cash * 1; |
| 1041 | let price = detail.price * 1; | 1075 | let price = detail.price * 1; |
| @@ -1211,8 +1245,36 @@ Page({ | @@ -1211,8 +1245,36 @@ Page({ | ||
| 1211 | } | 1245 | } |
| 1212 | list.forEach(item=>{ | 1246 | list.forEach(item=>{ |
| 1213 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1247 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1214 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1215 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1248 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1249 | + const detail = coupon_dataList[idx]; | ||
| 1250 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1251 | + detail.cdate = detail.cdate * 1; | ||
| 1252 | + detail.useStime = ''; | ||
| 1253 | + detail.useEtime = ''; | ||
| 1254 | + let condition = detail.aexpiration | ||
| 1255 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1256 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1257 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1258 | + } | ||
| 1259 | + if (condition.valid_forever === '1') { | ||
| 1260 | + detail.foreverText = '永久有效'; | ||
| 1261 | + } | ||
| 1262 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1263 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1264 | + detail.useStime = obj.useStime; | ||
| 1265 | + detail.useEtime = obj.useEtime; | ||
| 1266 | + } | ||
| 1267 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1268 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1269 | + detail.useStime = obj.useStime; | ||
| 1270 | + detail.useEtime = obj.useEtime; | ||
| 1271 | + } | ||
| 1272 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1273 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1274 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1275 | + detail.useStime = obj.useStime; | ||
| 1276 | + detail.useEtime = obj.useEtime; | ||
| 1277 | + } | ||
| 1216 | } | 1278 | } |
| 1217 | }) | 1279 | }) |
| 1218 | console.log('未领取的券列表-----------', couponArr); | 1280 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1222,6 +1284,17 @@ Page({ | @@ -1222,6 +1284,17 @@ Page({ | ||
| 1222 | } | 1284 | } |
| 1223 | }) | 1285 | }) |
| 1224 | }, | 1286 | }, |
| 1287 | + // 计算免费券有效期的起始、结束日期 | ||
| 1288 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1289 | + console.log(cdate, startOffset, endOffset); | ||
| 1290 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1291 | + startDate.setHours(0, 0, 0, 0); | ||
| 1292 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1293 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1294 | + endDate.setHours(23, 59, 59, 0); | ||
| 1295 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1296 | + return { useStime, useEtime }; | ||
| 1297 | + }, | ||
| 1225 | // 处理优惠券不可用日期数据 | 1298 | // 处理优惠券不可用日期数据 |
| 1226 | hasConsecutiveSelect(arr, type) { | 1299 | hasConsecutiveSelect(arr, type) { |
| 1227 | let firstTitle = null; | 1300 | let firstTitle = null; |
| @@ -137,6 +137,8 @@ | @@ -137,6 +137,8 @@ | ||
| 137 | <view wx:if="{{item.is_type == '4' && item.desc}}" class="limitation showDesc"> | 137 | <view wx:if="{{item.is_type == '4' && item.desc}}" class="limitation showDesc"> |
| 138 | <text class="font24r">消费要求</text> | 138 | <text class="font24r">消费要求</text> |
| 139 | </view> | 139 | </view> |
| 140 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="limitation showDesc font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> | ||
| 141 | + <view wx:if="{{item.useStime && item.useEtime}}" class="font24r nodate showDesc">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 140 | <view wx:if="{{item.is_type == '3' && (item.morText || item.noonText || item.nigText)}}" class="limitation showDesc"> | 142 | <view wx:if="{{item.is_type == '3' && (item.morText || item.noonText || item.nigText)}}" class="limitation showDesc"> |
| 141 | <text class="font24r">不可用日期</text> | 143 | <text class="font24r">不可用日期</text> |
| 142 | </view> | 144 | </view> |
| @@ -229,6 +231,8 @@ | @@ -229,6 +231,8 @@ | ||
| 229 | <view wx:if="{{couponData.is_type == '4' && couponData.desc}}" class="limitation showDesc"> | 231 | <view wx:if="{{couponData.is_type == '4' && couponData.desc}}" class="limitation showDesc"> |
| 230 | <text class="font24r">消费要求</text> | 232 | <text class="font24r">消费要求</text> |
| 231 | </view> | 233 | </view> |
| 234 | + <view wx:if="{{(couponData.useStime && couponData.useEtime) || couponData.foreverText}}" class="limitation showDesc font24r">有效期:{{couponData.foreverText?couponData.foreverText : ''}}</view> | ||
| 235 | + <view wx:if="{{couponData.useStime && couponData.useEtime}}" class="font24r nodate showDesc">{{couponData.useStime}} 至 {{couponData.useEtime}}</view> | ||
| 232 | <view wx:if="{{couponData.is_type == '3' && (couponData.morText || couponData.noonText || couponData.nigText)}}" class="limitation showDesc"> | 236 | <view wx:if="{{couponData.is_type == '3' && (couponData.morText || couponData.noonText || couponData.nigText)}}" class="limitation showDesc"> |
| 233 | <text class="font24r">不可用日期</text> | 237 | <text class="font24r">不可用日期</text> |
| 234 | </view> | 238 | </view> |
| @@ -274,6 +274,10 @@ | @@ -274,6 +274,10 @@ | ||
| 274 | background: #efefef; | 274 | background: #efefef; |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | +.preferentialCoupon .nodate{ | ||
| 278 | + padding-left: 20rpx; | ||
| 279 | +} | ||
| 280 | + | ||
| 277 | .preferentialCoupon .limitation { | 281 | .preferentialCoupon .limitation { |
| 278 | display: flex; | 282 | display: flex; |
| 279 | flex-direction: column; | 283 | flex-direction: column; |
| @@ -956,6 +956,8 @@ Page({ | @@ -956,6 +956,8 @@ Page({ | ||
| 956 | }).then(res => { | 956 | }).then(res => { |
| 957 | if (res.data.length > 0) { | 957 | if (res.data.length > 0) { |
| 958 | let detail = res.data[0] | 958 | let detail = res.data[0] |
| 959 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 960 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 959 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 961 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 960 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 962 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 961 | detail.use = detail.use ? util.determine(detail.use) : ''; | 963 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| @@ -1001,7 +1003,35 @@ Page({ | @@ -1001,7 +1003,35 @@ Page({ | ||
| 1001 | detail.noonText = noon; | 1003 | detail.noonText = noon; |
| 1002 | detail.nigText = nig; | 1004 | detail.nigText = nig; |
| 1003 | } | 1005 | } |
| 1004 | - detail.showCoupon = (this.data.dataStr < (detail.etime * 1) && detail.is_open == '1') ? '1' : '0'; | 1006 | + detail.cdate = detail.cdate * 1; |
| 1007 | + detail.useStime = ''; | ||
| 1008 | + detail.useEtime = ''; | ||
| 1009 | + let condition = detail.aexpiration | ||
| 1010 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1011 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1012 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1013 | + } | ||
| 1014 | + if (condition.valid_forever === '1') { | ||
| 1015 | + detail.foreverText = '永久有效'; | ||
| 1016 | + } | ||
| 1017 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1018 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1019 | + detail.useStime = obj.useStime; | ||
| 1020 | + detail.useEtime = obj.useEtime; | ||
| 1021 | + } | ||
| 1022 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1023 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1024 | + detail.useStime = obj.useStime; | ||
| 1025 | + detail.useEtime = obj.useEtime; | ||
| 1026 | + } | ||
| 1027 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1028 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1029 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1030 | + detail.useStime = obj.useStime; | ||
| 1031 | + detail.useEtime = obj.useEtime; | ||
| 1032 | + } | ||
| 1033 | + let data = detail.expiration_date; | ||
| 1034 | + detail.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && detail.is_open == '1') ? '1' : '0'; | ||
| 1005 | let entry = this.data.titleList | 1035 | let entry = this.data.titleList |
| 1006 | 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'))) { | 1036 | 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'))) { |
| 1007 | entry.push({ | 1037 | entry.push({ |
| @@ -1043,14 +1073,18 @@ Page({ | @@ -1043,14 +1073,18 @@ Page({ | ||
| 1043 | id: obj.map(item => item.id).join(','), | 1073 | id: obj.map(item => item.id).join(','), |
| 1044 | }).then(res => { | 1074 | }).then(res => { |
| 1045 | if (res.data.length > 0) { | 1075 | if (res.data.length > 0) { |
| 1076 | + // valid_forever 1永久 0非永久 | ||
| 1046 | let list = res.data.filter(item => { | 1077 | let list = res.data.filter(item => { |
| 1047 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 1078 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 1079 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 1048 | }) | 1080 | }) |
| 1049 | list.forEach(detail => { | 1081 | list.forEach(detail => { |
| 1050 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 1082 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 1051 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 1083 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 1052 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 1084 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 1053 | detail.use = detail.use ? util.determine(detail.use) : ''; | 1085 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 1086 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 1087 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 1054 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 1088 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 1055 | let cash = detail.use.cash * 1; | 1089 | let cash = detail.use.cash * 1; |
| 1056 | let price = detail.price * 1; | 1090 | let price = detail.price * 1; |
| @@ -1226,8 +1260,36 @@ Page({ | @@ -1226,8 +1260,36 @@ Page({ | ||
| 1226 | } | 1260 | } |
| 1227 | list.forEach(item=>{ | 1261 | list.forEach(item=>{ |
| 1228 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1262 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1229 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1230 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1263 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1264 | + const detail = coupon_dataList[idx]; | ||
| 1265 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1266 | + detail.cdate = detail.cdate * 1; | ||
| 1267 | + detail.useStime = ''; | ||
| 1268 | + detail.useEtime = ''; | ||
| 1269 | + let condition = detail.aexpiration | ||
| 1270 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1271 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1272 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1273 | + } | ||
| 1274 | + if (condition.valid_forever === '1') { | ||
| 1275 | + detail.foreverText = '永久有效'; | ||
| 1276 | + } | ||
| 1277 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1278 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1279 | + detail.useStime = obj.useStime; | ||
| 1280 | + detail.useEtime = obj.useEtime; | ||
| 1281 | + } | ||
| 1282 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1283 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1284 | + detail.useStime = obj.useStime; | ||
| 1285 | + detail.useEtime = obj.useEtime; | ||
| 1286 | + } | ||
| 1287 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1288 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1289 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1290 | + detail.useStime = obj.useStime; | ||
| 1291 | + detail.useEtime = obj.useEtime; | ||
| 1292 | + } | ||
| 1231 | } | 1293 | } |
| 1232 | }) | 1294 | }) |
| 1233 | console.log('未领取的券列表-----------', couponArr); | 1295 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1237,6 +1299,17 @@ Page({ | @@ -1237,6 +1299,17 @@ Page({ | ||
| 1237 | } | 1299 | } |
| 1238 | }) | 1300 | }) |
| 1239 | }, | 1301 | }, |
| 1302 | + // 计算免费券有效期的起始、结束日期 | ||
| 1303 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1304 | + console.log(cdate, startOffset, endOffset); | ||
| 1305 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1306 | + startDate.setHours(0, 0, 0, 0); | ||
| 1307 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1308 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1309 | + endDate.setHours(23, 59, 59, 0); | ||
| 1310 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1311 | + return { useStime, useEtime }; | ||
| 1312 | + }, | ||
| 1240 | // 处理优惠券不可用日期数据 | 1313 | // 处理优惠券不可用日期数据 |
| 1241 | hasConsecutiveSelect(arr, type) { | 1314 | hasConsecutiveSelect(arr, type) { |
| 1242 | let firstTitle = null; | 1315 | let firstTitle = null; |
| @@ -181,6 +181,8 @@ | @@ -181,6 +181,8 @@ | ||
| 181 | <view wx:if="{{item.is_type == '4' && item.desc}}" class="limitation showDesc"> | 181 | <view wx:if="{{item.is_type == '4' && item.desc}}" class="limitation showDesc"> |
| 182 | <text class="font24r">消费要求</text> | 182 | <text class="font24r">消费要求</text> |
| 183 | </view> | 183 | </view> |
| 184 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="limitation showDesc font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> | ||
| 185 | + <view wx:if="{{item.useStime && item.useEtime}}" class="font24r nodate showDesc">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 184 | <view wx:if="{{item.is_type == '3' && (item.morText || item.noonText || item.nigText)}}" class="limitation showDesc"> | 186 | <view wx:if="{{item.is_type == '3' && (item.morText || item.noonText || item.nigText)}}" class="limitation showDesc"> |
| 185 | <text class="font24r">不可用日期</text> | 187 | <text class="font24r">不可用日期</text> |
| 186 | </view> | 188 | </view> |
| @@ -267,6 +269,8 @@ | @@ -267,6 +269,8 @@ | ||
| 267 | <view wx:if="{{couponData.is_type == '4' && couponData.desc}}" class="limitation showDesc"> | 269 | <view wx:if="{{couponData.is_type == '4' && couponData.desc}}" class="limitation showDesc"> |
| 268 | <text class="font24r">消费要求</text> | 270 | <text class="font24r">消费要求</text> |
| 269 | </view> | 271 | </view> |
| 272 | + <view wx:if="{{(couponData.useStime && couponData.useEtime) || couponData.foreverText}}" class="limitation showDesc font24r">有效期:{{couponData.foreverText?couponData.foreverText : ''}}</view> | ||
| 273 | + <view wx:if="{{couponData.useStime && couponData.useEtime}}" class="font24r nodate showDesc">{{couponData.useStime}} 至 {{couponData.useEtime}}</view> | ||
| 270 | <view wx:if="{{couponData.is_type == '3' && (couponData.morText || couponData.noonText || couponData.nigText)}}" class="limitation showDesc"> | 274 | <view wx:if="{{couponData.is_type == '3' && (couponData.morText || couponData.noonText || couponData.nigText)}}" class="limitation showDesc"> |
| 271 | <text class="font24r">不可用日期</text> | 275 | <text class="font24r">不可用日期</text> |
| 272 | </view> | 276 | </view> |
| @@ -930,8 +930,9 @@ Page({ | @@ -930,8 +930,9 @@ Page({ | ||
| 930 | }).then(res => { | 930 | }).then(res => { |
| 931 | if (res.data.length > 0) { | 931 | if (res.data.length > 0) { |
| 932 | let couponData = res.data[0] | 932 | let couponData = res.data[0] |
| 933 | + let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : ''; | ||
| 933 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 | 934 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 |
| 934 | - couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0'; | 935 | + couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0'; |
| 935 | console.log('邀请函--------------------评价赠送的优惠券',couponData); | 936 | console.log('邀请函--------------------评价赠送的优惠券',couponData); |
| 936 | this.setData({ | 937 | this.setData({ |
| 937 | couponData:res.data[0] | 938 | couponData:res.data[0] |
| @@ -944,15 +945,19 @@ Page({ | @@ -944,15 +945,19 @@ Page({ | ||
| 944 | App.Activity.GetActivityById({ | 945 | App.Activity.GetActivityById({ |
| 945 | id: obj.map(item => item.id).join(','), | 946 | id: obj.map(item => item.id).join(','), |
| 946 | }).then(res => { | 947 | }).then(res => { |
| 947 | - if (res.data.length > 0) { | 948 | + if (res.data.length > 0) { |
| 949 | + // valid_forever 1永久 0非永久 | ||
| 948 | let list = res.data.filter(item => { | 950 | let list = res.data.filter(item => { |
| 949 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 951 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 952 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 950 | }) | 953 | }) |
| 951 | list.forEach(detail => { | 954 | list.forEach(detail => { |
| 952 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 955 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 953 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 956 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 954 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 957 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 955 | detail.use = detail.use ? util.determine(detail.use) : ''; | 958 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 959 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 960 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 956 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 961 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 957 | let cash = detail.use.cash * 1; | 962 | let cash = detail.use.cash * 1; |
| 958 | let price = detail.price * 1; | 963 | let price = detail.price * 1; |
| @@ -1114,8 +1119,36 @@ Page({ | @@ -1114,8 +1119,36 @@ Page({ | ||
| 1114 | } | 1119 | } |
| 1115 | list.forEach(item=>{ | 1120 | list.forEach(item=>{ |
| 1116 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1121 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1117 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1118 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1122 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1123 | + const detail = coupon_dataList[idx]; | ||
| 1124 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1125 | + detail.cdate = detail.cdate * 1; | ||
| 1126 | + detail.useStime = ''; | ||
| 1127 | + detail.useEtime = ''; | ||
| 1128 | + let condition = detail.aexpiration | ||
| 1129 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1130 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1131 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1132 | + } | ||
| 1133 | + if (condition.valid_forever === '1') { | ||
| 1134 | + detail.foreverText = '永久有效'; | ||
| 1135 | + } | ||
| 1136 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1137 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1138 | + detail.useStime = obj.useStime; | ||
| 1139 | + detail.useEtime = obj.useEtime; | ||
| 1140 | + } | ||
| 1141 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1142 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1143 | + detail.useStime = obj.useStime; | ||
| 1144 | + detail.useEtime = obj.useEtime; | ||
| 1145 | + } | ||
| 1146 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1147 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1148 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1149 | + detail.useStime = obj.useStime; | ||
| 1150 | + detail.useEtime = obj.useEtime; | ||
| 1151 | + } | ||
| 1119 | } | 1152 | } |
| 1120 | }) | 1153 | }) |
| 1121 | console.log('未领取的券列表-----------', couponArr); | 1154 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1125,6 +1158,17 @@ Page({ | @@ -1125,6 +1158,17 @@ Page({ | ||
| 1125 | } | 1158 | } |
| 1126 | }) | 1159 | }) |
| 1127 | }, | 1160 | }, |
| 1161 | + // 计算免费券有效期的起始、结束日期 | ||
| 1162 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1163 | + console.log(cdate, startOffset, endOffset); | ||
| 1164 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1165 | + startDate.setHours(0, 0, 0, 0); | ||
| 1166 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1167 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1168 | + endDate.setHours(23, 59, 59, 0); | ||
| 1169 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1170 | + return { useStime, useEtime }; | ||
| 1171 | + }, | ||
| 1128 | // 处理优惠券不可用日期数据 | 1172 | // 处理优惠券不可用日期数据 |
| 1129 | hasConsecutiveSelect(arr, type) { | 1173 | hasConsecutiveSelect(arr, type) { |
| 1130 | let firstTitle = null; | 1174 | let firstTitle = null; |
| @@ -110,7 +110,8 @@ | @@ -110,7 +110,8 @@ | ||
| 110 | </view> | 110 | </view> |
| 111 | </block> | 111 | </block> |
| 112 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 112 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 113 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 113 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 114 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 114 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 115 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 115 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 116 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 116 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 117 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
| @@ -885,8 +885,9 @@ Page({ | @@ -885,8 +885,9 @@ Page({ | ||
| 885 | }).then(res => { | 885 | }).then(res => { |
| 886 | if (res.data.length > 0) { | 886 | if (res.data.length > 0) { |
| 887 | let couponData = res.data[0] | 887 | let couponData = res.data[0] |
| 888 | + let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : ''; | ||
| 888 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 | 889 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 |
| 889 | - couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0'; | 890 | + couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0'; |
| 890 | console.log('邀请函--------------------评价赠送的优惠券',couponData); | 891 | console.log('邀请函--------------------评价赠送的优惠券',couponData); |
| 891 | this.setData({ | 892 | this.setData({ |
| 892 | couponData:res.data[0] | 893 | couponData:res.data[0] |
| @@ -899,15 +900,19 @@ Page({ | @@ -899,15 +900,19 @@ Page({ | ||
| 899 | App.Activity.GetActivityById({ | 900 | App.Activity.GetActivityById({ |
| 900 | id: obj.map(item => item.id).join(','), | 901 | id: obj.map(item => item.id).join(','), |
| 901 | }).then(res => { | 902 | }).then(res => { |
| 902 | - if (res.data.length > 0) { | 903 | + if (res.data.length > 0) { |
| 904 | + // valid_forever 1永久 0非永久 | ||
| 903 | let list = res.data.filter(item => { | 905 | let list = res.data.filter(item => { |
| 904 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 906 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 907 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 905 | }) | 908 | }) |
| 906 | list.forEach(detail => { | 909 | list.forEach(detail => { |
| 907 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 910 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 908 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 911 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 909 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 912 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 910 | detail.use = detail.use ? util.determine(detail.use) : ''; | 913 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 914 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 915 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 911 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 916 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 912 | let cash = detail.use.cash * 1; | 917 | let cash = detail.use.cash * 1; |
| 913 | let price = detail.price * 1; | 918 | let price = detail.price * 1; |
| @@ -1069,8 +1074,36 @@ Page({ | @@ -1069,8 +1074,36 @@ Page({ | ||
| 1069 | } | 1074 | } |
| 1070 | list.forEach(item=>{ | 1075 | list.forEach(item=>{ |
| 1071 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1076 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1072 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1073 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1077 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1078 | + const detail = coupon_dataList[idx]; | ||
| 1079 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1080 | + detail.cdate = detail.cdate * 1; | ||
| 1081 | + detail.useStime = ''; | ||
| 1082 | + detail.useEtime = ''; | ||
| 1083 | + let condition = detail.aexpiration | ||
| 1084 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1085 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1086 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1087 | + } | ||
| 1088 | + if (condition.valid_forever === '1') { | ||
| 1089 | + detail.foreverText = '永久有效'; | ||
| 1090 | + } | ||
| 1091 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1092 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1093 | + detail.useStime = obj.useStime; | ||
| 1094 | + detail.useEtime = obj.useEtime; | ||
| 1095 | + } | ||
| 1096 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1097 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1098 | + detail.useStime = obj.useStime; | ||
| 1099 | + detail.useEtime = obj.useEtime; | ||
| 1100 | + } | ||
| 1101 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1102 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1103 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1104 | + detail.useStime = obj.useStime; | ||
| 1105 | + detail.useEtime = obj.useEtime; | ||
| 1106 | + } | ||
| 1074 | } | 1107 | } |
| 1075 | }) | 1108 | }) |
| 1076 | console.log('未领取的券列表-----------', couponArr); | 1109 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1080,6 +1113,17 @@ Page({ | @@ -1080,6 +1113,17 @@ Page({ | ||
| 1080 | } | 1113 | } |
| 1081 | }) | 1114 | }) |
| 1082 | }, | 1115 | }, |
| 1116 | + // 计算免费券有效期的起始、结束日期 | ||
| 1117 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1118 | + console.log(cdate, startOffset, endOffset); | ||
| 1119 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1120 | + startDate.setHours(0, 0, 0, 0); | ||
| 1121 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1122 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1123 | + endDate.setHours(23, 59, 59, 0); | ||
| 1124 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1125 | + return { useStime, useEtime }; | ||
| 1126 | + }, | ||
| 1083 | // 处理优惠券不可用日期数据 | 1127 | // 处理优惠券不可用日期数据 |
| 1084 | hasConsecutiveSelect(arr, type) { | 1128 | hasConsecutiveSelect(arr, type) { |
| 1085 | let firstTitle = null; | 1129 | let firstTitle = null; |
| @@ -116,7 +116,8 @@ | @@ -116,7 +116,8 @@ | ||
| 116 | </view> | 116 | </view> |
| 117 | </block> | 117 | </block> |
| 118 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 118 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 119 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 119 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 120 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 120 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 121 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 121 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 122 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 122 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 123 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
| @@ -886,8 +886,9 @@ Page({ | @@ -886,8 +886,9 @@ Page({ | ||
| 886 | }).then(res => { | 886 | }).then(res => { |
| 887 | if (res.data.length > 0) { | 887 | if (res.data.length > 0) { |
| 888 | let couponData = res.data[0] | 888 | let couponData = res.data[0] |
| 889 | + let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : ''; | ||
| 889 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 | 890 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 |
| 890 | - couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0'; | 891 | + couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0'; |
| 891 | console.log('邀请函--------------------评价赠送的优惠券',couponData); | 892 | console.log('邀请函--------------------评价赠送的优惠券',couponData); |
| 892 | this.setData({ | 893 | this.setData({ |
| 893 | couponData:res.data[0] | 894 | couponData:res.data[0] |
| @@ -900,15 +901,19 @@ Page({ | @@ -900,15 +901,19 @@ Page({ | ||
| 900 | App.Activity.GetActivityById({ | 901 | App.Activity.GetActivityById({ |
| 901 | id: obj.map(item => item.id).join(','), | 902 | id: obj.map(item => item.id).join(','), |
| 902 | }).then(res => { | 903 | }).then(res => { |
| 903 | - if (res.data.length > 0) { | 904 | + if (res.data.length > 0) { |
| 905 | + // valid_forever 1永久 0非永久 | ||
| 904 | let list = res.data.filter(item => { | 906 | let list = res.data.filter(item => { |
| 905 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 907 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 908 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 906 | }) | 909 | }) |
| 907 | list.forEach(detail => { | 910 | list.forEach(detail => { |
| 908 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 911 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 909 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 912 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 910 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 913 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 911 | detail.use = detail.use ? util.determine(detail.use) : ''; | 914 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 915 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 916 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 912 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 917 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 913 | let cash = detail.use.cash * 1; | 918 | let cash = detail.use.cash * 1; |
| 914 | let price = detail.price * 1; | 919 | let price = detail.price * 1; |
| @@ -1070,8 +1075,36 @@ Page({ | @@ -1070,8 +1075,36 @@ Page({ | ||
| 1070 | } | 1075 | } |
| 1071 | list.forEach(item=>{ | 1076 | list.forEach(item=>{ |
| 1072 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1077 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1073 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1074 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1078 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1079 | + const detail = coupon_dataList[idx]; | ||
| 1080 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1081 | + detail.cdate = detail.cdate * 1; | ||
| 1082 | + detail.useStime = ''; | ||
| 1083 | + detail.useEtime = ''; | ||
| 1084 | + let condition = detail.aexpiration | ||
| 1085 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1086 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1087 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1088 | + } | ||
| 1089 | + if (condition.valid_forever === '1') { | ||
| 1090 | + detail.foreverText = '永久有效'; | ||
| 1091 | + } | ||
| 1092 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1093 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1094 | + detail.useStime = obj.useStime; | ||
| 1095 | + detail.useEtime = obj.useEtime; | ||
| 1096 | + } | ||
| 1097 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1098 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1099 | + detail.useStime = obj.useStime; | ||
| 1100 | + detail.useEtime = obj.useEtime; | ||
| 1101 | + } | ||
| 1102 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1103 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1104 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1105 | + detail.useStime = obj.useStime; | ||
| 1106 | + detail.useEtime = obj.useEtime; | ||
| 1107 | + } | ||
| 1075 | } | 1108 | } |
| 1076 | }) | 1109 | }) |
| 1077 | console.log('未领取的券列表-----------', couponArr); | 1110 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1081,6 +1114,17 @@ Page({ | @@ -1081,6 +1114,17 @@ Page({ | ||
| 1081 | } | 1114 | } |
| 1082 | }) | 1115 | }) |
| 1083 | }, | 1116 | }, |
| 1117 | + // 计算免费券有效期的起始、结束日期 | ||
| 1118 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1119 | + console.log(cdate, startOffset, endOffset); | ||
| 1120 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1121 | + startDate.setHours(0, 0, 0, 0); | ||
| 1122 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1123 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1124 | + endDate.setHours(23, 59, 59, 0); | ||
| 1125 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1126 | + return { useStime, useEtime }; | ||
| 1127 | + }, | ||
| 1084 | // 处理优惠券不可用日期数据 | 1128 | // 处理优惠券不可用日期数据 |
| 1085 | hasConsecutiveSelect(arr, type) { | 1129 | hasConsecutiveSelect(arr, type) { |
| 1086 | let firstTitle = null; | 1130 | let firstTitle = null; |
| @@ -99,7 +99,8 @@ | @@ -99,7 +99,8 @@ | ||
| 99 | </view> | 99 | </view> |
| 100 | </block> | 100 | </block> |
| 101 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 101 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 102 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 102 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 103 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 103 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 104 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 104 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 105 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 105 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 106 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
| @@ -884,8 +884,9 @@ Page({ | @@ -884,8 +884,9 @@ Page({ | ||
| 884 | }).then(res => { | 884 | }).then(res => { |
| 885 | if (res.data.length > 0) { | 885 | if (res.data.length > 0) { |
| 886 | let couponData = res.data[0] | 886 | let couponData = res.data[0] |
| 887 | + let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : ''; | ||
| 887 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 | 888 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 |
| 888 | - couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0'; | 889 | + couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0'; |
| 889 | console.log('邀请函--------------------评价赠送的优惠券',couponData); | 890 | console.log('邀请函--------------------评价赠送的优惠券',couponData); |
| 890 | this.setData({ | 891 | this.setData({ |
| 891 | couponData:res.data[0] | 892 | couponData:res.data[0] |
| @@ -898,15 +899,19 @@ Page({ | @@ -898,15 +899,19 @@ Page({ | ||
| 898 | App.Activity.GetActivityById({ | 899 | App.Activity.GetActivityById({ |
| 899 | id: obj.map(item => item.id).join(','), | 900 | id: obj.map(item => item.id).join(','), |
| 900 | }).then(res => { | 901 | }).then(res => { |
| 901 | - if (res.data.length > 0) { | 902 | + if (res.data.length > 0) { |
| 903 | + // valid_forever 1永久 0非永久 | ||
| 902 | let list = res.data.filter(item => { | 904 | let list = res.data.filter(item => { |
| 903 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 905 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 906 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 904 | }) | 907 | }) |
| 905 | list.forEach(detail => { | 908 | list.forEach(detail => { |
| 906 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 909 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 907 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 910 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 908 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 911 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 909 | detail.use = detail.use ? util.determine(detail.use) : ''; | 912 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 913 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 914 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 910 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 915 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 911 | let cash = detail.use.cash * 1; | 916 | let cash = detail.use.cash * 1; |
| 912 | let price = detail.price * 1; | 917 | let price = detail.price * 1; |
| @@ -1068,8 +1073,36 @@ Page({ | @@ -1068,8 +1073,36 @@ Page({ | ||
| 1068 | } | 1073 | } |
| 1069 | list.forEach(item=>{ | 1074 | list.forEach(item=>{ |
| 1070 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1075 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1071 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1072 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1076 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1077 | + const detail = coupon_dataList[idx]; | ||
| 1078 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1079 | + detail.cdate = detail.cdate * 1; | ||
| 1080 | + detail.useStime = ''; | ||
| 1081 | + detail.useEtime = ''; | ||
| 1082 | + let condition = detail.aexpiration | ||
| 1083 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1084 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1085 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1086 | + } | ||
| 1087 | + if (condition.valid_forever === '1') { | ||
| 1088 | + detail.foreverText = '永久有效'; | ||
| 1089 | + } | ||
| 1090 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1091 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1092 | + detail.useStime = obj.useStime; | ||
| 1093 | + detail.useEtime = obj.useEtime; | ||
| 1094 | + } | ||
| 1095 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1096 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1097 | + detail.useStime = obj.useStime; | ||
| 1098 | + detail.useEtime = obj.useEtime; | ||
| 1099 | + } | ||
| 1100 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1101 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1102 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1103 | + detail.useStime = obj.useStime; | ||
| 1104 | + detail.useEtime = obj.useEtime; | ||
| 1105 | + } | ||
| 1073 | } | 1106 | } |
| 1074 | }) | 1107 | }) |
| 1075 | console.log('未领取的券列表-----------', couponArr); | 1108 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1079,6 +1112,17 @@ Page({ | @@ -1079,6 +1112,17 @@ Page({ | ||
| 1079 | } | 1112 | } |
| 1080 | }) | 1113 | }) |
| 1081 | }, | 1114 | }, |
| 1115 | + // 计算免费券有效期的起始、结束日期 | ||
| 1116 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1117 | + console.log(cdate, startOffset, endOffset); | ||
| 1118 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1119 | + startDate.setHours(0, 0, 0, 0); | ||
| 1120 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1121 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1122 | + endDate.setHours(23, 59, 59, 0); | ||
| 1123 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1124 | + return { useStime, useEtime }; | ||
| 1125 | + }, | ||
| 1082 | // 处理优惠券不可用日期数据 | 1126 | // 处理优惠券不可用日期数据 |
| 1083 | hasConsecutiveSelect(arr, type) { | 1127 | hasConsecutiveSelect(arr, type) { |
| 1084 | let firstTitle = null; | 1128 | let firstTitle = null; |
| @@ -97,7 +97,8 @@ | @@ -97,7 +97,8 @@ | ||
| 97 | </view> | 97 | </view> |
| 98 | </block> | 98 | </block> |
| 99 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 99 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 100 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 100 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 101 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 101 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 102 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 102 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 103 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 103 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 104 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
| @@ -841,8 +841,9 @@ Page({ | @@ -841,8 +841,9 @@ Page({ | ||
| 841 | }).then(res => { | 841 | }).then(res => { |
| 842 | if (res.data.length > 0) { | 842 | if (res.data.length > 0) { |
| 843 | let couponData = res.data[0] | 843 | let couponData = res.data[0] |
| 844 | + let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : ''; | ||
| 844 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 | 845 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 |
| 845 | - couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0'; | 846 | + couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0'; |
| 846 | console.log('邀请函--------------------评价赠送的优惠券',couponData); | 847 | console.log('邀请函--------------------评价赠送的优惠券',couponData); |
| 847 | this.setData({ | 848 | this.setData({ |
| 848 | couponData:res.data[0] | 849 | couponData:res.data[0] |
| @@ -855,15 +856,19 @@ Page({ | @@ -855,15 +856,19 @@ Page({ | ||
| 855 | App.Activity.GetActivityById({ | 856 | App.Activity.GetActivityById({ |
| 856 | id: obj.map(item => item.id).join(','), | 857 | id: obj.map(item => item.id).join(','), |
| 857 | }).then(res => { | 858 | }).then(res => { |
| 858 | - if (res.data.length > 0) { | 859 | + if (res.data.length > 0) { |
| 860 | + // valid_forever 1永久 0非永久 | ||
| 859 | let list = res.data.filter(item => { | 861 | let list = res.data.filter(item => { |
| 860 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 862 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 863 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 861 | }) | 864 | }) |
| 862 | list.forEach(detail => { | 865 | list.forEach(detail => { |
| 863 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 866 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 864 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 867 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 865 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 868 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 866 | detail.use = detail.use ? util.determine(detail.use) : ''; | 869 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 870 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 871 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 867 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 872 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 868 | let cash = detail.use.cash * 1; | 873 | let cash = detail.use.cash * 1; |
| 869 | let price = detail.price * 1; | 874 | let price = detail.price * 1; |
| @@ -1025,8 +1030,36 @@ Page({ | @@ -1025,8 +1030,36 @@ Page({ | ||
| 1025 | } | 1030 | } |
| 1026 | list.forEach(item=>{ | 1031 | list.forEach(item=>{ |
| 1027 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1032 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1028 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1029 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1033 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1034 | + const detail = coupon_dataList[idx]; | ||
| 1035 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1036 | + detail.cdate = detail.cdate * 1; | ||
| 1037 | + detail.useStime = ''; | ||
| 1038 | + detail.useEtime = ''; | ||
| 1039 | + let condition = detail.aexpiration | ||
| 1040 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1041 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1042 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1043 | + } | ||
| 1044 | + if (condition.valid_forever === '1') { | ||
| 1045 | + detail.foreverText = '永久有效'; | ||
| 1046 | + } | ||
| 1047 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1048 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1049 | + detail.useStime = obj.useStime; | ||
| 1050 | + detail.useEtime = obj.useEtime; | ||
| 1051 | + } | ||
| 1052 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1053 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1054 | + detail.useStime = obj.useStime; | ||
| 1055 | + detail.useEtime = obj.useEtime; | ||
| 1056 | + } | ||
| 1057 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1058 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1059 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1060 | + detail.useStime = obj.useStime; | ||
| 1061 | + detail.useEtime = obj.useEtime; | ||
| 1062 | + } | ||
| 1030 | } | 1063 | } |
| 1031 | }) | 1064 | }) |
| 1032 | console.log('未领取的券列表-----------', couponArr); | 1065 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1036,6 +1069,17 @@ Page({ | @@ -1036,6 +1069,17 @@ Page({ | ||
| 1036 | } | 1069 | } |
| 1037 | }) | 1070 | }) |
| 1038 | }, | 1071 | }, |
| 1072 | + // 计算免费券有效期的起始、结束日期 | ||
| 1073 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1074 | + console.log(cdate, startOffset, endOffset); | ||
| 1075 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1076 | + startDate.setHours(0, 0, 0, 0); | ||
| 1077 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1078 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1079 | + endDate.setHours(23, 59, 59, 0); | ||
| 1080 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1081 | + return { useStime, useEtime }; | ||
| 1082 | + }, | ||
| 1039 | // 处理优惠券不可用日期数据 | 1083 | // 处理优惠券不可用日期数据 |
| 1040 | hasConsecutiveSelect(arr, type) { | 1084 | hasConsecutiveSelect(arr, type) { |
| 1041 | let firstTitle = null; | 1085 | let firstTitle = null; |
| @@ -119,7 +119,8 @@ | @@ -119,7 +119,8 @@ | ||
| 119 | </view> | 119 | </view> |
| 120 | </block> | 120 | </block> |
| 121 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 121 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 122 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 122 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 123 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 123 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 124 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 124 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 125 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 125 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 126 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
| @@ -885,8 +885,9 @@ Page({ | @@ -885,8 +885,9 @@ Page({ | ||
| 885 | }).then(res => { | 885 | }).then(res => { |
| 886 | if (res.data.length > 0) { | 886 | if (res.data.length > 0) { |
| 887 | let couponData = res.data[0] | 887 | let couponData = res.data[0] |
| 888 | + let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : ''; | ||
| 888 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 | 889 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 |
| 889 | - couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0'; | 890 | + couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0'; |
| 890 | console.log('邀请函--------------------评价赠送的优惠券',couponData); | 891 | console.log('邀请函--------------------评价赠送的优惠券',couponData); |
| 891 | this.setData({ | 892 | this.setData({ |
| 892 | couponData:res.data[0] | 893 | couponData:res.data[0] |
| @@ -899,15 +900,19 @@ Page({ | @@ -899,15 +900,19 @@ Page({ | ||
| 899 | App.Activity.GetActivityById({ | 900 | App.Activity.GetActivityById({ |
| 900 | id: obj.map(item => item.id).join(','), | 901 | id: obj.map(item => item.id).join(','), |
| 901 | }).then(res => { | 902 | }).then(res => { |
| 902 | - if (res.data.length > 0) { | 903 | + if (res.data.length > 0) { |
| 904 | + // valid_forever 1永久 0非永久 | ||
| 903 | let list = res.data.filter(item => { | 905 | let list = res.data.filter(item => { |
| 904 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 906 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 907 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 905 | }) | 908 | }) |
| 906 | list.forEach(detail => { | 909 | list.forEach(detail => { |
| 907 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 910 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 908 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 911 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 909 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 912 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 910 | detail.use = detail.use ? util.determine(detail.use) : ''; | 913 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 914 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 915 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 911 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 916 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 912 | let cash = detail.use.cash * 1; | 917 | let cash = detail.use.cash * 1; |
| 913 | let price = detail.price * 1; | 918 | let price = detail.price * 1; |
| @@ -1069,8 +1074,36 @@ Page({ | @@ -1069,8 +1074,36 @@ Page({ | ||
| 1069 | } | 1074 | } |
| 1070 | list.forEach(item=>{ | 1075 | list.forEach(item=>{ |
| 1071 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1076 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1072 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1073 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1077 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1078 | + const detail = coupon_dataList[idx]; | ||
| 1079 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1080 | + detail.cdate = detail.cdate * 1; | ||
| 1081 | + detail.useStime = ''; | ||
| 1082 | + detail.useEtime = ''; | ||
| 1083 | + let condition = detail.aexpiration | ||
| 1084 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1085 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1086 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1087 | + } | ||
| 1088 | + if (condition.valid_forever === '1') { | ||
| 1089 | + detail.foreverText = '永久有效'; | ||
| 1090 | + } | ||
| 1091 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1092 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1093 | + detail.useStime = obj.useStime; | ||
| 1094 | + detail.useEtime = obj.useEtime; | ||
| 1095 | + } | ||
| 1096 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1097 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1098 | + detail.useStime = obj.useStime; | ||
| 1099 | + detail.useEtime = obj.useEtime; | ||
| 1100 | + } | ||
| 1101 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1102 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1103 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1104 | + detail.useStime = obj.useStime; | ||
| 1105 | + detail.useEtime = obj.useEtime; | ||
| 1106 | + } | ||
| 1074 | } | 1107 | } |
| 1075 | }) | 1108 | }) |
| 1076 | console.log('未领取的券列表-----------', couponArr); | 1109 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1080,6 +1113,17 @@ Page({ | @@ -1080,6 +1113,17 @@ Page({ | ||
| 1080 | } | 1113 | } |
| 1081 | }) | 1114 | }) |
| 1082 | }, | 1115 | }, |
| 1116 | + // 计算免费券有效期的起始、结束日期 | ||
| 1117 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1118 | + console.log(cdate, startOffset, endOffset); | ||
| 1119 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1120 | + startDate.setHours(0, 0, 0, 0); | ||
| 1121 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1122 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1123 | + endDate.setHours(23, 59, 59, 0); | ||
| 1124 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1125 | + return { useStime, useEtime }; | ||
| 1126 | + }, | ||
| 1083 | // 处理优惠券不可用日期数据 | 1127 | // 处理优惠券不可用日期数据 |
| 1084 | hasConsecutiveSelect(arr, type) { | 1128 | hasConsecutiveSelect(arr, type) { |
| 1085 | let firstTitle = null; | 1129 | let firstTitle = null; |
| @@ -112,7 +112,8 @@ | @@ -112,7 +112,8 @@ | ||
| 112 | </view> | 112 | </view> |
| 113 | </block> | 113 | </block> |
| 114 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 114 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 115 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 115 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 116 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 116 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 117 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 117 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 118 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 118 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 119 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
| @@ -884,8 +884,9 @@ Page({ | @@ -884,8 +884,9 @@ Page({ | ||
| 884 | }).then(res => { | 884 | }).then(res => { |
| 885 | if (res.data.length > 0) { | 885 | if (res.data.length > 0) { |
| 886 | let couponData = res.data[0] | 886 | let couponData = res.data[0] |
| 887 | + let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : ''; | ||
| 887 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 | 888 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 |
| 888 | - couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0'; | 889 | + couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0'; |
| 889 | console.log('邀请函--------------------评价赠送的优惠券',couponData); | 890 | console.log('邀请函--------------------评价赠送的优惠券',couponData); |
| 890 | this.setData({ | 891 | this.setData({ |
| 891 | couponData:res.data[0] | 892 | couponData:res.data[0] |
| @@ -899,14 +900,18 @@ Page({ | @@ -899,14 +900,18 @@ Page({ | ||
| 899 | id: obj.map(item => item.id).join(','), | 900 | id: obj.map(item => item.id).join(','), |
| 900 | }).then(res => { | 901 | }).then(res => { |
| 901 | if (res.data.length > 0) { | 902 | if (res.data.length > 0) { |
| 903 | + // valid_forever 1永久 0非永久 | ||
| 902 | let list = res.data.filter(item => { | 904 | let list = res.data.filter(item => { |
| 903 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 905 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 906 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 904 | }) | 907 | }) |
| 905 | list.forEach(detail => { | 908 | list.forEach(detail => { |
| 906 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 909 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 907 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 910 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 908 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 911 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 909 | detail.use = detail.use ? util.determine(detail.use) : ''; | 912 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 913 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 914 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 910 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 915 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 911 | let cash = detail.use.cash * 1; | 916 | let cash = detail.use.cash * 1; |
| 912 | let price = detail.price * 1; | 917 | let price = detail.price * 1; |
| @@ -1068,8 +1073,36 @@ Page({ | @@ -1068,8 +1073,36 @@ Page({ | ||
| 1068 | } | 1073 | } |
| 1069 | list.forEach(item=>{ | 1074 | list.forEach(item=>{ |
| 1070 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1075 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1071 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1072 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1076 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1077 | + const detail = coupon_dataList[idx]; | ||
| 1078 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1079 | + detail.cdate = detail.cdate * 1; | ||
| 1080 | + detail.useStime = ''; | ||
| 1081 | + detail.useEtime = ''; | ||
| 1082 | + let condition = detail.aexpiration | ||
| 1083 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1084 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1085 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1086 | + } | ||
| 1087 | + if (condition.valid_forever === '1') { | ||
| 1088 | + detail.foreverText = '永久有效'; | ||
| 1089 | + } | ||
| 1090 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1091 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1092 | + detail.useStime = obj.useStime; | ||
| 1093 | + detail.useEtime = obj.useEtime; | ||
| 1094 | + } | ||
| 1095 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1096 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1097 | + detail.useStime = obj.useStime; | ||
| 1098 | + detail.useEtime = obj.useEtime; | ||
| 1099 | + } | ||
| 1100 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1101 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1102 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1103 | + detail.useStime = obj.useStime; | ||
| 1104 | + detail.useEtime = obj.useEtime; | ||
| 1105 | + } | ||
| 1073 | } | 1106 | } |
| 1074 | }) | 1107 | }) |
| 1075 | console.log('未领取的券列表-----------', couponArr); | 1108 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1079,6 +1112,17 @@ Page({ | @@ -1079,6 +1112,17 @@ Page({ | ||
| 1079 | } | 1112 | } |
| 1080 | }) | 1113 | }) |
| 1081 | }, | 1114 | }, |
| 1115 | + // 计算免费券有效期的起始、结束日期 | ||
| 1116 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1117 | + console.log(cdate, startOffset, endOffset); | ||
| 1118 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1119 | + startDate.setHours(0, 0, 0, 0); | ||
| 1120 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1121 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1122 | + endDate.setHours(23, 59, 59, 0); | ||
| 1123 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1124 | + return { useStime, useEtime }; | ||
| 1125 | + }, | ||
| 1082 | // 处理优惠券不可用日期数据 | 1126 | // 处理优惠券不可用日期数据 |
| 1083 | hasConsecutiveSelect(arr, type) { | 1127 | hasConsecutiveSelect(arr, type) { |
| 1084 | let firstTitle = null; | 1128 | let firstTitle = null; |
| @@ -109,7 +109,8 @@ | @@ -109,7 +109,8 @@ | ||
| 109 | </view> | 109 | </view> |
| 110 | </block> | 110 | </block> |
| 111 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 111 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 112 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 112 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 113 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 113 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 114 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 114 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 115 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 115 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 116 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
| @@ -918,8 +918,9 @@ Page({ | @@ -918,8 +918,9 @@ Page({ | ||
| 918 | }).then(res => { | 918 | }).then(res => { |
| 919 | if (res.data.length > 0) { | 919 | if (res.data.length > 0) { |
| 920 | let couponData = res.data[0] | 920 | let couponData = res.data[0] |
| 921 | + let data = couponData.expiration_date ? util.determine(couponData.expiration_date) : ''; | ||
| 921 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 | 922 | // showCoupon 代表赠送的券没过有效期 && 是开启状态 |
| 922 | - couponData.showCoupon = (this.data.dataStr<(couponData.etime*1) && couponData.is_open=='1') ? '1' : '0'; | 923 | + couponData.showCoupon = (((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && couponData.is_open == '1') ? '1' : '0'; |
| 923 | console.log('邀请函--------------------评价赠送的优惠券',couponData); | 924 | console.log('邀请函--------------------评价赠送的优惠券',couponData); |
| 924 | this.setData({ | 925 | this.setData({ |
| 925 | couponData:res.data[0] | 926 | couponData:res.data[0] |
| @@ -933,14 +934,18 @@ Page({ | @@ -933,14 +934,18 @@ Page({ | ||
| 933 | id: obj.map(item => item.id).join(','), | 934 | id: obj.map(item => item.id).join(','), |
| 934 | }).then(res => { | 935 | }).then(res => { |
| 935 | if (res.data.length > 0) { | 936 | if (res.data.length > 0) { |
| 937 | + // valid_forever 1永久 0非永久 | ||
| 936 | let list = res.data.filter(item => { | 938 | let list = res.data.filter(item => { |
| 937 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 939 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 940 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 938 | }) | 941 | }) |
| 939 | list.forEach(detail => { | 942 | list.forEach(detail => { |
| 940 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 943 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 941 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 944 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 942 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 945 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 943 | detail.use = detail.use ? util.determine(detail.use) : ''; | 946 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 947 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 948 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 944 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 949 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 945 | let cash = detail.use.cash * 1; | 950 | let cash = detail.use.cash * 1; |
| 946 | let price = detail.price * 1; | 951 | let price = detail.price * 1; |
| @@ -1102,8 +1107,36 @@ Page({ | @@ -1102,8 +1107,36 @@ Page({ | ||
| 1102 | } | 1107 | } |
| 1103 | list.forEach(item=>{ | 1108 | list.forEach(item=>{ |
| 1104 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 1109 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 1105 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 1106 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 1110 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 1111 | + const detail = coupon_dataList[idx]; | ||
| 1112 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 1113 | + detail.cdate = detail.cdate * 1; | ||
| 1114 | + detail.useStime = ''; | ||
| 1115 | + detail.useEtime = ''; | ||
| 1116 | + let condition = detail.aexpiration | ||
| 1117 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 1118 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 1119 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 1120 | + } | ||
| 1121 | + if (condition.valid_forever === '1') { | ||
| 1122 | + detail.foreverText = '永久有效'; | ||
| 1123 | + } | ||
| 1124 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 1125 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 1126 | + detail.useStime = obj.useStime; | ||
| 1127 | + detail.useEtime = obj.useEtime; | ||
| 1128 | + } | ||
| 1129 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 1130 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 1131 | + detail.useStime = obj.useStime; | ||
| 1132 | + detail.useEtime = obj.useEtime; | ||
| 1133 | + } | ||
| 1134 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 1135 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 1136 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 1137 | + detail.useStime = obj.useStime; | ||
| 1138 | + detail.useEtime = obj.useEtime; | ||
| 1139 | + } | ||
| 1107 | } | 1140 | } |
| 1108 | }) | 1141 | }) |
| 1109 | console.log('未领取的券列表-----------', couponArr); | 1142 | console.log('未领取的券列表-----------', couponArr); |
| @@ -1113,6 +1146,17 @@ Page({ | @@ -1113,6 +1146,17 @@ Page({ | ||
| 1113 | } | 1146 | } |
| 1114 | }) | 1147 | }) |
| 1115 | }, | 1148 | }, |
| 1149 | + // 计算免费券有效期的起始、结束日期 | ||
| 1150 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 1151 | + console.log(cdate, startOffset, endOffset); | ||
| 1152 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 1153 | + startDate.setHours(0, 0, 0, 0); | ||
| 1154 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1155 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 1156 | + endDate.setHours(23, 59, 59, 0); | ||
| 1157 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 1158 | + return { useStime, useEtime }; | ||
| 1159 | + }, | ||
| 1116 | // 处理优惠券不可用日期数据 | 1160 | // 处理优惠券不可用日期数据 |
| 1117 | hasConsecutiveSelect(arr, type) { | 1161 | hasConsecutiveSelect(arr, type) { |
| 1118 | let firstTitle = null; | 1162 | let firstTitle = null; |
| @@ -114,7 +114,8 @@ | @@ -114,7 +114,8 @@ | ||
| 114 | </view> | 114 | </view> |
| 115 | </block> | 115 | </block> |
| 116 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 116 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 117 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 117 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 118 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 118 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 119 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 119 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 120 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 120 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 121 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
| @@ -210,15 +210,19 @@ Page({ | @@ -210,15 +210,19 @@ Page({ | ||
| 210 | App.Activity.GetActivityById({ | 210 | App.Activity.GetActivityById({ |
| 211 | id: obj.map(item => item.id).join(','), | 211 | id: obj.map(item => item.id).join(','), |
| 212 | }).then(res => { | 212 | }).then(res => { |
| 213 | - if (res.data.length > 0) { | 213 | + if (res.data.length > 0) { |
| 214 | + // valid_forever 1永久 0非永久 | ||
| 214 | let list = res.data.filter(item => { | 215 | let list = res.data.filter(item => { |
| 215 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 216 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 217 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 216 | }) | 218 | }) |
| 217 | list.forEach(detail => { | 219 | list.forEach(detail => { |
| 218 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 220 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 219 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 221 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 220 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 222 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 221 | detail.use = detail.use ? util.determine(detail.use) : ''; | 223 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 224 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 225 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 222 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 226 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 223 | let cash = detail.use.cash * 1; | 227 | let cash = detail.use.cash * 1; |
| 224 | let price = detail.price * 1; | 228 | let price = detail.price * 1; |
| @@ -294,8 +298,36 @@ Page({ | @@ -294,8 +298,36 @@ Page({ | ||
| 294 | }, []); | 298 | }, []); |
| 295 | list.forEach(item=>{ | 299 | list.forEach(item=>{ |
| 296 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 300 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 297 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 298 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 301 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 302 | + const detail = coupon_dataList[idx]; | ||
| 303 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 304 | + detail.cdate = detail.cdate * 1; | ||
| 305 | + detail.useStime = ''; | ||
| 306 | + detail.useEtime = ''; | ||
| 307 | + let condition = detail.aexpiration | ||
| 308 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 309 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 310 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 311 | + } | ||
| 312 | + if (condition.valid_forever === '1') { | ||
| 313 | + detail.foreverText = '永久有效'; | ||
| 314 | + } | ||
| 315 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 316 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 317 | + detail.useStime = obj.useStime; | ||
| 318 | + detail.useEtime = obj.useEtime; | ||
| 319 | + } | ||
| 320 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 321 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 322 | + detail.useStime = obj.useStime; | ||
| 323 | + detail.useEtime = obj.useEtime; | ||
| 324 | + } | ||
| 325 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 326 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 327 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 328 | + detail.useStime = obj.useStime; | ||
| 329 | + detail.useEtime = obj.useEtime; | ||
| 330 | + } | ||
| 299 | } | 331 | } |
| 300 | }) | 332 | }) |
| 301 | this.setData({ | 333 | this.setData({ |
| @@ -322,6 +354,17 @@ Page({ | @@ -322,6 +354,17 @@ Page({ | ||
| 322 | } | 354 | } |
| 323 | return couponList | 355 | return couponList |
| 324 | }, | 356 | }, |
| 357 | + // 计算免费券有效期的起始、结束日期 | ||
| 358 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 359 | + console.log(cdate, startOffset, endOffset); | ||
| 360 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 361 | + startDate.setHours(0, 0, 0, 0); | ||
| 362 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 363 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 364 | + endDate.setHours(23, 59, 59, 0); | ||
| 365 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 366 | + return { useStime, useEtime }; | ||
| 367 | + }, | ||
| 325 | // 处理优惠券不可用日期数据 | 368 | // 处理优惠券不可用日期数据 |
| 326 | hasConsecutiveSelect(arr, type) { | 369 | hasConsecutiveSelect(arr, type) { |
| 327 | let firstTitle = null; | 370 | let firstTitle = null; |
| @@ -30,7 +30,8 @@ | @@ -30,7 +30,8 @@ | ||
| 30 | </view> | 30 | </view> |
| 31 | </block> | 31 | </block> |
| 32 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 32 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 33 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 33 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 34 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 34 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 35 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 35 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 36 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 36 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 37 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
| @@ -244,15 +244,19 @@ Page({ | @@ -244,15 +244,19 @@ Page({ | ||
| 244 | App.Activity.GetActivityById({ | 244 | App.Activity.GetActivityById({ |
| 245 | id: obj.map(item => item.id).join(','), | 245 | id: obj.map(item => item.id).join(','), |
| 246 | }).then(res => { | 246 | }).then(res => { |
| 247 | - if (res.data.length > 0) { | 247 | + if (res.data.length > 0) { |
| 248 | + // valid_forever 1永久 0非永久 | ||
| 248 | let list = res.data.filter(item => { | 249 | let list = res.data.filter(item => { |
| 249 | - return this.data.dataStr < (item.etime * 1) && item.is_open == '1' | 250 | + let data = item.expiration_date ? util.determine(item.expiration_date) : ''; |
| 251 | + return ((data.valid_forever == '0' && this.data.dataStr < (data.etime * 1)) || data.valid_forever == '1') && item.is_open == '1' | ||
| 250 | }) | 252 | }) |
| 251 | list.forEach(detail => { | 253 | list.forEach(detail => { |
| 252 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; | 254 | detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : ''; |
| 253 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; | 255 | detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; |
| 254 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; | 256 | detail.arule = detail.arule ? util.determine(detail.arule) : ''; |
| 255 | detail.use = detail.use ? util.determine(detail.use) : ''; | 257 | detail.use = detail.use ? util.determine(detail.use) : ''; |
| 258 | + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : ''; | ||
| 259 | + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : ''; | ||
| 256 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { | 260 | if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) { |
| 257 | let cash = detail.use.cash * 1; | 261 | let cash = detail.use.cash * 1; |
| 258 | let price = detail.price * 1; | 262 | let price = detail.price * 1; |
| @@ -414,8 +418,36 @@ Page({ | @@ -414,8 +418,36 @@ Page({ | ||
| 414 | } | 418 | } |
| 415 | list.forEach(item=>{ | 419 | list.forEach(item=>{ |
| 416 | let idx = coupon_dataList.findIndex(b => b.id === item.id); | 420 | let idx = coupon_dataList.findIndex(b => b.id === item.id); |
| 417 | - if (idx!== null && idx!== undefined && coupon_dataList[idx]) { | ||
| 418 | - coupon_dataList[idx].resultCoupon = '1';//显示已领取 | 421 | + if (idx !== null && idx !== undefined && coupon_dataList[idx]) { |
| 422 | + const detail = coupon_dataList[idx]; | ||
| 423 | + detail.resultCoupon = '1'; // 显示已领取 | ||
| 424 | + detail.cdate = detail.cdate * 1; | ||
| 425 | + detail.useStime = ''; | ||
| 426 | + detail.useEtime = ''; | ||
| 427 | + let condition = detail.aexpiration | ||
| 428 | + if (condition.valid_forever === '0' && condition.stime && condition.etime) { | ||
| 429 | + detail.useStime = util.unixtoTime(condition.stime, 'YYYY-MM-DD'); | ||
| 430 | + detail.useEtime = util.unixtoTime(condition.etime, 'YYYY-MM-DD'); | ||
| 431 | + } | ||
| 432 | + if (condition.valid_forever === '1') { | ||
| 433 | + detail.foreverText = '永久有效'; | ||
| 434 | + } | ||
| 435 | + if (condition.valid_forever === '0' && condition.today) { | ||
| 436 | + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1); | ||
| 437 | + detail.useStime = obj.useStime; | ||
| 438 | + detail.useEtime = obj.useEtime; | ||
| 439 | + } | ||
| 440 | + if (condition.valid_forever === '0' && condition.tomorrow) { | ||
| 441 | + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1); | ||
| 442 | + detail.useStime = obj.useStime; | ||
| 443 | + detail.useEtime = obj.useEtime; | ||
| 444 | + } | ||
| 445 | + if (condition.valid_forever === '0' && condition.sday && condition.eday) { | ||
| 446 | + let eday = condition.sday == '1' ? (parseInt(condition.eday) - 1) : (parseInt(condition.eday) + 1) | ||
| 447 | + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, eday); | ||
| 448 | + detail.useStime = obj.useStime; | ||
| 449 | + detail.useEtime = obj.useEtime; | ||
| 450 | + } | ||
| 419 | } | 451 | } |
| 420 | }) | 452 | }) |
| 421 | console.log('未领取的券列表-----------', couponArr); | 453 | console.log('未领取的券列表-----------', couponArr); |
| @@ -425,6 +457,17 @@ Page({ | @@ -425,6 +457,17 @@ Page({ | ||
| 425 | } | 457 | } |
| 426 | }) | 458 | }) |
| 427 | }, | 459 | }, |
| 460 | + // 计算免费券有效期的起始、结束日期 | ||
| 461 | + setTimeRange(cdate, startOffset, endOffset) { | ||
| 462 | + console.log(cdate, startOffset, endOffset); | ||
| 463 | + const startDate = new Date((cdate + startOffset * 86400) * 1000); | ||
| 464 | + startDate.setHours(0, 0, 0, 0); | ||
| 465 | + const useStime = util.unixtoTime(startDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 466 | + const endDate = new Date((cdate + endOffset * 86400) * 1000); | ||
| 467 | + endDate.setHours(23, 59, 59, 0); | ||
| 468 | + const useEtime = util.unixtoTime(endDate.getTime() / 1000, 'YYYY-MM-DD'); | ||
| 469 | + return { useStime, useEtime }; | ||
| 470 | + }, | ||
| 428 | // 处理优惠券不可用日期数据 | 471 | // 处理优惠券不可用日期数据 |
| 429 | hasConsecutiveSelect(arr, type) { | 472 | hasConsecutiveSelect(arr, type) { |
| 430 | let firstTitle = null; | 473 | let firstTitle = null; |
| @@ -45,7 +45,8 @@ | @@ -45,7 +45,8 @@ | ||
| 45 | </view> | 45 | </view> |
| 46 | </block> | 46 | </block> |
| 47 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> | 47 | <block wx:if="{{item.is_type == '3' || item.is_type == '4'}}"> |
| 48 | - <view wx:if="{{item.is_type == '3' && item.aexpiration>0}}" class="bottom font24r">领取后{{item.aexpiration}}天有效</view> | 48 | + <view wx:if="{{(item.useStime && item.useEtime) || item.foreverText}}" class="bottom font24r">有效期:{{item.foreverText?item.foreverText : ''}}</view> |
| 49 | + <view wx:if="{{item.useStime && item.useEtime}}" class="bottom font24r nodate">{{item.useStime}} 至 {{item.useEtime}}</view> | ||
| 49 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> | 50 | <view wx:if="{{item.morText || item.noonText || item.noonText}}" class="bottom font24r">不可用日期:</view> |
| 50 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> | 51 | <view wx:if="{{item.morText}}" class="bottom font24r nodate">{{item.morText}}</view> |
| 51 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> | 52 | <view wx:if="{{item.noonText}}" class="bottom font24r nodate">{{item.noonText}}</view> |
-
Please register or login to post a comment