Authored by 郭成尧

Merge branch 'feature/coupon' into release/180420

... ... @@ -51,6 +51,12 @@
</div>
{{/each}}
{{/ usableCouponsList}}
{{#isEqualOr usableCouponNumStr '0'}}
<div class="no-conpon-now">
<div class="icon-not"></div>
<p>暂无优惠券</p>
</div>
{{/isEqualOr}}
</div>
<div class="coupon-list unusable hide">
{{#unusableCouponsList}}
... ... @@ -79,6 +85,12 @@
</div>
{{/each}}
{{/ unusableCouponsList}}
{{#isEqualOr unusableCouponNumStr '0'}}
<div class="no-conpon-now">
<div class="icon-not"></div>
<p>暂无优惠券</p>
</div>
{{/isEqualOr}}
</div>
<div class="use-now" id="useNowBox">
{{#couponPay}}
... ...
... ... @@ -13,8 +13,8 @@ const _couponProcess = (couponList, type) => {
coupon.is_used = true;
}
if (type === 'use' || coupon.is_overtime === 'Y') {
coupon.usedOrOvertime = true;
if (type === 'use' || coupon.is_overtime === 'Y' || coupon.is_invalid === 'Y') {
coupon.usedOvertimeOrInValid = true;
}
coupon.useNowLink = helpers.urlFormat(`/list/cc${coupon.coupon_code}-cd${coupon.coupon_id}?intro_text=以下商品可使用【${coupon.coupon_name}】优惠券&title=优惠活动商品`, '', null); // eslint-disable-line
... ... @@ -90,23 +90,11 @@ class CouponNew {
uid, type, filter, page
});
let couponsList = _.get(couponApi, 'data.couponList', []);
let showUsedTip = false;
if (couponsList && couponsList.length) {
if (type === 'use') {
showUsedTip = '以上是近期已使用的优惠券';
}
if (type === 'overtime') {
showUsedTip = '以上是近期已失效的优惠券';
}
}
if (couponsList && couponsList.length) {
couponsList = _couponProcess(couponsList, type);
res.render('coupons/coupons', {
couponsList,
showUsedTip,
layout: false
});
} else {
... ...
{{#couponsList}}
{{> coupons/coupon}}
{{/ couponsList}}
{{#if showUsedTip}}
<div class="used-tip">
<hr>
<span>{{showUsedTip}}</span>
<hr>
</div>
{{/if}}
... ...
... ... @@ -28,6 +28,12 @@
{{> coupons/coupon}}
{{/ couponList}}
</div>
<div class="used-tip hide">
<hr>
<span class="used">以上是近期已使用的优惠券</span>
<span class="invalid">以上是近期已失效的优惠券</span>
<hr>
</div>
<div class="no-conpon-now{{#if couponList}} hide{{/if}}">
<div class="icon-not"></div>
<p>暂无优惠券</p>
... ...
<section class="coupon-section" data-code="{{coupon_code}}" data-id="{{coupon_id}}">
<div class="coupon{{#isEqualOr is_overtime 'Y'}} coupon-overtime{{/isEqualOr}}{{#if is_used}} coupon-used{{/if}}">
<div class="coupon-left{{#unless usedOrOvertime}}{{#isEqualOr catalog 200}} coupon-left-activity{{/isEqualOr}}{{#isEqualOr catalog 300}} coupon-left-freight{{/isEqualOr}}{{#isEqualOr catalog 100}} coupon-left-shop{{/isEqualOr}}{{/unless}}">
<div class="coupon{{#isEqualOr is_overtime 'Y'}} coupon-overtime{{/isEqualOr}}{{#if is_used}} coupon-used{{/if}}{{#isEqualOr is_invalid 'Y'}} coupon-invalid{{/isEqualOr}}">
<div class="coupon-left{{#unless usedOvertimeOrInValid}}{{#isEqualOr catalog 200}} coupon-left-activity{{/isEqualOr}}{{#isEqualOr catalog 300}} coupon-left-freight{{/isEqualOr}}{{#isEqualOr catalog 100}} coupon-left-shop{{/isEqualOr}}{{/unless}}">
<p class="value"><span>{{coupon_value_str}}</span></p>
{{#if use_rule}}
<p class="threshold">{{use_rule}}</p>
... ... @@ -11,25 +11,29 @@
<span class="{{#isEqualOr catalog 200}}type-activity{{/isEqualOr}}{{#isEqualOr catalog 300}}type-freight{{/isEqualOr}}{{#isEqualOr catalog 100}}type-shop{{/isEqualOr}}">[{{catalog_name}}]</span> {{coupon_name}}</p>
<p class="time">{{coupon_validity}}</p>
{{#if notes}}
<p>
<p class="use-intro">
<span class="show-intro-btn">使用说明</span>
<span class="iconfont icon-down show-intro-btn show-intro-arrow"></span>
</p>
{{/if}}
<span class="tip"></span>
</div>
{{#isEqualOr is_overtime 'Y'}}
{{#if usedOvertimeOrInValid}}
{{#isEqualOr is_overtime 'Y'}}
<div class="stamp overtime-stamp"></div>
{{^}}
{{#if is_used}}
<div class="stamp used-stamp"></div>
{{/isEqualOr}}
{{#isEqualOr is_invalid 'Y'}}
<div class="stamp invalid-stamp"></div>
{{/isEqualOr}}
{{#if is_used}}
<div class="stamp used-stamp"></div>
{{/if}}
{{^}}
<a href="{{useNowLink}}" class="use-now">立即使用</a>
{{#isEqualOr is_overdue_soon 'Y'}}
<span class="top-tip"></span>
{{/isEqualOr}}
{{/if}}
{{#isEqualOr is_overdue_soon 'Y'}}
<span class="top-tip"></span>
{{/isEqualOr}}
{{/if}}
</div>
<ul class="coupon-intro hide">
{{#notes}}
... ...
... ... @@ -113,16 +113,16 @@ class SelectCouponController extends Page {
data: {
couponCode: couponCode
}
}).then(function(res) {
}).then(res => {
if (res.message) {
tip.show(res.message);
}
if (res.code === 200) {
this.orderInfo('usable_usual_code', res.data.coupon_code);
this.selectCouponCodes.push(couponCode);
tip.show('优惠券可用');
setTimeout(function() {
setTimeout(() => {
location.reload();
}, 500);
}, 100);
}
});
}
... ...
... ... @@ -18,7 +18,8 @@ class ConponController extends Page {
couponSection: $('.coupon-section'),
noConponNow: $('.no-conpon-now'),
exchangeCouponBtn: $('#exchangeCouponBtn'),
couponCodeInput: $('input[name=couponCodeInput]')
couponCodeInput: $('input[name=couponCodeInput]'),
usedTip: $('.used-tip')
};
this.view.filterBtn.on('click', this.tabChange.bind(this));
... ... @@ -78,15 +79,15 @@ class ConponController extends Page {
data: {
couponCode: couponCode
}
}).then(function(res) {
}).then(res => {
if (res.message) {
tip.show(res.message);
}
if (res.code === 200) {
tip.show('优惠券可用');
setTimeout(function() {
setTimeout(() => {
location.reload();
}, 500);
}, 100);
}
});
}
... ... @@ -180,10 +181,18 @@ class ConponController extends Page {
// 筛选参数更改
if (itemClicked.hasClass('no-used')) {
this.couponType = 'notuse';
this.view.usedTip.addClass('hide');
this.view.usedTip.find('span').addClass('hide');
} else if (itemClicked.hasClass('used')) {
this.couponType = 'use';
this.view.usedTip.removeClass('hide');
this.view.usedTip.find('.used').removeClass('hide');
this.view.usedTip.find('.invalid').addClass('hide');
} else if (itemClicked.hasClass('invalid')) {
this.couponType = 'overtime';
this.view.usedTip.removeClass('hide');
this.view.usedTip.find('.invalid').removeClass('hide');
this.view.usedTip.find('.used').addClass('hide');
} else {
tip.show('未知券类型');
}
... ...
... ... @@ -192,13 +192,19 @@ body {
}
.info > .title {
width: 450px;
width: 400px;
font-size: 24px;
color: #444;
margin-bottom: 46px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.info > .time {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.info > .desc {
... ... @@ -294,4 +300,22 @@ body {
.hide {
display: none;
}
.no-conpon-now {
text-align: center;
padding-top: 262px;
color: #b0b0b0;
.icon-not {
width: 208px;
height: 130px;
background-image: resolve("home/employ/not.png");
background-size: 100% 100%;
margin: auto auto 30px;
}
p {
font-size: 28px;
}
}
}
... ...
... ... @@ -172,9 +172,6 @@ body {
font-size: 22px;
color: #b0b0b0;
position: relative;
display: flex;
flex-direction: column;
align-content: space-between;
.type-shop {
color: #efaf46;
... ... @@ -199,7 +196,14 @@ body {
}
.time {
margin-bottom: 26px;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.use-intro {
position: absolute;
bottom: 22px;
}
.tip {
... ... @@ -242,6 +246,10 @@ body {
background-image: resolve("home/coupon/used.png");
}
.invalid-stamp {
background-image: resolve("home/coupon/invalid.png");
}
.top-tip {
width: 84px;
height: 84px;
... ... @@ -259,6 +267,7 @@ body {
}
}
.coupon-invalid,
.coupon-used,
.coupon-overtime {
> .coupon-left > p {
... ... @@ -315,7 +324,6 @@ body {
.used-tip {
display: flex;
margin-top: 40px;
span {
color: #b0b0b0;
... ...