Authored by 郝肖肖

无优惠券提示

@@ -21,11 +21,9 @@ const index = (req, res, next) => { @@ -21,11 +21,9 @@ const index = (req, res, next) => {
21 title: '优惠券', 21 title: '优惠券',
22 pageFooter: true, 22 pageFooter: true,
23 list: result, 23 list: result,
24 - used: req.body.status === '1' ? true : false,  
25 localCss: true 24 localCss: true
26 }; 25 };
27 26
28 - req.body.page && (req.body.page !== '1' || req.body.status === '1') && (options.layout = false);  
29 res.render('coupons', options); 27 res.render('coupons', options);
30 }).catch(next); 28 }).catch(next);
31 }; 29 };
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 <p>限品类:{{sortLimit}}</p> 43 <p>限品类:{{sortLimit}}</p>
44 {{/if}} 44 {{/if}}
45 <p>特例商品(秒杀、限定、境外、预售等)暂不支持使用优惠券。</p> 45 <p>特例商品(秒杀、限定、境外、预售等)暂不支持使用优惠券。</p>
46 - <p>说明:金卡用户专用</p> 46 + {{#if explains}}<p>说明:{{explains}}</p>{{/if}}
47 </div> 47 </div>
48 </div> 48 </div>
49 {{/each}} 49 {{/each}}
  1 +<div class="coupon-not-result">
  2 + <i></i>
  3 + <p>您还没有优惠券!</p>
  4 + <a href="/product/new">随便逛逛</a>
  5 +</div>
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
33 <p>限品类:{{sortLimit}}</p> 33 <p>限品类:{{sortLimit}}</p>
34 {{/if}} 34 {{/if}}
35 <p>特例商品(秒杀、限定、境外、预售等)暂不支持使用优惠券。</p> 35 <p>特例商品(秒杀、限定、境外、预售等)暂不支持使用优惠券。</p>
36 - <p>说明:金卡用户专用</p> 36 + {{#if explains}}<p>说明:{{explains}}</p>{{/if}}
37 </div> 37 </div>
38 </div> 38 </div>
39 {{/each}} 39 {{/each}}
1 // 不要使用es6 1 // 不要使用es6
2 'use strict'; 2 'use strict';
3 3
4 -var $ = require('yoho-jquery');  
5 -var couponsListHbs = require('home/coupons-list.hbs'); 4 +var $ = require('yoho-jquery'),
  5 + couponsListHbs = require('home/coupons-list.hbs'),
  6 + notResultHbs = require('home/coupon-not-result.hbs');
6 7
7 var $couponTab1 = $('.coupon-tab1'), 8 var $couponTab1 = $('.coupon-tab1'),
8 $couponTab2 = $('.coupon-tab2'), 9 $couponTab2 = $('.coupon-tab2'),
@@ -46,29 +47,28 @@ couponFun = function() { @@ -46,29 +47,28 @@ couponFun = function() {
46 page: page 47 page: page
47 }, 48 },
48 success: function(data) { 49 success: function(data) {
49 - if (data.length <= 0) { 50 + var $activeDom;
  51 +
  52 + if (indexNum === 1) {
  53 + $activeDom = $couponTab2;
  54 + } else if (indexNum === 2) {
  55 + $activeDom = $couponTab3;
  56 + } else {
  57 + $activeDom = $couponTab1;
  58 + }
  59 +
  60 + if (page <= 1 && data.length <= 0) {
  61 + $activeDom.html(notResultHbs());
50 return false; 62 return false;
51 } 63 }
52 64
53 - if (page === 0 && data.length <= 0) { 65 + if (data.length <= 0) {
54 return false; 66 return false;
55 } 67 }
56 68
57 $tabDom.data('page', ++page); 69 $tabDom.data('page', ++page);
58 $tabDom.data('AjaxFlag', false); 70 $tabDom.data('AjaxFlag', false);
59 -  
60 - switch (indexNum * 1) {  
61 - case 0:  
62 - $couponTab1.append(couponsListHbs({list: data}));  
63 - break;  
64 - case 1:  
65 - $couponTab2.append(couponsListHbs({list: data}));  
66 - break;  
67 - case 2:  
68 - $couponTab3.append(couponsListHbs({list: data}));  
69 - break;  
70 - default: break;  
71 - } 71 + $activeDom.append(couponsListHbs({list: data}));
72 window.rePosFooter(); // 重新计算底部位置 72 window.rePosFooter(); // 重新计算底部位置
73 } 73 }
74 }); 74 });
@@ -105,3 +105,11 @@ $('.coupon-list').on('click', '.info-btn', function() { @@ -105,3 +105,11 @@ $('.coupon-list').on('click', '.info-btn', function() {
105 $this.closest('.coupon-group').find('.coupon-footer').addClass('hide'); 105 $this.closest('.coupon-group').find('.coupon-footer').addClass('hide');
106 } 106 }
107 }); 107 });
  108 +
  109 +$('body').css({'background-color': '#f2f2f2'});
  110 +
  111 +// 首屏渲染无结果判断
  112 +if ($('.coupon-tab1').find('.coupon-group').length <= 0) {
  113 + $('.coupon-tab1').html(notResultHbs());
  114 + window.rePosFooter(); // 重新计算底部位置
  115 +}
1 .my-coupon-page { 1 .my-coupon-page {
2 - background-color: #f2f2f2;  
3 -  
4 .coupon-tab { 2 .coupon-tab {
5 height: 90px; 3 height: 90px;
6 line-height: 90px; 4 line-height: 90px;
@@ -140,4 +138,47 @@ @@ -140,4 +138,47 @@
140 border-top: 1px dashed #fff; 138 border-top: 1px dashed #fff;
141 } 139 }
142 } 140 }
  141 +
  142 + .coupon-not-result {
  143 + width: 100%;
  144 + height: auto;
  145 + overflow: hidden;
  146 + position: fixed;
  147 + left: 0;
  148 + top: 50%;
  149 + margin-top: -162px;
  150 +
  151 + i {
  152 + width: 100%;
  153 + height: 120px;
  154 + overflow: hidden;
  155 + display: block;
  156 + background: resolve("home/employ/not.png") center top no-repeat;
  157 + background-size: auto 100%;
  158 + }
  159 +
  160 + p {
  161 + width: 100%;
  162 + height: auto;
  163 + overflow: hidden;
  164 + padding: 20px 0 0;
  165 + font-size: 32px;
  166 + text-align: center;
  167 + color: #444;
  168 + }
  169 +
  170 + a {
  171 + width: 73.75%;
  172 + height: 80px;
  173 + overflow: hidden;
  174 + font-size: 36px;
  175 + line-height: 80px;
  176 + display: block;
  177 + background: #444;
  178 + color: #fff;
  179 + text-align: center;
  180 + margin: 60px auto 0;
  181 + border-radius: 0.2rem;
  182 + }
  183 + }
143 } 184 }