Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
htoooth
8 years ago
Commit
0847ea2f9ce473d1f4e74b04a869f54c31e5076a
2 parents
a0e7f383
83b38569
Merge branch 'feature/searchTerms' into release/5.5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
apps/product/controllers/search.js
public/js/header.js
apps/product/controllers/search.js
View file @
0847ea2
...
...
@@ -121,7 +121,7 @@ const serachFilterBrands = (req, res, next) => {
const
searchHistory
=
(
req
,
res
)
=>
{
let
history
=
_
.
trim
(
req
.
cookies
[
'_History'
]);
//eslint-disable-line
let
q
=
_
.
trim
(
decodeURIComponent
(
req
.
query
.
query
)
||
''
);
let
q
=
_
.
trim
(
decodeURIComponent
(
req
.
query
.
query
));
let
data
=
[];
let
ResData
=
{};
...
...
@@ -129,7 +129,7 @@ const searchHistory = (req, res) => {
history
=
history
?
history
.
split
(
','
)
:
[];
history
=
_
.
reject
(
history
,
old
=>
old
===
q
?
true
:
false
);
if
(
q
!==
''
)
{
if
(
q
)
{
history
.
unshift
(
q
);
res
.
cookie
(
'_History'
,
_
.
take
(
history
,
9
).
join
(
','
),
{
domain
:
config
.
cookieDomain
,
...
...
@@ -138,12 +138,13 @@ const searchHistory = (req, res) => {
}
_
.
forEach
(
history
,
function
(
item
)
{
if
(
item
!==
'undefined'
)
{
let
list
=
{};
let
list
=
{};
list
[
'keyword'
]
=
item
;
//eslint-disable-line
list
[
'href'
]
=
helpers
.
urlFormat
(
''
,
{
query
:
list
[
'keyword'
]},
'search'
);
//eslint-disable-line
data
.
push
(
list
);
list
[
'keyword'
]
=
item
;
//eslint-disable-line
list
[
'href'
]
=
helpers
.
urlFormat
(
''
,
{
query
:
list
[
'keyword'
]},
'search'
);
//eslint-disable-line
data
.
push
(
list
);
}
});
ResData
[
'data'
]
=
data
;
//eslint-disable-line
...
...
public/js/header.js
View file @
0847ea2
...
...
@@ -328,6 +328,7 @@ function submitSearch() {
if
(
searchKey
===
''
)
{
$
(
'#query-key'
).
val
(
defaultSearch
);
}
$searchKey
.
val
(
searchKey
);
$searchForm
.
submit
();
}
...
...
@@ -927,9 +928,14 @@ function actionAddKeyWords() {
function
searchSuggestHistory
()
{
var
param
=
{
return_type
:
'jsonp'
,
query
:
encodeURIComponent
(
window
.
queryString
().
query
)
||
''
query
:
window
.
queryString
().
query
};
if
(
$searchKey
.
attr
(
'alt'
))
{
param
.
query
=
''
;
$searchKey
.
attr
(
'alt'
,
false
);
}
$
.
getJSON
(
'//search.yohobuy.com/product/search/history?callback=?'
,
param
,
function
(
jsonData
)
{
if
(
$searchKey
.
val
()
===
''
)
{
...
...
@@ -949,6 +955,7 @@ function searchSuggestHistory() {
$
(
'.search-suggest-title .searchDel'
).
click
(
function
()
{
window
.
setCookie
(
'_History'
,
''
,
{
domain
:
'.yohobuy.com'
});
$
(
this
).
closest
(
'.search-suggest-history'
).
hide
();
$searchKey
.
attr
(
'alt'
,
true
);
return
false
;
});
...
...
@@ -1008,7 +1015,9 @@ function searchSuggestRecommend(channel, key) {
*/
$
(
function
()
{
searchSuggestRecommend
();
searchSuggestHistory
();
if
(
location
.
href
.
indexOf
(
'www.yohobuy.com'
)
<
0
)
{
searchSuggestHistory
();
}
});
actionCover
();
...
...
Please
register
or
login
to post a comment