Authored by 王水玲

隐藏搜索联动及店铺推荐功能

... ... @@ -15,7 +15,9 @@ var $searchWrap = $('.search-wrapper'),
$clearInput = $('.clear-input');
var goodsTpl = require('../../tpl/common/bag-goods.hbs');
var searchHintTpl = require('../../tpl/header/search-hint.hbs');
//var searchHintTpl = require('../../tpl/header/search-hint.hbs');
var delayer;
require('yoho-jquery-nanoscroller');
... ... @@ -181,61 +183,78 @@ $searchKey.keyup(function(e) {
});
// 关键词搜索联想
function searchSuggest(key) {
$.get('//www.yohoblk.com/product/query/suggest', {
keyword: key
}, function(data) {
if (data.length >= 1) {
$searchHint.html(searchHintTpl({list: data})).show();
} else {
$searchHint.hide();
}
});
}
// function searchSuggest(key) {
// $.get('//www.yohoblk.com/product/query/suggest', {
// keyword: key
// }, function(data) {
// if (data.length >= 1) {
// $searchHint.html(searchHintTpl({list: data})).show();
// } else {
// $searchHint.hide();
// }
// });
// }
$searchKey.keyup(function(e) {
var val = $.trim($(this).val()),
$child = $searchHint.find('li'),
$act = $searchHint.find('.action'),
$focus;
if (e.which > 36 && e.which < 41) {
if (e.which === 38) {
$focus = $act.prev();
if (!$act.length || !$focus.length) {
$focus = $child.eq($child.length - 1);
}
} else if (e.which === 40) {
$focus = $act.next();
if (!$act.length || !$focus.length) {
$focus = $child.eq(0);
}
} else {
return;
}
var key = $searchKey.val();
$child.removeClass('action');
$focus.addClass('action');
$(this).val($focus.find('.search-value').text());
} else if (e.which === 13) {
if (val) {
if (e.which === 13) {
if (key) {
$searchForm.submit();
}
} else {
if ($searchHint && $searchHint.length) {
val = val.replace(new RegExp('\'', 'gm'), ''); // 去掉特殊字符
searchSuggest(val);
}
}
if (val) {
if (key) {
$clearInput.show();
} else {
$clearInput.hide();
}
});
// 搜索联动代码,由于接口暂不支持,先注释
// $searchKey.keyup(function(e) {
// var val = $.trim($(this).val()),
// $child = $searchHint.find('li'),
// $act = $searchHint.find('.action'),
// $focus;
//
// if (e.which > 36 && e.which < 41) {
//
// if (e.which === 38) {
// $focus = $act.prev();
// if (!$act.length || !$focus.length) {
// $focus = $child.eq($child.length - 1);
// }
// } else if (e.which === 40) {
// $focus = $act.next();
// if (!$act.length || !$focus.length) {
// $focus = $child.eq(0);
// }
// } else {
// return;
// }
//
// $child.removeClass('action');
// $focus.addClass('action');
// $(this).val($focus.find('.search-value').text());
// } else if (e.which === 13) {
// if (val) {
// $searchForm.submit();
// }
// } else {
// if ($searchHint && $searchHint.length) {
// val = val.replace(new RegExp('\'', 'gm'), ''); // 去掉特殊字符
// searchSuggest(val);
// }
// }
//
// if (val) {
// $clearInput.show();
// } else {
// $clearInput.hide();
// }
// });
// ie8输入框提示特殊处理
// 应产品要求所有浏览器获得焦点提示文字隐藏
// if (!!window.ActiveXObject && !!document.documentMode) {
... ...
... ... @@ -11,9 +11,12 @@ var recommmendProduct = {
recentPreviewPage: 0,
init: function(obj) {
var _this = this,
params = obj.params || {},
$dom = $(obj.dom),
url = obj.url || '/product/getRecommendProduct';
// params = obj.params || {},
$dom = $(obj.dom);
// url = obj.url || '/product/getRecommendProduct';
$dom.append(recTemplet({
isGoodsDetail: obj.isGoodsDetail ? true : false
... ... @@ -25,11 +28,19 @@ var recommmendProduct = {
$dom: $dom
});
// 为您优选||店铺推荐
// 为您优选||店铺推荐 接口不支持,暂时注释
// _this.getProducts({
// url: url,
// index: 0,
// params: params
// });
_this.getProducts({
url: url,
index: 0,
params: params
url: '/product/recentPreview',
index: 1,
params: {
limit: 20
}
});
// tab切换
... ... @@ -102,16 +113,16 @@ var recommmendProduct = {
}
}
if (obj.index === 0) {
// 最近预览
_this.getProducts({
url: '/product/recentPreview',
index: 1,
params: {
limit: 20
}
});
}
// if (obj.index === 0) {
// // 最近预览
// _this.getProducts({
// url: '/product/recentPreview',
// index: 1,
// params: {
// limit: 20
// }
// });
// }
});
},
isShowChangeBtn: function(currGoodsLen) {
... ...