Authored by 王水玲

search 优化

0 info it worked if it ends with ok
1 verbose cli [ 'D:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using npm@2.15.1
3 info using node@v4.4.4
4 verbose stack Error: ENOENT: no such file or directory, open 'E:\wwwroot\yohobuywap\package.json'
4 verbose stack at Error (native)
5 verbose cwd E:\wwwroot\yohobuywap
6 error Windows_NT 6.1.7601
7 error argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
8 error node v4.4.4
9 error npm v2.15.1
10 error path E:\wwwroot\yohobuywap\package.json
11 error code ENOENT
12 error errno -4058
13 error syscall open
14 error enoent ENOENT: no such file or directory, open 'E:\wwwroot\yohobuywap\package.json'
14 error enoent This is most likely not a problem with npm itself
14 error enoent and is related to npm not being able to find a file.
15 verbose exit [ -4058, true ]
... ...
... ... @@ -6,6 +6,7 @@
var $ = require('jquery'),
security = require('../plugin/security'),
tip = require('../plugin/tip'),
Hammer = require('yoho.hammer');
var $input = $('#search-input input');
... ... @@ -18,8 +19,11 @@ var $form = $('#search-form');
var $history = $('.history');
var $historySearch = $('.history-search');
var $searchAssociate = $('.search-associate');
var $clearHistory = $('#clear-history');
var $buriedpoint = $('.buriedpoint');
var $search = $('#search');
var $searchItems = $('.search-items');
var writeSearch = require('./write-search');
... ... @@ -42,17 +46,56 @@ $input.on('input', function() {
if ($input.val() === '') {
$icon.css('color', '#b2b2b2');
$clear.addClass('hide');
$searchAssociate.html('');
$searchItems.show();
} else {
$icon.css('color', '#666');
$clear.removeClass('hide');
}
// 联动搜索
$.ajax({
url: 'search/fuzzyDatas',
data: {
keyword: $input.val()
},
dataType: 'json',
success: function(data) {
var ajaxHtml = '';
var i;
if (data.length > 0) {
for (i = 0; i < data.length; i++) {
ajaxHtml += '<li><span class="keyword">' + data[i].keyword + '</span><span class="count">' +
data[i].count + ' items<i class="iconfont">&#xe614;</i></span></li>';
}
$searchAssociate.html(ajaxHtml);
$searchItems.hide();
} else {
$searchAssociate.html('');
}
$searchAssociate.find('li').on('touchend', function() {
$buriedpoint.val($(this).find('.keyword').html());
$search.closest('form').submit();
});
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
cHammer = new Hammer($clear[0]);
cHammer.on('tap', function() {
$input.val('').trigger('input');
});
$('#search').on('touchend', function() {
$search.on('touchend', function() {
if ($buriedpoint.val() === '' && $('#default-terms').val() !== '') {
$buriedpoint.val($('#default-terms').val());
}
if (security.hasDangerInput()) {
return false;
}
... ...
... ... @@ -73,31 +73,113 @@
white-space: nowrap;
}
.clear-icon{
.clear-icon {
float: right;
background: #fff;
}
span{
span {
margin-right: 5px;
}
.search-group{
.search-group {
border-bottom: 1px solid #e6e6e6;
margin: 15px 0px;
.search-content-title{
height: 40px;
.left{
float: left;
}
.right{
float: right;
}
.ico-hot {
width: 22px;
height: 30px;
display: inline-block;
background: url('/search/hot-ico.png') no-repeat;
margin-right: 20px;
position: relative;
top: 2px;
}
h3 {
color: #b0b0b0;
font-size: 28px;
}
}
.search-content-title {
height: 40px;
.ico-lately {
width: 26px;
height: 26px;
display: inline-block;
background: url('/search/time-ico.png') no-repeat;
margin-right: 20px;
position: relative;
top: 2px;
}
.ico-del {
width: 24px;
height: 26px;
display: inline-block;
background: url('/search/del-ico.png') no-repeat;
}
.left {
float: left;
}
.right {
float: right;
}
}
.search-content{
clear: both;
padding-left: 47px;
box-sizing: border-box;
padding-bottom: 18px;
a {
border-radius: 8px;
border: 2px solid #b0b0b0;
background: #fff;
color: #b0b0b0;
font-size: 28px;
}
}
.hot-search {
margin-top: 38px;
}
}
.search-associate {
width: 100%;
background: #f8f8f8;
li {
height: 84px;
line-height: 84px;
width: 100%;
padding: 0 20px;
clear: both;
margin-bottom: 5px;
background: #fff;
box-sizing: border-box;
}
.keyword {
float: left;
font-size: 30px;
}
.count {
float: right;
color: #b0b0b0;
font-size: 18px;
.search-content{
clear: both;
i {
font-size: 12PX;
margin-left: 10px;
position: relative;
top: 3px;
}
}
}
... ...
{{> layout/header}}
<div class="search-page yoho-page">
{{# search}}
<div id="search-input" class="search-input">
{{# search}}
<input type="hidden" value="{{defaultTerms}}" id="default-terms">
<div id="search-input" class="search-input">
<form id="search-form" action={{url}} method="get">
<i class="search-icon iconfont">&#xe60f;</i>
<input type="text" placeholder="搜索商品" name="query" data-bp-id="search_page_input_1" class="buriedpoint">
<input type="text" placeholder="{{#if defaultTerms}}{{defaultTerms}}{{else}}搜索商品{{/if}}" name="query" data-bp-id="search_page_input_1" class="buriedpoint" autocomplete="off">
<input type="hidden" name="from" value="search">
<i class="clear-input iconfont hide">&#xe626;</i>
<span id="search" class="search buriedpoint" type="submit" data-bp-id="search_index_one_0">搜索</span>
</form>
</div>
<ul class="search-associate"></ul>
<div class="search-items">
<div class="search-group history-search hide">
<div class="search-content-title">
<h3 class="left">最近搜索</h3>
<i id="clear-history" class="right iconfont hide"></i>
<h3 class="left"><i class="ico-lately"></i>最近搜索</h3>
<i id="clear-history" class="right ico-del hide"></i>
</div>
<div class="search-content">
<ul class="history clearfix"></ul>
... ... @@ -22,14 +24,16 @@
</div>
{{#if hotTerms}}
<div class="search-group hot-search">
<h3>热门搜索</h3>
<ul class="hot clearfix">
{{# hotTerms}}
<li>
<a href='/?query={{content}}'>{{content}}</a>
</li>
{{/ hotTerms}}
</ul>
<h3><i class="ico-hot"></i>热门搜索</h3>
<div class="search-content">
<ul class="hot clearfix">
{{# hotTerms}}
<li>
<a href='/?query={{content}}'>{{content}}</a>
</li>
{{/ hotTerms}}
</ul>
</div>
</div>
{{/if}}
</div>
... ...
... ... @@ -57,12 +57,21 @@
{{/ brandHome}}
<ul id="list-nav" class="list-nav clearfix">
{{#if isSearch}}
<li class="new active buriedpoint" data-bp-id="shop_listnav_new_1">
<a href="javascript:void(0);">
<span class="nav-txt">默认</span>
<span class="iconfont cur">&#xe616;</span>
</a>
</li>
{{else}}
<li class="new active buriedpoint" data-bp-id="shop_listnav_new_1">
<a href="javascript:void(0);">
<span class="nav-txt">最新</span>
<span class="iconfont cur">&#xe616;</span>
</a>
</li>
{{/if}}
<li class="price buriedpoint" data-bp-id="shop_listnav_price_1">
<a href="javascript:void(0);">
<span class="nav-txt">价格</span>
... ...
... ... @@ -211,6 +211,9 @@ class SearchController extends AbstractAction
$this->setNavHeader($condition['title'], true, SITE_MAIN);
}
// 搜索列表将最新改成默认的标识
$data['isSearch'] = true;
$this->_view->display('list', $data);
}
... ...