...
|
...
|
@@ -5,15 +5,15 @@ |
|
|
*/
|
|
|
require('channel/brand.page.css');
|
|
|
|
|
|
var $ = require('yoho-jquery'),
|
|
|
let $ = require('yoho-jquery'),
|
|
|
Hammer = require('../common/toy-hammer'),
|
|
|
Swiper = require('yoho-swiper'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload');
|
|
|
|
|
|
var ranToken = ' ??++ ';
|
|
|
var ranToken2 = ' ???--- ';
|
|
|
let ranToken = ' ??++ ';
|
|
|
let ranToken2 = ' ???--- ';
|
|
|
|
|
|
var $brandList,
|
|
|
let $brandList,
|
|
|
$newBrandWall,
|
|
|
$recommandBrandWall,
|
|
|
$icon = $('.search-icon'),
|
...
|
...
|
@@ -26,26 +26,26 @@ var $brandList, |
|
|
$searchResult = $('.search-result'),
|
|
|
$navBtn = $('.nav-home');
|
|
|
|
|
|
var brandsData,
|
|
|
let brandsData,
|
|
|
$keyword = $('#keyword');
|
|
|
|
|
|
var $history = $('.local-history');
|
|
|
var $searchPage = $('.search-brand-page');
|
|
|
var $historySearch = $('.history-search');
|
|
|
var $hotSearch = $('.hot-search');
|
|
|
var $clearHistory = $('#clear-history');
|
|
|
var isSearchPage = $('.brand-search-page').length > 0;
|
|
|
let $history = $('.local-history');
|
|
|
let $searchPage = $('.search-brand-page');
|
|
|
let $historySearch = $('.history-search');
|
|
|
let $hotSearch = $('.hot-search');
|
|
|
let $clearHistory = $('#clear-history');
|
|
|
let isSearchPage = $('.brand-search-page').length > 0;
|
|
|
|
|
|
require('../common');
|
|
|
require('../footer');
|
|
|
|
|
|
function getBrandList() {
|
|
|
var listHbs = require('channel/brandlist.hbs');
|
|
|
let listHbs = require('channel/brandlist.hbs');
|
|
|
|
|
|
$.ajax({
|
|
|
url: '/brands/getBrandList',
|
|
|
data: {
|
|
|
channel: window.queryString.channel
|
|
|
channel: window.queryString.channel || $('.query-param[data-attr="yhChannel"]').val()
|
|
|
},
|
|
|
success: function(data) {
|
|
|
$('#placeholder-brandlist').replaceWith(listHbs(data));
|
...
|
...
|
@@ -53,7 +53,7 @@ function getBrandList() { |
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
// 改变背景色
|
|
|
changeBackground();
|
|
|
changeBackground(); //eslint-disable-line
|
|
|
|
|
|
$brandList = $('.brand-list');
|
|
|
$newBrandWall = $('.new-brand-wall');
|
...
|
...
|
@@ -65,7 +65,7 @@ function getBrandList() { |
|
|
}
|
|
|
|
|
|
function changeBackground() {
|
|
|
var brandList = $('.brand-list').find('p');
|
|
|
let brandList = $('.brand-list').find('p');
|
|
|
|
|
|
brandList.on('touchstart', function() {
|
|
|
brandList.css('background', '#fff');
|
...
|
...
|
@@ -115,11 +115,11 @@ function searchInput() { |
|
|
// $(this).closest('.search-box').css('width', '12.5rem');
|
|
|
$searchAction.find('.clear-text').hide();
|
|
|
}
|
|
|
searchResult();
|
|
|
searchResult(); //eslint-disable-line
|
|
|
}
|
|
|
|
|
|
function isLocalStorageSupported() {
|
|
|
var testKey = 'test',
|
|
|
let testKey = 'test',
|
|
|
storage = Window.prototype.localStorage || window.localStorage;
|
|
|
|
|
|
try {
|
...
|
...
|
@@ -132,20 +132,16 @@ function isLocalStorageSupported() { |
|
|
}
|
|
|
|
|
|
// 绑定提交前的存local操作
|
|
|
function bindWriteLocal($brandList, list) {
|
|
|
$brandList.on('click', 'p , li', function(e) {
|
|
|
var brandName, brandId, brandDomain, url;
|
|
|
var a = $(this).find('a');
|
|
|
var myDate = new Date();
|
|
|
var query = a.attr('brandName') + ranToken2 + myDate.getTime(),
|
|
|
function bindWriteLocal(brandListEle, list) {
|
|
|
brandListEle.on('click', 'p , li', function(e) {
|
|
|
let brandName, url;
|
|
|
let a = $(this).find('a');
|
|
|
let myDate = new Date();
|
|
|
let query = a.attr('brandName') + ranToken2 + myDate.getTime(),
|
|
|
historys;
|
|
|
|
|
|
brandName = a.attr('brandName');
|
|
|
|
|
|
brandId = a.attr('brandId');
|
|
|
|
|
|
brandDomain = a.attr('brandDomain');
|
|
|
|
|
|
url = a.attr('href');
|
|
|
|
|
|
e.preventDefault();
|
...
|
...
|
@@ -200,8 +196,8 @@ function bindWriteLocal($brandList, list) { |
|
|
}
|
|
|
|
|
|
function searchResult() {
|
|
|
var keyword = ($keyword.val() + '').toLowerCase();
|
|
|
var result = {},
|
|
|
let keyword = ($keyword.val() + '').toLowerCase();
|
|
|
let result = {},
|
|
|
i = 0,
|
|
|
html = '';
|
|
|
|
...
|
...
|
@@ -212,7 +208,7 @@ function searchResult() { |
|
|
if ($.isArray(v)) {
|
|
|
|
|
|
// 遍历品牌,进行匹配
|
|
|
$.each(v, function(i, brand) {
|
|
|
$.each(v, function(index, brand) {
|
|
|
if (brand.searchName.toLowerCase().indexOf(keyword) > -1) {
|
|
|
result[k] = result[k] || [];
|
|
|
result[k].push(brand);
|
...
|
...
|
@@ -223,13 +219,13 @@ function searchResult() { |
|
|
|
|
|
// 根据搜索结果生成 HTML
|
|
|
$.each(result, function(k, v) {
|
|
|
var brandHtml = ['<div class="brand-list bar-', i, '">'];
|
|
|
let brandHtml = ['<div class="brand-list bar-', i, '">'];
|
|
|
|
|
|
i++;
|
|
|
brandHtml.push('<div class="title-bar"><h2>');
|
|
|
brandHtml.push(k);
|
|
|
brandHtml.push('</h2></div>');
|
|
|
$.each(v, function(i, brand) {
|
|
|
$.each(v, function(index, brand) {
|
|
|
|
|
|
brandHtml.push('<p><a href="' + brand.url + '" brandName = "' + brand.name +
|
|
|
'" brandId = "' + brand.brandId + '" brandDomain = "' + brand.brandDomain + '">' + brand.name);
|
...
|
...
|
@@ -262,8 +258,8 @@ function searchResult() { |
|
|
|
|
|
(function() {
|
|
|
if ($('.banner-top').length === 0) {
|
|
|
var h1 = $('.genderNav').height();
|
|
|
var h2 = $('.newbrand-search').height();
|
|
|
let h1 = $('.genderNav').height();
|
|
|
let h2 = $('.newbrand-search').height();
|
|
|
|
|
|
$('.hot-brands').css('padding-top', (h1 + h2) + 'px');
|
|
|
}
|
...
|
...
|
@@ -285,13 +281,19 @@ function searchResult() { |
|
|
});
|
|
|
|
|
|
$genderItem.on('touchstart', function() {
|
|
|
var index = $(this).data('id') + 1;
|
|
|
if (window.queryString.channel) {
|
|
|
let index = $(this).data('id') + 1;
|
|
|
|
|
|
window.location.search = 'channel=' + index;
|
|
|
window.location.search = 'channel=' + index;
|
|
|
} else {
|
|
|
let name = $(this).data('name').toLowerCase();
|
|
|
|
|
|
window.location.href = `/${name}-brands/`;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$brandItem.on('click', function() {
|
|
|
var index = $(this).data('id');
|
|
|
let index = $(this).data('id');
|
|
|
|
|
|
$('.brandNav ul .active').removeClass('active');
|
|
|
$(this).addClass('active');
|
...
|
...
|
@@ -351,7 +353,7 @@ if (isSearchPage) { |
|
|
$keyword.closest('.search-box').css('width', '13rem');
|
|
|
$searchAction.show().find('.clear-text').hide();
|
|
|
|
|
|
var clearTextHammer = new Hammer($('.clear-text')[0]);
|
|
|
let clearTextHammer = new Hammer($('.clear-text')[0]);
|
|
|
|
|
|
clearTextHammer.on('tap', function(e) {
|
|
|
$searchResult.html('');
|
...
|
...
|
@@ -380,7 +382,7 @@ if (isSearchPage) { |
|
|
}
|
|
|
|
|
|
$netHistory = $('.net-history');
|
|
|
var chHammer = new Hammer($clearHistory[0]);
|
|
|
let chHammer = new Hammer($clearHistory[0]);
|
|
|
|
|
|
chHammer.on('tap', function() {
|
|
|
if (isLocalStorageSupported()) {
|
...
|
...
|
@@ -399,7 +401,7 @@ if (isSearchPage) { |
|
|
|
|
|
// 搜索页面
|
|
|
(function() {
|
|
|
var html = '',
|
|
|
let html = '',
|
|
|
history,
|
|
|
historys, i,
|
|
|
localHistory,
|
...
|
...
|
@@ -417,7 +419,7 @@ if (isSearchPage) { |
|
|
dict = {
|
|
|
brand: brand,
|
|
|
time: time
|
|
|
}, dictc, dict;
|
|
|
}, dictc, dict; //eslint-disable-line
|
|
|
netArr.push(dict);
|
|
|
});
|
|
|
|
...
|
...
|
|