Authored by 郭成尧

re-add-to-cart

... ... @@ -58,14 +58,22 @@
{{/ifnot}}
<div class="count">x{{count}}</div>
</div>
<p class="price">
<span class="market-price">¥{{price}}</span>
{{#if isStudents}}<span class="vip fill-text"></span>{{/if}}
{{#if isVipPrice}}<span class="vip fill-text">VIP</span>{{/if}}
</p>
<div class="tags">
{{#if lowStocks}}<span class="low-stocks fill-text">库存不足</span>{{/if}}
{{#appearDate}}<span class="appear-date">上市期:{{.}}</span>{{/appearDate}}
<div class="bottom">
<div class="price{{#if reAddToCart}} pull-left{{/if}}">
<span class="market-price">¥{{price}}</span>
{{#if isStudents}}<span class="vip fill-text"></span>{{/if}}
{{#if isVipPrice}}<span class="vip fill-text">VIP</span>{{/if}}
</div>
{{#if reAddToCart}}
<div class="re-add pull-right">
<span>重新加入购物车</span>
</div>
{{^}}
<div class="tags">
{{#if lowStocks}}<span class="low-stocks fill-text">库存不足</span>{{/if}}
{{#appearDate}}<span class="appear-date">上市期:{{.}}</span>{{/appearDate}}
</div>
{{/if}}
</div>
</div>
</div>
... ...
... ... @@ -35,6 +35,9 @@ let goodObj = {
$('.good-item').on('click', '.name,.color-size-row,.img', function(e) {
self.goodClick(e);
});
$('.good-item').on('click', '.bottom .re-add', function(e) {
self.reAddGood(e);
});
$('.check-all').on('click', function(e) {
self.checkedAllClick(e);
});
... ... @@ -215,6 +218,32 @@ let goodObj = {
});
},
reAddGood(eles) {
let self = this;
loading.showLoading();
$.ajax({
type: 'post',
url: '/cart/index/add',
data: {
productSku: $(eles.delegateTarget).data('id')
},
dataType: 'json',
complete: () => {
loading.hideLoading();
},
success: function(result) {
if (result.code === 200) {
self.handle.refreshPage();
} else {
tip.show(result.message);
}
},
error: function() {
tip.show('网络异常');
}
});
},
delGood(eles) {
let self = this;
let skuData = self.getSelectGoodData(eles).map(ele => {
... ...
... ... @@ -196,6 +196,14 @@
}
}
.bottom > .re-add > span {
border: 1px solid #d0253b;
padding: 4px;
border-radius: 5px;
color: #d0253b;
font-size: 16px;
}
.name-row {
display: flex;
... ...
... ... @@ -129,6 +129,10 @@ const formatCartGoods = (goodData, isAdvanceCart, isValid, inValidLow) => {
result.inValidLow = inValidLow;
}
if (inValidLow && goodData.storage_number > 0) {
result.reAddToCart = true;
}
// gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
if (!goodData.goods_type) {
result.inValid = true;
... ...