Showing
4 changed files
with
449 additions
and
365 deletions
@@ -399,7 +399,8 @@ function getSource(column, postition, event) { | @@ -399,7 +399,8 @@ function getSource(column, postition, event) { | ||
399 | } catch (e) {} | 399 | } catch (e) {} |
400 | } | 400 | } |
401 | 401 | ||
402 | -function submitSearch() { | 402 | + |
403 | +window.submitSearch = function() { | ||
403 | var $keywordinput = $('#query_key').val(); | 404 | var $keywordinput = $('#query_key').val(); |
404 | var column = 'Search'; | 405 | var column = 'Search'; |
405 | var postition = 'Head Search'; | 406 | var postition = 'Head Search'; |
@@ -421,6 +422,7 @@ function submitSearch() { | @@ -421,6 +422,7 @@ function submitSearch() { | ||
421 | } | 422 | } |
422 | } | 423 | } |
423 | } | 424 | } |
425 | + | ||
424 | /** | 426 | /** |
425 | * 定义购物车扩展 | 427 | * 定义购物车扩展 |
426 | */ | 428 | */ |
@@ -509,7 +511,7 @@ function actionGoodsCart() { | @@ -509,7 +511,7 @@ function actionGoodsCart() { | ||
509 | listIndex = (listIndex + 1) % queryNum; | 511 | listIndex = (listIndex + 1) % queryNum; |
510 | getText(this); | 512 | getText(this); |
511 | } else if (event.which === 13) { | 513 | } else if (event.which === 13) { |
512 | - submitSearch(); | 514 | + window.submitSearch(); |
513 | } else { | 515 | } else { |
514 | getKeywords(this); | 516 | getKeywords(this); |
515 | } | 517 | } |
@@ -1830,358 +1832,367 @@ require("js/product/filter"); | @@ -1830,358 +1832,367 @@ require("js/product/filter"); | ||
1830 | 1832 | ||
1831 | require("js/product/sort-pager"); | 1833 | require("js/product/sort-pager"); |
1832 | 1834 | ||
1835 | +require("js/product/latest-walk"); | ||
1836 | + | ||
1833 | require("js/product/product"); | 1837 | require("js/product/product"); |
1834 | }); | 1838 | }); |
1835 | define("js/product/filter", ["jquery","handlebars","source-map"], function(require, exports, module){ | 1839 | define("js/product/filter", ["jquery","handlebars","source-map"], function(require, exports, module){ |
1836 | -/** | ||
1837 | - * 商品筛选逻辑 | ||
1838 | - * @author: xuqi<qi.xu@yoho.cn> | ||
1839 | - * @date: 2015/12/4 | ||
1840 | - */ | ||
1841 | - | ||
1842 | -var $ = require("jquery"), | ||
1843 | - Handlebars = require("handlebars"); | ||
1844 | - | ||
1845 | -var checkUnicode = { | ||
1846 | - unchecked: '', | ||
1847 | - checked: '' | ||
1848 | -}, | ||
1849 | -moreUnicode = { | ||
1850 | - up: '', | ||
1851 | - down: '' | ||
1852 | -}; | ||
1853 | - | ||
1854 | -//品牌相关变量 | ||
1855 | -var $brandDefault = $('.brand .default'), | ||
1856 | - $brandPanel = $('.brand .brand-panel'), | ||
1857 | - $brandAttrs = $brandPanel.find('.attr'), | ||
1858 | - $brandMore = $('#brand-more'), | ||
1859 | - $brandMulti = $('#brand-multi'); | ||
1860 | - | ||
1861 | -var $brandMoreTxt, $brandMoreIcon; | ||
1862 | - | ||
1863 | -//价格相关变量 | ||
1864 | -var $udPrice = $('.ud-price-range'), | ||
1865 | - interReg = /^\d+$/, | ||
1866 | - $limit, $min, $max, $btn; | ||
1867 | - | ||
1868 | -//分类相关变量 | ||
1869 | -var $sortSub = $('.sort-sub-wrap'); | ||
1870 | - | ||
1871 | -//高级选项相关变量 | ||
1872 | -var $seniorSubWrap = $('.senior-sub-wrap'), | ||
1873 | - $seniorAttrWrap = $('.senior-attr-wrap'); | ||
1874 | - | ||
1875 | -var seniorHoverTime, hoveredIndex; | ||
1876 | - | ||
1877 | -// 尺寸 handlebars 模板 | ||
1878 | -var sizeTmpl = '{{# size}}<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">{{name}}</a>{{/ size}}', | ||
1879 | - sizeCache = {}, // 缓存一下尺寸信息 | ||
1880 | - $sizeWrap = $('.filter-box .size'); | ||
1881 | - | ||
1882 | -sizeTmpl = Handlebars.compile(sizeTmpl); | ||
1883 | - | ||
1884 | -//清除checkbox选中状态 | ||
1885 | -function clearChecked($checkbox) { | ||
1886 | - $checkbox.removeClass('checked').html(checkUnicode.unchecked); | ||
1887 | -} | ||
1888 | - | ||
1889 | -//显示更多品牌面板 | ||
1890 | -function brandShowMore() { | ||
1891 | - $brandDefault.addClass('hide'); | ||
1892 | - $brandPanel.removeClass('hide'); | ||
1893 | -} | ||
1894 | - | ||
1895 | -//隐藏更多品牌面板 | ||
1896 | -function brandHideMore() { | ||
1897 | - $brandPanel.addClass('hide'); | ||
1898 | - $brandDefault.removeClass('hide'); | ||
1899 | -} | ||
1900 | - | ||
1901 | -//url构造&跳转 | ||
1902 | -function uriLoc(attr, val) { | ||
1903 | - var href = decodeURIComponent(window.location.search), | ||
1904 | - query = attr + '=' + val, | ||
1905 | - newHref; | ||
1906 | - | ||
1907 | - if (href === '') { | ||
1908 | - newHref = '?' + query; | ||
1909 | - } else { | ||
1910 | - newHref = href + '&' + query; | ||
1911 | - } | ||
1912 | - | ||
1913 | - window.location.href = newHref; | ||
1914 | -} | ||
1915 | - | ||
1916 | -//隐藏高级选项面板 | ||
1917 | -function hideSeniorPanel(index) { | ||
1918 | - $seniorSubWrap.children('.senior-sub:eq(' + hoveredIndex + ')').addClass('hide'); | ||
1919 | - $seniorAttrWrap.children('.attr:eq(' + hoveredIndex + ')').removeClass('hover'); | ||
1920 | - hoveredIndex = -1; | ||
1921 | -} | ||
1922 | - | ||
1923 | -//屏蔽筛选项双击文字选中 | ||
1924 | -$('.filter-box').on('selectstart', '.attr, .brands-index span', function() { | ||
1925 | - return false; | ||
1926 | -}); | ||
1927 | - | ||
1928 | -//【分类】 | ||
1929 | -$('.sort-pre').on('click', 'li', function() { | ||
1930 | - var $this = $(this), | ||
1931 | - index = $this.index(), | ||
1932 | - id = $this.data('id'); | ||
1933 | - | ||
1934 | - if ($this.hasClass('active')) { | ||
1935 | - | ||
1936 | - // 选中时,再次点击取消选中 | ||
1937 | - $this.removeClass('active'); | ||
1938 | - $sortSub.children(':eq(' + index + ')').addClass('hide'); | ||
1939 | - $sizeWrap.addClass('hide'); | ||
1940 | - return; | ||
1941 | - } | ||
1942 | - | ||
1943 | - $this.siblings('.active').removeClass('active'); | ||
1944 | - $this.addClass('active'); | ||
1945 | - | ||
1946 | - $sortSub.children(':not(.hide)').addClass('hide'); | ||
1947 | - $sortSub.children(':eq(' + index + ')').removeClass('hide'); | ||
1948 | - | ||
1949 | - if (sizeCache[id]) { | ||
1950 | - $sizeWrap.find('.attr-content').html(sizeCache[id]); | ||
1951 | - $sizeWrap.removeClass('hide'); | ||
1952 | - } else { | ||
1953 | - $.ajax({ | ||
1954 | - url: '/product/search/sortSize', | ||
1955 | - data: { | ||
1956 | - msort: id | ||
1957 | - } | ||
1958 | - }).then(function(res) { | ||
1959 | - if ($.type(res) === 'array' && res.length) { | ||
1960 | - sizeCache[id] = sizeTmpl({ | ||
1961 | - size: res | ||
1962 | - }); | ||
1963 | - $sizeWrap.find('.attr-content').html(sizeCache[id]); | ||
1964 | - $sizeWrap.removeClass('hide'); | ||
1965 | - } else { | ||
1966 | - $sizeWrap.addClass('hide'); | ||
1967 | - } | ||
1968 | - }); | ||
1969 | - } | ||
1970 | -}); | ||
1971 | - | ||
1972 | -//【品牌】 | ||
1973 | -if ($brandMore.length > 0) { | ||
1974 | - $brandMoreTxt = $brandMore.children('em'); | ||
1975 | - $brandMoreIcon = $brandMore.children('.iconfont'); | ||
1976 | -} | ||
1977 | - | ||
1978 | -//【品牌】多选 | ||
1979 | -$brandMulti.click(function() { | ||
1980 | - if ($brandPanel.css('display') === 'none') { | ||
1981 | - | ||
1982 | - //显示品牌面板 | ||
1983 | - $brandMore.trigger('click'); | ||
1984 | - } | ||
1985 | - | ||
1986 | - $brandPanel.addClass('multi'); //显示出checkbox | ||
1987 | - $(this).addClass('hide'); | ||
1988 | -}); | ||
1989 | - | ||
1990 | -//【品牌】更多 | ||
1991 | -$brandMore.click(function() { | ||
1992 | - var $this = $(this); | ||
1993 | - | ||
1994 | - if ($this.hasClass('more')) { | ||
1995 | - brandHideMore(); | ||
1996 | - | ||
1997 | - $brandMoreTxt.text('更多'); | ||
1998 | - $brandMoreIcon.html(moreUnicode.down); | ||
1999 | - } else { | ||
2000 | - brandShowMore(); | ||
2001 | - | ||
2002 | - $brandMoreTxt.text('收起'); | ||
2003 | - $brandMoreIcon.html(moreUnicode.up); | ||
2004 | - } | ||
2005 | - | ||
2006 | - $(this).toggleClass('more'); | ||
2007 | -}); | ||
2008 | - | ||
2009 | -//【品牌】索引 | ||
2010 | -$('.brands-index').on('mouseenter', 'span', function() { | ||
2011 | - var $this = $(this), | ||
2012 | - index = $this.data('index'); | ||
2013 | - | ||
2014 | - if ($this.hasClass('hover')) { | ||
2015 | - return; | ||
2016 | - } | ||
2017 | - | ||
2018 | - $this.siblings('span.hover').removeClass('hover'); | ||
2019 | - $this.addClass('hover'); | ||
2020 | - | ||
2021 | - if ($this.index() === 0) { | ||
2022 | - | ||
2023 | - //全部 | ||
2024 | - $brandAttrs.removeClass('hide'); | ||
2025 | - } else { | ||
2026 | - $brandAttrs.addClass('hide').filter('[data-index=' + index + ']').removeClass('hide'); | ||
2027 | - } | ||
2028 | -}); | ||
2029 | - | ||
2030 | -//【品牌】搜索 | ||
2031 | -$('#brand-search-input').keyup(function() { | ||
2032 | - var val = $(this).val().toLowerCase(); | ||
2033 | - | ||
2034 | - if (val === '') { | ||
2035 | - $brandAttrs.removeClass('hide'); | ||
2036 | - } else { | ||
2037 | - $brandAttrs.addClass('hide').filter('[data-key*="' + val + '"]').removeClass('hide'); | ||
2038 | - } | ||
2039 | -}); | ||
2040 | - | ||
2041 | -//【品牌】多选确定 | ||
2042 | -$('#brand-multi-ok').click(function() { | ||
2043 | - var val = ''; | ||
2044 | - | ||
2045 | - if ($(this).hasClass('dis')) { | ||
2046 | - return; | ||
2047 | - } | ||
2048 | - | ||
2049 | - $brandPanel.find('.checked').each(function() { | ||
2050 | - var id = $(this).data('id'); | ||
2051 | - | ||
2052 | - val += (val === '') ? id : (',' + id); | ||
2053 | - }); | ||
2054 | - | ||
2055 | - uriLoc('brand', val); | ||
2056 | -}); | ||
2057 | - | ||
2058 | -//【品牌/高级选项】多选取消 | ||
2059 | -$('.multi-select-cancel').click(function() { | ||
2060 | - var $panel = $(this).closest('.multi'); | ||
2061 | - | ||
2062 | - if ($panel.hasClass('brand-panel')) { | ||
2063 | - | ||
2064 | - $brandMulti.removeClass('hide'); //显示多选按钮 | ||
2065 | - $brandMore.trigger('click'); | ||
2066 | - } | ||
2067 | - | ||
2068 | - $panel.removeClass('multi'); | ||
2069 | - clearChecked($panel.find('.checkbox.checked')); //清除选中状态 | ||
2070 | -}); | ||
2071 | - | ||
2072 | -//【品牌/高级选项】checkbox | ||
2073 | -$('.check-container').on('click', '.attr', function() { | ||
2074 | - var $this = $(this), | ||
2075 | - $check = $this.find('.checkbox'), | ||
2076 | - $btnOk = $this.closest('.brand-panel, .senior-sub').find('.multi-select-ok'); | ||
2077 | - | ||
2078 | - $check.toggleClass('checked'); | ||
2079 | - | ||
2080 | - if ($check.hasClass('checked')) { | ||
2081 | - $check.html(checkUnicode.checked); | ||
2082 | - } else { | ||
2083 | - $check.html(checkUnicode.unchecked); | ||
2084 | - } | ||
2085 | - | ||
2086 | - //更新按钮状态 | ||
2087 | - if ($check.hasClass('checked') || | ||
2088 | - $this.siblings('.attr').find('.checked').length > 0) { | ||
2089 | - $btnOk.removeClass('dis'); | ||
2090 | - } else { | ||
2091 | - $btnOk.addClass('dis'); | ||
2092 | - } | ||
2093 | -}); | ||
2094 | - | ||
2095 | -//【品牌/高级选项】当多选时阻止链接默认跳转 | ||
2096 | -$('.brand, .senior').on('click', '.attr > a', function(e) { | ||
2097 | - if ($(this).closest('.multi').length > 0) { | ||
2098 | - e.preventDefault(); | ||
2099 | - } | ||
2100 | -}); | ||
2101 | - | ||
2102 | -//【价格】用户定义价格处理 | ||
2103 | -if ($udPrice.length > 0) { | ||
2104 | - $limit = $udPrice.find('.limit'); | ||
2105 | - $min = $limit.filter('.min'); | ||
2106 | - $max = $limit.filter('.max'); | ||
2107 | - $btn = $udPrice.find('.price-sure'); | ||
2108 | - | ||
2109 | - //【价格】输入 | ||
2110 | - $limit.keyup(function() { | ||
2111 | - var min = $.trim($min.val()), | ||
2112 | - max = $.trim($max.val()), | ||
2113 | - isMinInt = interReg.test(min), | ||
2114 | - isMaxInt = interReg.test(max); | ||
2115 | - | ||
2116 | - if (isMaxInt && (min === '' || isMinInt) || | ||
2117 | - isMinInt && (max === '' || isMaxInt) | ||
2118 | - ) { | ||
2119 | - $btn.removeClass('hide'); | ||
2120 | - } else { | ||
2121 | - $btn.addClass('hide'); | ||
2122 | - } | ||
2123 | - }); | ||
2124 | - | ||
2125 | - //【价格】多项查询 | ||
2126 | - $btn.click(function() { | ||
2127 | - var min = $.trim($min.val()), | ||
2128 | - max = $.trim($max.val()), | ||
2129 | - tmp; | ||
2130 | - | ||
2131 | - //对于min大于max的情况,交换位置 | ||
2132 | - if (min !== '' && max !== '' && +min > +max) { | ||
2133 | - tmp = max; | ||
2134 | - max = min; | ||
2135 | - min = tmp; | ||
2136 | - } | ||
2137 | - | ||
2138 | - uriLoc('price', min + ',' + max); | ||
2139 | - }); | ||
2140 | -} | ||
2141 | - | ||
2142 | -//【高级选项】鼠标移入显示子项 | ||
2143 | -$seniorAttrWrap.on('mouseenter', '.attr', function() { | ||
2144 | - var $this = $(this); | ||
2145 | - var index = $this.index(); | ||
2146 | - | ||
2147 | - $this.addClass('hover').siblings().removeClass('hover'); | ||
2148 | - | ||
2149 | - $seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide'); | ||
2150 | -}).on('mouseleave', '.attr', function() { | ||
2151 | - var $this = $(this), | ||
2152 | - index = $this.index(); | ||
2153 | - | ||
2154 | - hoveredIndex = index; | ||
2155 | - | ||
2156 | - seniorHoverTime = setTimeout(function() { | ||
2157 | - hideSeniorPanel(); | ||
2158 | - }, 100); | ||
2159 | -}); | ||
2160 | - | ||
2161 | -//【高级选项】多选 | ||
2162 | -$('.senior-sub').on('click', '.multi-select', function() { | ||
2163 | - $(this).closest('.senior-sub').addClass('multi'); | ||
2164 | -}).on('click', '.multi-select-ok', function() { | ||
2165 | - var $btn = $(this), | ||
2166 | - $sub = $btn.closest('.senior-sub'), | ||
2167 | - val = ''; | ||
2168 | - | ||
2169 | - if ($btn.hasClass('dis')) { | ||
2170 | - return; | ||
2171 | - } | ||
2172 | - | ||
2173 | - $sub.find('.checked').each(function() { | ||
2174 | - var id = $(this).data('id'); | ||
2175 | - | ||
2176 | - val += (val === '') ? id : (',' + id); | ||
2177 | - }); | ||
2178 | - | ||
2179 | - uriLoc($sub.data('attr'), val); | ||
2180 | -}).on('mouseenter', function() { | ||
2181 | - clearTimeout(seniorHoverTime); | ||
2182 | -}).on('mouseleave', function() { | ||
2183 | - hideSeniorPanel(); | ||
2184 | -}); | 1840 | +/** |
1841 | + * 商品筛选逻辑 | ||
1842 | + * @author: xuqi<qi.xu@yoho.cn> | ||
1843 | + * @date: 2015/12/4 | ||
1844 | + */ | ||
1845 | + | ||
1846 | +var $ = require("jquery"), | ||
1847 | + Handlebars = require("handlebars"); | ||
1848 | + | ||
1849 | +var checkUnicode = { | ||
1850 | + unchecked: '', | ||
1851 | + checked: '' | ||
1852 | +}, | ||
1853 | +moreUnicode = { | ||
1854 | + up: '', | ||
1855 | + down: '' | ||
1856 | +}; | ||
1857 | + | ||
1858 | +//品牌相关变量 | ||
1859 | +var $brandDefault = $('.brand .default'), | ||
1860 | + $brandPanel = $('.brand .brand-panel'), | ||
1861 | + $brandAttrs = $brandPanel.find('.attr'), | ||
1862 | + $brandMore = $('#brand-more'), | ||
1863 | + $brandMulti = $('#brand-multi'); | ||
1864 | + | ||
1865 | +var $brandMoreTxt, $brandMoreIcon; | ||
1866 | + | ||
1867 | +//价格相关变量 | ||
1868 | +var $udPrice = $('.ud-price-range'), | ||
1869 | + interReg = /^\d+$/, | ||
1870 | + $limit, $min, $max, $btn; | ||
1871 | + | ||
1872 | +//分类相关变量 | ||
1873 | +var $sortSub = $('.sort-sub-wrap'); | ||
1874 | + | ||
1875 | +//高级选项相关变量 | ||
1876 | +var $seniorSubWrap = $('.senior-sub-wrap'), | ||
1877 | + $seniorAttrWrap = $('.senior-attr-wrap'); | ||
1878 | + | ||
1879 | +var seniorHoverTime, hoveredIndex; | ||
1880 | + | ||
1881 | +// 尺寸 handlebars 模板 | ||
1882 | +var sizeTmpl = '{{# size}}<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">{{name}}</a>{{/ size}}', | ||
1883 | + sizeCache = {}, // 缓存一下尺寸信息 | ||
1884 | + $sizeWrap = $('.filter-box .size'); | ||
1885 | + | ||
1886 | +sizeTmpl = Handlebars.compile(sizeTmpl); | ||
1887 | + | ||
1888 | +//清除checkbox选中状态 | ||
1889 | +function clearChecked($checkbox) { | ||
1890 | + $checkbox.removeClass('checked').html(checkUnicode.unchecked); | ||
1891 | +} | ||
1892 | + | ||
1893 | +//显示更多品牌面板 | ||
1894 | +function brandShowMore() { | ||
1895 | + $brandDefault.addClass('hide'); | ||
1896 | + $brandPanel.removeClass('hide'); | ||
1897 | +} | ||
1898 | + | ||
1899 | +//隐藏更多品牌面板 | ||
1900 | +function brandHideMore() { | ||
1901 | + $brandPanel.addClass('hide'); | ||
1902 | + $brandDefault.removeClass('hide'); | ||
1903 | +} | ||
1904 | + | ||
1905 | +//url构造&跳转 | ||
1906 | +function uriLoc(attr, val) { | ||
1907 | + var href = decodeURIComponent(window.location.search), | ||
1908 | + query = attr + '=' + val, | ||
1909 | + newHref; | ||
1910 | + | ||
1911 | + if (href === '') { | ||
1912 | + newHref = '?' + query; | ||
1913 | + } else { | ||
1914 | + newHref = href + '&' + query; | ||
1915 | + } | ||
1916 | + | ||
1917 | + window.location.href = newHref; | ||
1918 | +} | ||
1919 | + | ||
1920 | +//隐藏高级选项面板 | ||
1921 | +function hideSeniorPanel(index) { | ||
1922 | + $seniorSubWrap.children('.senior-sub:eq(' + hoveredIndex + ')').addClass('hide'); | ||
1923 | + $seniorAttrWrap.children('.attr:eq(' + hoveredIndex + ')').removeClass('hover'); | ||
1924 | + hoveredIndex = -1; | ||
1925 | +} | ||
1926 | + | ||
1927 | +//屏蔽筛选项双击文字选中 | ||
1928 | +$('.filter-box').on('selectstart', '.attr, .brands-index span', function() { | ||
1929 | + return false; | ||
1930 | +}); | ||
1931 | + | ||
1932 | +//【分类】 | ||
1933 | +$('.sort-pre').on('click', 'li', function() { | ||
1934 | + var $this = $(this), | ||
1935 | + index = $this.index(), | ||
1936 | + id = $this.data('id'); | ||
1937 | + | ||
1938 | + if ($this.hasClass('active')) { | ||
1939 | + | ||
1940 | + // 选中时,再次点击取消选中 | ||
1941 | + $this.removeClass('active'); | ||
1942 | + $sortSub.children(':eq(' + index + ')').addClass('hide'); | ||
1943 | + $sizeWrap.addClass('hide'); | ||
1944 | + return; | ||
1945 | + } | ||
1946 | + | ||
1947 | + $this.siblings('.active').removeClass('active'); | ||
1948 | + $this.addClass('active'); | ||
1949 | + | ||
1950 | + $sortSub.children(':not(.hide)').addClass('hide'); | ||
1951 | + $sortSub.children(':eq(' + index + ')').removeClass('hide'); | ||
1952 | + | ||
1953 | + if (sizeCache[id]) { | ||
1954 | + $sizeWrap.find('.attr-content').html(sizeCache[id]); | ||
1955 | + $sizeWrap.removeClass('hide'); | ||
1956 | + } else { | ||
1957 | + $.ajax({ | ||
1958 | + url: '/product/search/sortSize', | ||
1959 | + data: { | ||
1960 | + msort: id | ||
1961 | + } | ||
1962 | + }).then(function(res) { | ||
1963 | + if ($.type(res) === 'array' && res.length) { | ||
1964 | + sizeCache[id] = sizeTmpl({ | ||
1965 | + size: res | ||
1966 | + }); | ||
1967 | + $sizeWrap.find('.attr-content').html(sizeCache[id]); | ||
1968 | + $sizeWrap.removeClass('hide'); | ||
1969 | + } else { | ||
1970 | + $sizeWrap.addClass('hide'); | ||
1971 | + } | ||
1972 | + }); | ||
1973 | + } | ||
1974 | +}); | ||
1975 | + | ||
1976 | +//【品牌】 | ||
1977 | +if ($brandMore.length > 0) { | ||
1978 | + $brandMoreTxt = $brandMore.children('em'); | ||
1979 | + $brandMoreIcon = $brandMore.children('.iconfont'); | ||
1980 | +} | ||
1981 | + | ||
1982 | +//【品牌】多选 | ||
1983 | +$brandMulti.click(function() { | ||
1984 | + if ($brandPanel.css('display') === 'none') { | ||
1985 | + | ||
1986 | + //显示品牌面板 | ||
1987 | + $brandMore.trigger('click'); | ||
1988 | + } | ||
1989 | + | ||
1990 | + $brandPanel.addClass('multi'); //显示出checkbox | ||
1991 | + $(this).addClass('hide'); | ||
1992 | +}); | ||
1993 | + | ||
1994 | +//【品牌】更多 | ||
1995 | +$brandMore.click(function() { | ||
1996 | + var $this = $(this); | ||
1997 | + | ||
1998 | + if ($this.hasClass('more')) { | ||
1999 | + brandHideMore(); | ||
2000 | + | ||
2001 | + $brandMoreTxt.text('更多'); | ||
2002 | + $brandMoreIcon.html(moreUnicode.down); | ||
2003 | + } else { | ||
2004 | + brandShowMore(); | ||
2005 | + | ||
2006 | + $brandMoreTxt.text('收起'); | ||
2007 | + $brandMoreIcon.html(moreUnicode.up); | ||
2008 | + } | ||
2009 | + | ||
2010 | + $(this).toggleClass('more'); | ||
2011 | +}); | ||
2012 | + | ||
2013 | +//【品牌】索引 | ||
2014 | +$('.brands-index').on('mouseenter', 'span', function() { | ||
2015 | + var $this = $(this), | ||
2016 | + index = $this.data('index'); | ||
2017 | + | ||
2018 | + if ($this.hasClass('hover')) { | ||
2019 | + return; | ||
2020 | + } | ||
2021 | + | ||
2022 | + $this.siblings('span.hover').removeClass('hover'); | ||
2023 | + $this.addClass('hover'); | ||
2024 | + | ||
2025 | + if ($this.index() === 0) { | ||
2026 | + | ||
2027 | + //全部 | ||
2028 | + $brandAttrs.removeClass('hide'); | ||
2029 | + } else { | ||
2030 | + $brandAttrs.addClass('hide').filter('[data-index=' + index + ']').removeClass('hide'); | ||
2031 | + } | ||
2032 | +}); | ||
2033 | + | ||
2034 | +//【品牌】搜索 | ||
2035 | +$('#brand-search-input').keyup(function() { | ||
2036 | + var val = $(this).val().toLowerCase(); | ||
2037 | + | ||
2038 | + if (val === '') { | ||
2039 | + $brandAttrs.removeClass('hide'); | ||
2040 | + } else { | ||
2041 | + $brandAttrs.addClass('hide').filter('[data-key*="' + val + '"]').removeClass('hide'); | ||
2042 | + } | ||
2043 | +}); | ||
2044 | + | ||
2045 | +//【品牌】多选确定 | ||
2046 | +$('#brand-multi-ok').click(function() { | ||
2047 | + var val = ''; | ||
2048 | + | ||
2049 | + if ($(this).hasClass('dis')) { | ||
2050 | + return; | ||
2051 | + } | ||
2052 | + | ||
2053 | + $brandPanel.find('.checked').each(function() { | ||
2054 | + var id = $(this).data('id'); | ||
2055 | + | ||
2056 | + val += (val === '') ? id : (',' + id); | ||
2057 | + }); | ||
2058 | + | ||
2059 | + uriLoc('brand', val); | ||
2060 | +}); | ||
2061 | + | ||
2062 | +//【品牌/高级选项】多选取消 | ||
2063 | +$('.multi-select-cancel').click(function() { | ||
2064 | + var $panel = $(this).closest('.multi'); | ||
2065 | + | ||
2066 | + if ($panel.hasClass('brand-panel')) { | ||
2067 | + | ||
2068 | + $brandMulti.removeClass('hide'); //显示多选按钮 | ||
2069 | + $brandMore.trigger('click'); | ||
2070 | + } | ||
2071 | + | ||
2072 | + $panel.removeClass('multi'); | ||
2073 | + clearChecked($panel.find('.checkbox.checked')); //清除选中状态 | ||
2074 | +}); | ||
2075 | + | ||
2076 | +//【品牌/高级选项】checkbox | ||
2077 | +$('.check-container').on('click', '.attr', function() { | ||
2078 | + var $this = $(this), | ||
2079 | + $check = $this.find('.checkbox'), | ||
2080 | + $btnOk = $this.closest('.brand-panel, .senior-sub').find('.multi-select-ok'); | ||
2081 | + | ||
2082 | + $check.toggleClass('checked'); | ||
2083 | + | ||
2084 | + if ($check.hasClass('checked')) { | ||
2085 | + $check.html(checkUnicode.checked); | ||
2086 | + } else { | ||
2087 | + $check.html(checkUnicode.unchecked); | ||
2088 | + } | ||
2089 | + | ||
2090 | + //更新按钮状态 | ||
2091 | + if ($check.hasClass('checked') || | ||
2092 | + $this.siblings('.attr').find('.checked').length > 0) { | ||
2093 | + $btnOk.removeClass('dis'); | ||
2094 | + } else { | ||
2095 | + $btnOk.addClass('dis'); | ||
2096 | + } | ||
2097 | +}); | ||
2098 | + | ||
2099 | +//【品牌/高级选项】当多选时阻止链接默认跳转 | ||
2100 | +$('.brand, .senior').on('click', '.attr > a', function(e) { | ||
2101 | + if ($(this).closest('.multi').length > 0) { | ||
2102 | + e.preventDefault(); | ||
2103 | + } | ||
2104 | +}); | ||
2105 | + | ||
2106 | +//【价格】用户定义价格处理 | ||
2107 | +if ($udPrice.length > 0) { | ||
2108 | + $limit = $udPrice.find('.limit'); | ||
2109 | + $min = $limit.filter('.min'); | ||
2110 | + $max = $limit.filter('.max'); | ||
2111 | + $btn = $udPrice.find('.price-sure'); | ||
2112 | + | ||
2113 | + //【价格】输入 | ||
2114 | + $limit.keyup(function() { | ||
2115 | + var min = $.trim($min.val()), | ||
2116 | + max = $.trim($max.val()), | ||
2117 | + isMinInt = interReg.test(min), | ||
2118 | + isMaxInt = interReg.test(max); | ||
2119 | + | ||
2120 | + if (isMaxInt && (min === '' || isMinInt) || | ||
2121 | + isMinInt && (max === '' || isMaxInt) | ||
2122 | + ) { | ||
2123 | + $btn.removeClass('hide'); | ||
2124 | + } else { | ||
2125 | + $btn.addClass('hide'); | ||
2126 | + } | ||
2127 | + }); | ||
2128 | + | ||
2129 | + //【价格】多项查询 | ||
2130 | + $btn.click(function() { | ||
2131 | + var min = $.trim($min.val()), | ||
2132 | + max = $.trim($max.val()), | ||
2133 | + tmp; | ||
2134 | + | ||
2135 | + //对于min大于max的情况,交换位置 | ||
2136 | + if (min !== '' && max !== '' && +min > +max) { | ||
2137 | + tmp = max; | ||
2138 | + max = min; | ||
2139 | + min = tmp; | ||
2140 | + } | ||
2141 | + | ||
2142 | + uriLoc('price', min + ',' + max); | ||
2143 | + }); | ||
2144 | +} | ||
2145 | + | ||
2146 | +//【高级选项】鼠标移入显示子项 | ||
2147 | +$seniorAttrWrap.on('mouseenter', '.attr', function() { | ||
2148 | + var $this = $(this); | ||
2149 | + var index = $this.index(); | ||
2150 | + | ||
2151 | + if ($this.hasClass('no-sub')) { | ||
2152 | + return; | ||
2153 | + } | ||
2154 | + $this.addClass('hover').siblings().removeClass('hover'); | ||
2155 | + | ||
2156 | + $seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide'); | ||
2157 | +}).on('mouseleave', '.attr', function() { | ||
2158 | + var $this = $(this), | ||
2159 | + index = $this.index(); | ||
2160 | + | ||
2161 | + if ($this.hasClass('no-sub')) { | ||
2162 | + return; | ||
2163 | + } | ||
2164 | + | ||
2165 | + hoveredIndex = index; | ||
2166 | + | ||
2167 | + seniorHoverTime = setTimeout(function() { | ||
2168 | + hideSeniorPanel(); | ||
2169 | + }, 100); | ||
2170 | +}); | ||
2171 | + | ||
2172 | +//【高级选项】多选 | ||
2173 | +$('.senior-sub').on('click', '.multi-select', function() { | ||
2174 | + $(this).closest('.senior-sub').addClass('multi'); | ||
2175 | +}).on('click', '.multi-select-ok', function() { | ||
2176 | + var $btn = $(this), | ||
2177 | + $sub = $btn.closest('.senior-sub'), | ||
2178 | + val = ''; | ||
2179 | + | ||
2180 | + if ($btn.hasClass('dis')) { | ||
2181 | + return; | ||
2182 | + } | ||
2183 | + | ||
2184 | + $sub.find('.checked').each(function() { | ||
2185 | + var id = $(this).data('id'); | ||
2186 | + | ||
2187 | + val += (val === '') ? id : (',' + id); | ||
2188 | + }); | ||
2189 | + | ||
2190 | + uriLoc($sub.data('attr'), val); | ||
2191 | +}).on('mouseenter', function() { | ||
2192 | + clearTimeout(seniorHoverTime); | ||
2193 | +}).on('mouseleave', function() { | ||
2194 | + hideSeniorPanel(); | ||
2195 | +}); | ||
2185 | 2196 | ||
2186 | }); | 2197 | }); |
2187 | define("js/product/sort-pager", ["jquery"], function(require, exports, module){ | 2198 | define("js/product/sort-pager", ["jquery"], function(require, exports, module){ |
@@ -2214,6 +2225,65 @@ $countPerPage.click(function() { | @@ -2214,6 +2225,65 @@ $countPerPage.click(function() { | ||
2214 | } | 2225 | } |
2215 | }); | 2226 | }); |
2216 | }); | 2227 | }); |
2228 | +define("js/product/latest-walk", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){ | ||
2229 | +/** | ||
2230 | + * 最近浏览取接口渲染模板 | ||
2231 | + * @author: xuqi<qi.xu@yoho.cn> | ||
2232 | + 8 @date: 2016/1/20 | ||
2233 | + */ | ||
2234 | + | ||
2235 | +var $ = require("jquery"); | ||
2236 | +var Handlebars = require("handlebars"); | ||
2237 | +var lazyLoad = require("lazyload"); | ||
2238 | + | ||
2239 | +var $latestWalkCount = $('#latest-walk-count'); | ||
2240 | + | ||
2241 | +(function() { | ||
2242 | + var tpl; | ||
2243 | + | ||
2244 | + if ($latestWalkCount.lenght < 0) { | ||
2245 | + return; | ||
2246 | + } | ||
2247 | + | ||
2248 | + tpl = Handlebars.compile($('#latest-walk-tpl').html()); | ||
2249 | + | ||
2250 | + $.ajax({ | ||
2251 | + url: 'http://itemapi.yohobuy.com/item/item/recentreview', | ||
2252 | + dataType: 'jsonp', | ||
2253 | + data: { | ||
2254 | + limit: $latestWalkCount.val() | ||
2255 | + }, | ||
2256 | + success: function(data) { | ||
2257 | + var latestWalk = [], | ||
2258 | + res, i, cur; | ||
2259 | + | ||
2260 | + if (data.code === 200) { | ||
2261 | + res = data.data; | ||
2262 | + | ||
2263 | + for (i = 0; i < res.length; i++) { | ||
2264 | + cur = res[i]; | ||
2265 | + | ||
2266 | + latestWalk.push({ | ||
2267 | + href: cur.url, | ||
2268 | + img: cur.pic_url, | ||
2269 | + name: cur.product_name, | ||
2270 | + salePrice: cur.price, | ||
2271 | + marketPrice: cur.market_price | ||
2272 | + }); | ||
2273 | + } | ||
2274 | + | ||
2275 | + if (latestWalk.length > 0) { | ||
2276 | + $('#latest-walk-goods').html(tpl({ | ||
2277 | + latestWalk: latestWalk | ||
2278 | + })); | ||
2279 | + | ||
2280 | + lazyLoad($('#latest-walk-goods .lazy')); | ||
2281 | + } | ||
2282 | + } | ||
2283 | + } | ||
2284 | + }); | ||
2285 | +}()); | ||
2286 | +}); | ||
2217 | define("js/product/product", ["jquery","lazyload"], function(require, exports, module){ | 2287 | define("js/product/product", ["jquery","lazyload"], function(require, exports, module){ |
2218 | /** | 2288 | /** |
2219 | *Description: 商品列表页 | 2289 | *Description: 商品列表页 |
@@ -5778,7 +5848,7 @@ $sc.click(function() { | @@ -5778,7 +5848,7 @@ $sc.click(function() { | ||
5778 | $.post('/passport/back/sendbackmobile', { | 5848 | $.post('/passport/back/sendbackmobile', { |
5779 | mobile: $('#mobile').val(), | 5849 | mobile: $('#mobile').val(), |
5780 | area: $('#area').val(), | 5850 | area: $('#area').val(), |
5781 | - verifyCode: $('#captchaPic').val(), | 5851 | + verifyCode: $('#captchaPic').val() |
5782 | }, function(jsonData) { | 5852 | }, function(jsonData) { |
5783 | if (jsonData.code === 200) { | 5853 | if (jsonData.code === 200) { |
5784 | $errTip.hide(); | 5854 | $errTip.hide(); |
@@ -5832,17 +5902,34 @@ itime = setInterval(function() { | @@ -5832,17 +5902,34 @@ itime = setInterval(function() { | ||
5832 | 5902 | ||
5833 | 5903 | ||
5834 | $('#captcha').keyup(function() { | 5904 | $('#captcha').keyup(function() { |
5835 | - var v = $.trim($(this).val()); | 5905 | + var v = $.trim($(this).val()), |
5906 | + that = this; | ||
5836 | 5907 | ||
5837 | - if (v !== '') { | ||
5838 | - | ||
5839 | - //添加验证码正确验证 | ||
5840 | - //$next.removeClass('disable').prop('disabled', false); | ||
5841 | - $next.removeClass('disable').removeAttr('disabled'); | ||
5842 | - } else { | 5908 | + if (v.length === 4) { |
5909 | + $.ajax({ | ||
5910 | + type: 'POST', | ||
5911 | + url: '/passport/back/backmobile', | ||
5912 | + dataType: 'json', | ||
5913 | + data: { | ||
5914 | + code: $('#captcha').val(), | ||
5915 | + verifyCode: $("#captchaPic").val(), | ||
5916 | + area: $('#area').val(), | ||
5917 | + mobile: $('#mobile').val() | ||
5918 | + }, | ||
5919 | + success: function(res) { | ||
5920 | + if (res.code === 200) { | ||
5843 | 5921 | ||
5844 | - //$next.addClass('disable').prop('disabled', true); | ||
5845 | - $next.addClass('disable').attr('disabled', true); | 5922 | + //添加验证码正确验证 |
5923 | + $next.removeClass('disable').removeAttr('disabled'); | ||
5924 | + $errTip.addClass('hide'); | ||
5925 | + $(that).removeClass('error'); | ||
5926 | + } else { | ||
5927 | + $next.addClass('disable').attr('disabled', true); | ||
5928 | + $errTip.removeClass('hide').find('em').text('验证码输入错误'); | ||
5929 | + $(that).addClass('error'); | ||
5930 | + } | ||
5931 | + } | ||
5932 | + }); | ||
5846 | } | 5933 | } |
5847 | }).blur(function() { | 5934 | }).blur(function() { |
5848 | var v = $.trim($(this).val()); | 5935 | var v = $.trim($(this).val()); |
@@ -5851,10 +5938,7 @@ $('#captcha').keyup(function() { | @@ -5851,10 +5938,7 @@ $('#captcha').keyup(function() { | ||
5851 | 5938 | ||
5852 | //添加验证码正确验证 | 5939 | //添加验证码正确验证 |
5853 | $(this).addClass('error'); | 5940 | $(this).addClass('error'); |
5854 | - $errTip.removeClass('hide'); | ||
5855 | - } else { | ||
5856 | - $(this).removeClass('error'); | ||
5857 | - $errTip.addClass('hide'); | 5941 | + $errTip.removeClass('hide').text('请输入验证码'); |
5858 | } | 5942 | } |
5859 | }).focus(function() { | 5943 | }).focus(function() { |
5860 | $(this).removeClass('error'); | 5944 | $(this).removeClass('error'); |
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
-
Please register or login to post a comment