coupon-list-name-modified
Showing
3 changed files
with
19 additions
and
17 deletions
@@ -249,14 +249,16 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime, | @@ -249,14 +249,16 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime, | ||
249 | */ | 249 | */ |
250 | exports.getCouponList = uid => { | 250 | exports.getCouponList = uid => { |
251 | let result = { | 251 | let result = { |
252 | + availableCoupons: [], | ||
253 | + usableFreesCoupons: [], | ||
252 | notAvailableCoupons: [], | 254 | notAvailableCoupons: [], |
253 | - coupons: [] | ||
254 | }; | 255 | }; |
255 | 256 | ||
256 | return shoppingAPI.listCoupon(uid) | 257 | return shoppingAPI.listCoupon(uid) |
257 | .then(coupons => { | 258 | .then(coupons => { |
258 | - let unusableCoupons = _.get(coupons, 'data.unusable_coupons', []); | ||
259 | let usableCoupons = _.get(coupons, 'data.usable_coupons', []); | 259 | let usableCoupons = _.get(coupons, 'data.usable_coupons', []); |
260 | + let freesCoupons = _.get(coupons, 'usable_frees_coupons', []); | ||
261 | + let unusableCoupons = _.get(coupons, 'data.unusable_coupons', []); | ||
260 | 262 | ||
261 | let procCouponsData = coupon => { | 263 | let procCouponsData = coupon => { |
262 | return { | 264 | return { |
@@ -267,8 +269,9 @@ exports.getCouponList = uid => { | @@ -267,8 +269,9 @@ exports.getCouponList = uid => { | ||
267 | }; | 269 | }; |
268 | }; | 270 | }; |
269 | 271 | ||
270 | - result.notAvailableCoupons = unusableCoupons.map(procCouponsData); | ||
271 | - result.coupons = usableCoupons.map(procCouponsData); | 272 | + result.availableCoupons = usableCoupons.map(procCouponsData); // 可用优惠券 |
273 | + result.usableFreesCoupons = freesCoupons.map(procCouponsData); // 运费券 | ||
274 | + result.notAvailableCoupons = unusableCoupons.map(procCouponsData); // 不可用优惠券 | ||
272 | 275 | ||
273 | return result; | 276 | return result; |
274 | }, | 277 | }, |
1 | -{{#coupons}} | ||
2 | - {{^ notAvailable}} | 1 | +{{#availableCoupons}} |
3 | <section class="coupon"> | 2 | <section class="coupon"> |
4 | <div class="coupon-title">{{ couponDetailInfomation }}</div> | 3 | <div class="coupon-title">{{ couponDetailInfomation }}</div> |
5 | <div class="coupon-content"> | 4 | <div class="coupon-content"> |
@@ -13,5 +12,4 @@ | @@ -13,5 +12,4 @@ | ||
13 | </div> | 12 | </div> |
14 | </div> | 13 | </div> |
15 | </section> | 14 | </section> |
16 | - {{/ notAvailable}} | ||
17 | -{{/coupons}} | 15 | +{{/availableCoupons}} |
@@ -98,22 +98,22 @@ $notUseCoupon.on('click', function() { | @@ -98,22 +98,22 @@ $notUseCoupon.on('click', function() { | ||
98 | }); | 98 | }); |
99 | 99 | ||
100 | function getCouponHandle(allCoupons) { | 100 | function getCouponHandle(allCoupons) { |
101 | - let notAvailableCoupons, | ||
102 | - coupons; | ||
103 | - | ||
104 | - // 把可用和不可用的优惠券分离出来 | ||
105 | - notAvailableCoupons = allCoupons.notAvailableCoupons; | ||
106 | - coupons = allCoupons.coupons; | 101 | + let availableCoupons = allCoupons.availableCoupons; |
102 | + let usableFreesCoupons = allCoupons.freesCoupons; | ||
103 | + let notAvailableCoupons = allCoupons.notAvailableCoupons; | ||
107 | 104 | ||
108 | // 没有优惠券 | 105 | // 没有优惠券 |
109 | - if (!(notAvailableCoupons.length || coupons.length)) { | 106 | + if (!(availableCoupons.length || usableFreesCoupons)) { |
110 | $('.coupon-wrap').html($('#tmpl-no-coupon').html()); | 107 | $('.coupon-wrap').html($('#tmpl-no-coupon').html()); |
111 | fixedLayOut(); | 108 | fixedLayOut(); |
112 | return; | 109 | return; |
113 | } | 110 | } |
114 | 111 | ||
112 | + $.each(availableCoupons, function(i, coupon) { | ||
113 | + coupon.couponValue = Math.floor(coupon.couponValue); | ||
114 | + }); | ||
115 | 115 | ||
116 | - $.each(coupons, function(i, coupon) { | 116 | + $.each(usableFreesCoupons, function(i, coupon) { |
117 | coupon.couponValue = Math.floor(coupon.couponValue); | 117 | coupon.couponValue = Math.floor(coupon.couponValue); |
118 | }); | 118 | }); |
119 | 119 | ||
@@ -123,7 +123,8 @@ function getCouponHandle(allCoupons) { | @@ -123,7 +123,8 @@ function getCouponHandle(allCoupons) { | ||
123 | 123 | ||
124 | // 渲染可用的优惠券 | 124 | // 渲染可用的优惠券 |
125 | $couponList.append(conponTmpl({ | 125 | $couponList.append(conponTmpl({ |
126 | - coupons: coupons | 126 | + availableCoupons: availableCoupons, |
127 | + usableFreesCoupons: usableFreesCoupons | ||
127 | })).find('.employ-main').on('touchstart', function() { | 128 | })).find('.employ-main').on('touchstart', function() { |
128 | let couponCode = $(this).data('coupon-code'); | 129 | let couponCode = $(this).data('coupon-code'); |
129 | 130 |
-
Please register or login to post a comment