From 556ef83842f13b6ca84492f696d2a0a395fd7dd1 Mon Sep 17 00:00:00 2001 From: Devil Date: Sun, 22 Sep 2019 10:07:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/admin/default/js/goods.js | 71 ++++++++---------------- public/static/index/default/js/cart.js | 18 +++--- public/static/index/default/js/goods.js | 20 +++---- public/static/index/default/js/index.js | 10 ++-- public/static/index/default/js/search.js | 20 +++---- 5 files changed, 58 insertions(+), 81 deletions(-) diff --git a/public/static/admin/default/js/goods.js b/public/static/admin/default/js/goods.js index 8ac175be6..0d9e72d31 100755 --- a/public/static/admin/default/js/goods.js +++ b/public/static/admin/default/js/goods.js @@ -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 += '×'; html += ''; html += ''; - console.log(spec[i]) $('.title-start').before(html); // value html = ''; - html += ''; + html += ''; html += ''; $('.value-start').before(html); } // 自动生成规格 - var data = spec_cartesian(spec); - console.log(data); + var data = SpecCartesian(spec); + for(var i=1; i') >= 0) + { + html = html.replace(//ig, '复制 移除'); + } + $('.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 diff --git a/public/static/index/default/js/cart.js b/public/static/index/default/js/cart.js index bd320b563..69ba6dfd4 100755 --- a/public/static/index/default/js/cart.js +++ b/public/static/index/default/js/cart.js @@ -1,7 +1,7 @@ $(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; diff --git a/public/static/index/default/js/goods.js b/public/static/index/default/js/goods.js index e3d7cab88..a8727adff 100755 --- a/public/static/index/default/js/goods.js +++ b/public/static/index/default/js/goods.js @@ -1,5 +1,5 @@ // 规格弹窗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 diff --git a/public/static/index/default/js/index.js b/public/static/index/default/js/index.js index 5446b7eac..5032f2365 100755 --- a/public/static/index/default/js/index.js +++ b/public/static/index/default/js/index.js @@ -1,5 +1,5 @@ // 楼层聚合数据高度处理 -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 diff --git a/public/static/index/default/js/search.js b/public/static/index/default/js/search.js index 4c5a75eab..2ab166548 100755 --- a/public/static/index/default/js/search.js +++ b/public/static/index/default/js/search.js @@ -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 -- GitLab