详情页面购买数量优化
parent
1ac70cf7fc
commit
83a0b73105
|
|
@ -264,10 +264,10 @@
|
|||
<dd>
|
||||
<div class="am-input-group am-input-group-sm number-tag">
|
||||
<button class="am-input-group-label" id="min" type="button">-</button>
|
||||
<input type="number" class="am-form-field" value="1" id="text_box" min="1" max="{{$goods.inventory}}" data-original-max="{{$goods.inventory}}" />
|
||||
<input type="number" class="am-form-field" value="{{$goods.buy_min_number}}" id="text_box" min="{{$goods.buy_min_number}}" max="{{if empty($goods['buy_max_number'])}}{{$goods.inventory}}{{else /}}{{$goods.buy_max_number}}{{/if}}" data-original-max="{{$goods.inventory}}" />
|
||||
<button class="am-input-group-label" id="add" type="button">+</button>
|
||||
</div>
|
||||
<span class="tb-hidden stock-tips">库存<span class="stock" data-original-stock="{{$goods.inventory}}">{{$goods.inventory}}</span>{{$goods.inventory_unit}}</span>
|
||||
<span class="tb-hidden stock-tips">库存<span class="stock" data-original-stock="{{$goods.inventory}}" data-min-limit="{{$goods.buy_min_number}}" data-max-limit="{{$goods.buy_max_number}}" data-unit="{{$goods.inventory_unit}}">{{$goods.inventory}}</span>{{$goods.inventory_unit}}</span>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ form.am-form .am-form-group { padding-right: 5px; }
|
|||
.business-item ul { padding: 10px 3px 5px 5px; overflow: hidden; }
|
||||
.business-item ul li { border:1px solid transparent ;overflow: hidden; float: left; cursor: pointer; padding: 5px; border: 1px solid #eee; margin: 0 10px 10px 0; }
|
||||
.business-item ul li img { width: 36px; height: 36px; vertical-align: middle; }
|
||||
.business-item ul li.selected { border-color: #d2364c ; position: relative; }
|
||||
.business-item ul li:hover {border: 1px solid #d2364c;box-shadow: 0px 0 0px 1px #d2364c;}
|
||||
.business-item ul li.selected { border-color: #d2364c ; position: relative; box-shadow: 0px 0 0px 1px #d2364c; }
|
||||
.business-item ul li.selected i.icon-active { position: absolute; width: 10px; height: 10px; font-size: 0; line-height: 0; right: 0px; bottom: 0px; background: url(../images/sys-item-selected.gif) no-repeat right bottom; }
|
||||
@media only screen and (min-width:640px) {
|
||||
.business-item ul li {width:calc(33% - 5px); }
|
||||
|
|
@ -60,6 +61,6 @@ form.am-form .am-form-group { padding-right: 5px; }
|
|||
}
|
||||
.content-right ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
padding: 1px;
|
||||
margin: 10px 0 0 0;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 70 B After Width: | Height: | Size: 70 B |
|
|
@ -111,10 +111,24 @@ function CartAdd(e)
|
|||
{
|
||||
// 参数
|
||||
var type = e.attr('data-type');
|
||||
var stock = $('#text_box').val() || 0;
|
||||
if(stock <= 0 || stock < 1)
|
||||
var stock = parseInt($('#text_box').val()) || 1;
|
||||
var inventory = parseInt($('.stock-tips .stock').text());
|
||||
var min = $('.stock-tips .stock').data('min-limit') || 1;
|
||||
var max = $('.stock-tips .stock').data('max-limit') || 0;
|
||||
var unit = $('.stock-tips .stock').data('unit') || '';
|
||||
if(stock < min)
|
||||
{
|
||||
PromptCenter('购买数量有误');
|
||||
PromptCenter('最低起购数量'+min+unit);
|
||||
return false;
|
||||
}
|
||||
if(max > 0 && stock > max)
|
||||
{
|
||||
PromptCenter('最大限购数量'+max+unit);
|
||||
return false;
|
||||
}
|
||||
if(stock > inventory)
|
||||
{
|
||||
PromptCenter('库存数量'+inventory+unit);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -375,7 +389,7 @@ $(function() {
|
|||
$(this).find('ul>li').on('click', function()
|
||||
{
|
||||
// 切换规格购买数量清空
|
||||
$('#text_box').val(1);
|
||||
$('#text_box').val($('.stock-tips .stock').data('min-limit') || 1);
|
||||
|
||||
// 规格处理
|
||||
var length = $('.theme-signin-left .sku-items').length;
|
||||
|
|
@ -574,23 +588,38 @@ $(function() {
|
|||
});
|
||||
|
||||
//获得文本框对象
|
||||
var t = $('#text_box');
|
||||
var $sotck = $('#text_box');
|
||||
var min = $('.stock-tips .stock').data('min-limit') || 1;
|
||||
var max = $('.stock-tips .stock').data('max-limit') || 0;
|
||||
var unit = $('.stock-tips .stock').data('unit') || '';
|
||||
|
||||
//数量增加操作
|
||||
$('#add').on('click', function() {
|
||||
var stock = parseInt($('.stock-tips .stock').text());
|
||||
var number = parseInt(t.val());
|
||||
if(number < stock)
|
||||
$('#add').on('click', function()
|
||||
{
|
||||
var inventory = parseInt($('.stock-tips .stock').text());
|
||||
var number = parseInt($sotck.val())+1;
|
||||
if(max > 0 && number > max)
|
||||
{
|
||||
t.val(number + 1)
|
||||
} else {
|
||||
Prompt('超出库存数量');
|
||||
Prompt('最大限购数量'+max+unit);
|
||||
return false;
|
||||
}
|
||||
if(number > inventory)
|
||||
{
|
||||
Prompt('库存数量'+inventory+unit);
|
||||
return false;
|
||||
}
|
||||
$sotck.val(number);
|
||||
});
|
||||
//数量减少操作
|
||||
$('#min').on('click', function() {
|
||||
var value = parseInt(t.val())-1 || 1;
|
||||
t.val((value <= 1) ? 1 : value);
|
||||
$('#min').on('click', function()
|
||||
{
|
||||
var value = parseInt($sotckt.val())-1 || 1;
|
||||
if(value < min)
|
||||
{
|
||||
Prompt('最低起购数量'+min+unit);
|
||||
return false;
|
||||
}
|
||||
$sotck.val(value);
|
||||
});
|
||||
|
||||
// 评论
|
||||
|
|
|
|||
Loading…
Reference in New Issue