Showing
4 changed files
with
57 additions
and
8 deletions
@@ -58,14 +58,22 @@ | @@ -58,14 +58,22 @@ | ||
58 | {{/ifnot}} | 58 | {{/ifnot}} |
59 | <div class="count">x{{count}}</div> | 59 | <div class="count">x{{count}}</div> |
60 | </div> | 60 | </div> |
61 | - <p class="price"> | ||
62 | - <span class="market-price">¥{{price}}</span> | ||
63 | - {{#if isStudents}}<span class="vip fill-text">学</span>{{/if}} | ||
64 | - {{#if isVipPrice}}<span class="vip fill-text">VIP</span>{{/if}} | ||
65 | - </p> | ||
66 | - <div class="tags"> | ||
67 | - {{#if lowStocks}}<span class="low-stocks fill-text">库存不足</span>{{/if}} | ||
68 | - {{#appearDate}}<span class="appear-date">上市期:{{.}}</span>{{/appearDate}} | 61 | + <div class="bottom"> |
62 | + <div class="price{{#if reAddToCart}} pull-left{{/if}}"> | ||
63 | + <span class="market-price">¥{{price}}</span> | ||
64 | + {{#if isStudents}}<span class="vip fill-text">学</span>{{/if}} | ||
65 | + {{#if isVipPrice}}<span class="vip fill-text">VIP</span>{{/if}} | ||
66 | + </div> | ||
67 | + {{#if reAddToCart}} | ||
68 | + <div class="re-add pull-right"> | ||
69 | + <span>重新加入购物车</span> | ||
70 | + </div> | ||
71 | + {{^}} | ||
72 | + <div class="tags"> | ||
73 | + {{#if lowStocks}}<span class="low-stocks fill-text">库存不足</span>{{/if}} | ||
74 | + {{#appearDate}}<span class="appear-date">上市期:{{.}}</span>{{/appearDate}} | ||
75 | + </div> | ||
76 | + {{/if}} | ||
69 | </div> | 77 | </div> |
70 | </div> | 78 | </div> |
71 | </div> | 79 | </div> |
@@ -35,6 +35,9 @@ let goodObj = { | @@ -35,6 +35,9 @@ let goodObj = { | ||
35 | $('.good-item').on('click', '.name,.color-size-row,.img', function(e) { | 35 | $('.good-item').on('click', '.name,.color-size-row,.img', function(e) { |
36 | self.goodClick(e); | 36 | self.goodClick(e); |
37 | }); | 37 | }); |
38 | + $('.good-item').on('click', '.bottom .re-add', function(e) { | ||
39 | + self.reAddGood(e); | ||
40 | + }); | ||
38 | $('.check-all').on('click', function(e) { | 41 | $('.check-all').on('click', function(e) { |
39 | self.checkedAllClick(e); | 42 | self.checkedAllClick(e); |
40 | }); | 43 | }); |
@@ -215,6 +218,32 @@ let goodObj = { | @@ -215,6 +218,32 @@ let goodObj = { | ||
215 | }); | 218 | }); |
216 | 219 | ||
217 | }, | 220 | }, |
221 | + reAddGood(eles) { | ||
222 | + let self = this; | ||
223 | + | ||
224 | + loading.showLoading(); | ||
225 | + $.ajax({ | ||
226 | + type: 'post', | ||
227 | + url: '/cart/index/add', | ||
228 | + data: { | ||
229 | + productSku: $(eles.delegateTarget).data('id') | ||
230 | + }, | ||
231 | + dataType: 'json', | ||
232 | + complete: () => { | ||
233 | + loading.hideLoading(); | ||
234 | + }, | ||
235 | + success: function(result) { | ||
236 | + if (result.code === 200) { | ||
237 | + self.handle.refreshPage(); | ||
238 | + } else { | ||
239 | + tip.show(result.message); | ||
240 | + } | ||
241 | + }, | ||
242 | + error: function() { | ||
243 | + tip.show('网络异常'); | ||
244 | + } | ||
245 | + }); | ||
246 | + }, | ||
218 | delGood(eles) { | 247 | delGood(eles) { |
219 | let self = this; | 248 | let self = this; |
220 | let skuData = self.getSelectGoodData(eles).map(ele => { | 249 | let skuData = self.getSelectGoodData(eles).map(ele => { |
@@ -196,6 +196,14 @@ | @@ -196,6 +196,14 @@ | ||
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | + .bottom > .re-add > span { | ||
200 | + border: 1px solid #d0253b; | ||
201 | + padding: 4px; | ||
202 | + border-radius: 5px; | ||
203 | + color: #d0253b; | ||
204 | + font-size: 16px; | ||
205 | + } | ||
206 | + | ||
199 | .name-row { | 207 | .name-row { |
200 | display: flex; | 208 | display: flex; |
201 | 209 |
@@ -129,6 +129,10 @@ const formatCartGoods = (goodData, isAdvanceCart, isValid, inValidLow) => { | @@ -129,6 +129,10 @@ const formatCartGoods = (goodData, isAdvanceCart, isValid, inValidLow) => { | ||
129 | result.inValidLow = inValidLow; | 129 | result.inValidLow = inValidLow; |
130 | } | 130 | } |
131 | 131 | ||
132 | + if (inValidLow && goodData.storage_number > 0) { | ||
133 | + result.reAddToCart = true; | ||
134 | + } | ||
135 | + | ||
132 | // gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品; | 136 | // gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品; |
133 | if (!goodData.goods_type) { | 137 | if (!goodData.goods_type) { |
134 | result.inValid = true; | 138 | result.inValid = true; |
-
Please register or login to post a comment