Authored by 郭成尧

coupon-list-name-modified

... ... @@ -249,14 +249,16 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime,
*/
exports.getCouponList = uid => {
let result = {
availableCoupons: [],
usableFreesCoupons: [],
notAvailableCoupons: [],
coupons: []
};
return shoppingAPI.listCoupon(uid)
.then(coupons => {
let unusableCoupons = _.get(coupons, 'data.unusable_coupons', []);
let usableCoupons = _.get(coupons, 'data.usable_coupons', []);
let freesCoupons = _.get(coupons, 'usable_frees_coupons', []);
let unusableCoupons = _.get(coupons, 'data.unusable_coupons', []);
let procCouponsData = coupon => {
return {
... ... @@ -267,8 +269,9 @@ exports.getCouponList = uid => {
};
};
result.notAvailableCoupons = unusableCoupons.map(procCouponsData);
result.coupons = usableCoupons.map(procCouponsData);
result.availableCoupons = usableCoupons.map(procCouponsData); // 可用优惠券
result.usableFreesCoupons = freesCoupons.map(procCouponsData); // 运费券
result.notAvailableCoupons = unusableCoupons.map(procCouponsData); // 不可用优惠券
return result;
},
... ...
{{#coupons}}
{{^ notAvailable}}
{{#availableCoupons}}
<section class="coupon">
<div class="coupon-title">{{ couponDetailInfomation }}</div>
<div class="coupon-content">
... ... @@ -13,5 +12,4 @@
</div>
</div>
</section>
{{/ notAvailable}}
{{/coupons}}
{{/availableCoupons}}
\ No newline at end of file
... ...
... ... @@ -98,22 +98,22 @@ $notUseCoupon.on('click', function() {
});
function getCouponHandle(allCoupons) {
let notAvailableCoupons,
coupons;
// 把可用和不可用的优惠券分离出来
notAvailableCoupons = allCoupons.notAvailableCoupons;
coupons = allCoupons.coupons;
let availableCoupons = allCoupons.availableCoupons;
let usableFreesCoupons = allCoupons.freesCoupons;
let notAvailableCoupons = allCoupons.notAvailableCoupons;
// 没有优惠券
if (!(notAvailableCoupons.length || coupons.length)) {
if (!(availableCoupons.length || usableFreesCoupons)) {
$('.coupon-wrap').html($('#tmpl-no-coupon').html());
fixedLayOut();
return;
}
$.each(availableCoupons, function(i, coupon) {
coupon.couponValue = Math.floor(coupon.couponValue);
});
$.each(coupons, function(i, coupon) {
$.each(usableFreesCoupons, function(i, coupon) {
coupon.couponValue = Math.floor(coupon.couponValue);
});
... ... @@ -123,7 +123,8 @@ function getCouponHandle(allCoupons) {
// 渲染可用的优惠券
$couponList.append(conponTmpl({
coupons: coupons
availableCoupons: availableCoupons,
usableFreesCoupons: usableFreesCoupons
})).find('.employ-main').on('touchstart', function() {
let couponCode = $(this).data('coupon-code');
... ...