提交 556ef838 编写于 作者: D Devil

商品规格快捷操作

上级 08771363
......@@ -8,7 +8,7 @@
* @param {[array]} arr1 [要进行笛卡尔积的二维数组]
* @param {[array]} arr2 [最终实现的笛卡尔积组合,可不写]
*/
function spec_cartesian(arr1, arr2)
function SpecCartesian(arr1, arr2)
{
// 去除第一个元素
var result = [];
......@@ -40,7 +40,7 @@ function spec_cartesian(arr1, arr2)
// 递归进行拼接
if(arr1.length > 0)
{
result = spec_cartesian(arr1, result);
result = SpecCartesian(arr1, result);
}
// 返回最终笛卡尔积
......@@ -326,7 +326,6 @@ $(function()
// 生成规格
$('.quick-spec-created').on('click', function()
{
var spec = [];
$('.spec-quick table tbody tr').each(function(k, v)
{
......@@ -348,46 +347,9 @@ $(function()
if(spec.length <= 0)
{
Prompt('快捷操作规格为空');
return false;
}
spec = [
{
"title": "套餐",
"value": ["套餐1", "套餐2", "套餐3"]
},
{
"title": "颜色",
"value": ["黑色", "红色"]
},
{
"title": "容量",
"value": ["64G", "128G"]
},
{
"title": "配置",
"value": ["高级", "钻石", "555"]
},
{
"title": "测试5",
"value": ["测试1", "测试2"]
}
];
spec = [
{
"title": "颜色",
"value": ["黑色", "白色", "蓝色"]
},
{
"title": "尺码",
"value": ["S", "M", "L", "XL", "XXL"]
},
{
"title": "长度",
"value": ["5分裤", "7分裤", "9分裤", "长裤", "测试"]
}
];
// 移除规格列
$('.specifications-table .title-nav-remove').trigger('click');
......@@ -400,21 +362,36 @@ $(function()
html += '<i class="am-close am-close-spin title-nav-remove" data-index="'+index+'">&times;</i>';
html += '<input type="text" name="specifications_name_'+index+'" value="'+spec[i]['title']+'" placeholder="规格名" class="am-radius" data-validation-message="请填写规格名" required />';
html += '</th>';
console.log(spec[i])
$('.title-start').before(html);
// value
html = '<td class="table-value table-value-'+index+'">';
html += '<input type="text" name="specifications_value_'+index+'[]" placeholder="规格值" class="am-radius" data-validation-message="请填写规格值" required />';
html += '<input type="text" name="specifications_value_'+index+'[]" value="'+(spec[i]['value'][0] || "")+'" placeholder="规格值" class="am-radius" data-validation-message="请填写规格值" required />';
html += '</td>';
$('.value-start').before(html);
}
// 自动生成规格
var data = spec_cartesian(spec);
console.log(data);
var data = SpecCartesian(spec);
for(var i=1; i<data.length; i++)
{
// 添加规格值
var html = $('.specifications-table').find('tbody tr:last').prop('outerHTML');
if(html.indexOf('<!--operation-->') >= 0)
{
html = html.replace(/<!--operation-->/ig, '<span class="fs-12 cr-blue c-p m-r-5 line-copy">复制</span> <span class="fs-12 cr-red c-p line-remove">移除</span>');
}
$('.specifications-table').append(html);
$('.specifications-table').find('tbody tr:last').attr('class', 'line-'+index+' line-not-first');
$('.specifications-table').find('tbody tr:last').attr('data-line-tag', '.line-'+index);
// 规格值
var temp_spec = data[i].split(',');
for(var k in temp_spec)
{
// 规格值赋值
$('.specifications-table').find('tbody tr:last').find('td:eq('+k+') input').val(temp_spec[k]);
}
}
});
});
\ No newline at end of file
$(function()
{
// 计算选择的商品总数和总价
function cart_base_total()
function CartBaseTotal()
{
var total_stock = 0;
var total_price = 0.00;
......@@ -72,7 +72,7 @@ $(function()
self.parents('tr').find('.wap-number').text('x'+stock);
// 计算选择的商品总数和总价
cart_base_total();
CartBaseTotal();
} else {
PromptCenter(result.msg);
}
......@@ -130,19 +130,19 @@ $(function()
}
// 计算选择的商品总数和总价
cart_base_total();
CartBaseTotal();
});
// 选择
$('.am-table input[type="checkbox"]').on('click', function()
{
// 计算选择的商品总数和总价
cart_base_total();
CartBaseTotal();
});
// 导航固定
var nav_top = $('.cart-nav').length > 0 ? $('.cart-nav').offset().top : 0;
function cart_nav_pop()
function CartNavPop()
{
var scroll = $(document).scrollTop();
var location = scroll+$(window).height()-100;
......@@ -156,24 +156,24 @@ $(function()
$('body').css({"padding-bottom":"0"});
}
}
cart_nav_pop();
CartNavPop();
$(window).scroll(function()
{
cart_nav_pop();
CartNavPop();
});
// 浏览器窗口实时事件
$(window).resize(function()
{
// 导航固定初始化
cart_nav_pop();
CartNavPop();
});
// 结算事件
$('.separate-submit').on('click', function()
{
// 计算选择的商品总数和总价
cart_base_total();
CartBaseTotal();
// 获取购物车id
var ids = $(this).parents('form').find('input[name="ids"]').val() || 0;
......
// 规格弹窗PC显示
function poptit_pc_show()
function PoptitPcShow()
{
$(document.body).css('position', 'static');
$('.theme-signin-left').scrollTop(0);
......@@ -7,7 +7,7 @@ function poptit_pc_show()
$('.theme-popover').slideDown(0);
}
// 规格弹窗关闭
function poptit_close()
function PoptitClose()
{
if($(window).width() < 1025)
{
......@@ -186,7 +186,7 @@ function CartAdd(e)
data: {"goods_id": $('.goods-detail').data('id'), "stock": stock, "spec": spec},
success: function(result)
{
poptit_close();
PoptitClose();
$.AMUI.progress.done();
$button.attr('disabled', false);
......@@ -200,7 +200,7 @@ function CartAdd(e)
},
error: function(xhr, type)
{
poptit_close();
PoptitClose();
$.AMUI.progress.done();
$button.attr('disabled', false);
PromptCenter('服务器错误');
......@@ -518,11 +518,11 @@ $(function() {
$('.theme-popover .confirm').attr('data-type', $(this).data('type'));
}
} else {
poptit_pc_show();
PoptitPcShow();
}
});
$('.theme-poptit .close, .btn-op .close').on('click', function() {
poptit_close();
PoptitClose();
});
// 购买
......@@ -568,7 +568,7 @@ $(function() {
data: {"id": $('.goods-detail').data('id')},
success: function(result)
{
poptit_close();
PoptitClose();
$.AMUI.progress.done();
if(result.code == 0)
......@@ -599,7 +599,7 @@ $(function() {
},
error: function(xhr, type)
{
poptit_close();
PoptitClose();
$.AMUI.progress.done();
if($(window).width() < 640)
{
......@@ -717,8 +717,8 @@ $(window).resize(function()
// 规格显示/隐藏处理
if($(window).width() < 1025)
{
poptit_close();
PoptitClose();
} else {
poptit_pc_show();
PoptitPcShow();
}
});
\ No newline at end of file
// 楼层聚合数据高度处理
function floor_resize_handle()
function FloorResizeHandle()
{
$('.floor').each(function(k, v)
{
......@@ -13,7 +13,7 @@ $(function()
// 新闻轮播
if((window.innerWidth || $(window).width()) <= 640)
{
function auto_scroll()
function AutoScroll()
{
$('.banner-news').find("ul").animate({
marginTop: "-39px"
......@@ -25,19 +25,19 @@ $(function()
}
setInterval(function()
{
auto_scroll();
AutoScroll();
}, 3000);
}
// 浏览器窗口实时事件
$(window).resize(function()
{
floor_resize_handle();
FloorResizeHandle();
});
});
$(window).load(function()
{
floor_resize_handle();
FloorResizeHandle();
});
\ No newline at end of file
......@@ -16,13 +16,13 @@ $(function()
$(".select-result dl").append(copy_html.attr("id", selected_tag_name));
}
}
get_goods_list(1);
GetGoodsList(1);
});
$(document).on('click', '.select-result dl dd', function() {
$(this).remove();
$('#'+$(this).attr('id')+'-dl').find('.select-all').addClass('selected').siblings().removeClass('selected');
get_goods_list(1);
GetGoodsList(1);
});
$(document).on('click', 'ul.select dd', function() {
......@@ -42,7 +42,7 @@ $(function()
$(this).hide();
$('.select-result .select-no').show();
$('.select-result').hide();
get_goods_list(1);
GetGoodsList(1);
});
// 排序导航
......@@ -67,7 +67,7 @@ $(function()
$(this).addClass('active');
$(this).attr('data-type', 'asc');
}
get_goods_list(1);
GetGoodsList(1);
});
// 条件分类组筛选
......@@ -111,7 +111,7 @@ $(function()
// 导航显示/隐藏处理
function search_nav()
function SearchNav()
{
// 滚动处理导航
$(window).scroll(function()
......@@ -138,7 +138,7 @@ $(function()
$(window).resize(function()
{
// 导航
search_nav();
SearchNav();
// 条件筛选
if($(document).width() >= 640)
......@@ -146,10 +146,10 @@ $(function()
$('.dd-conent').show();
}
});
search_nav();
SearchNav();
// 获取商品列表
function get_goods_list(page)
function GetGoodsList(page)
{
// 请求参数处理
var data = {
......@@ -217,12 +217,12 @@ $(function()
}
});
}
get_goods_list(1);
GetGoodsList(1);
// 加载更多数据
$('.search-pages-submit').on('click', function()
{
get_goods_list();
GetGoodsList();
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册