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
Email Patches
Plain Diff
Browse Files
Authored by
OF1706
8 years ago
Commit
da06d573c11b48aea5aeff8714809915fa0f535a
1 parent
b2267289
searchTerms sum2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
64 deletions
apps/product/controllers/search.js
public/js/header.js
apps/product/controllers/search.js
View file @
da06d57
...
...
@@ -118,7 +118,7 @@ const serachFilterBrands = (req, res, next) => {
const
searchHistory
=
(
req
,
res
)
=>
{
let
history
=
_
.
trim
(
req
.
cookies
[
'_History'
]);
let
history
=
_
.
trim
(
req
.
cookies
[
'_History'
]);
//eslint-disable-line
let
q
=
_
.
trim
(
decodeURIComponent
(
req
.
query
.
query
)
||
''
);
let
data
=
[];
...
...
@@ -127,9 +127,9 @@ 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
(
','
),
{
res
.
cookie
(
'_History'
,
_
.
take
(
history
,
9
).
join
(
','
),
{
domain
:
config
.
cookieDomain
,
maxAge
:
60
*
60
*
24
*
1000
*
30
// 一月
});
...
...
public/js/header.js
View file @
da06d57
...
...
@@ -92,7 +92,7 @@ loginFn = handlebars.compile($('#header-login-info-tpl').html() || '');
cartFn
=
handlebars
.
compile
(
$
(
'#mini-cart-tpl'
).
html
()
||
''
);
// handlebars helper
handlebars
.
registerHelper
(
'notzero'
,
function
(
v1
,
options
)
{
handlebars
.
registerHelper
(
'notzero'
,
function
(
v1
,
options
)
{
if
(
v1
!==
'0'
)
{
return
options
.
fn
(
this
);
}
else
{
...
...
@@ -214,7 +214,7 @@ function getBannerAndNotice() {
$
.
getJSON
(
'//new.yohobuy.com/common/getbanner?callback=?'
,
{
client_type
:
'web'
,
content_code
:
code
},
function
(
JsonData
)
{
},
function
(
JsonData
)
{
if
(
+
JsonData
.
code
===
200
)
{
if
(
typeof
JsonData
.
data
===
'object'
)
{
if
(
JsonData
.
data
.
url
!==
''
)
{
...
...
@@ -229,13 +229,13 @@ function getBannerAndNotice() {
// 格式化三级菜单
function
formatThirdMenu
()
{
$subNav
.
each
(
function
()
{
$subNav
.
each
(
function
()
{
var
$thirdList
=
$
(
this
).
find
(
'.hide-list'
),
list
=
[],
i
=
0
;
if
(
$thirdList
.
length
)
{
$thirdList
.
children
().
each
(
function
()
{
$thirdList
.
children
().
each
(
function
()
{
if
(
i
%
thirdLineNum
===
0
)
{
list
.
push
(
''
);
}
...
...
@@ -269,7 +269,7 @@ function syncLoginInfo() {
method
:
'open.passport.get'
};
return
$
.
getJSON
(
'//www.yohobuy.com/common/passport/?callback=?'
,
param
,
function
(
jsonData
)
{
return
$
.
getJSON
(
'//www.yohobuy.com/common/passport/?callback=?'
,
param
,
function
(
jsonData
)
{
if
(
jsonData
&&
jsonData
.
data
&&
jsonData
.
data
.
result
!==
-
1
)
{
updateLoginInfo
(
jsonData
.
data
);
}
else
{
...
...
@@ -288,7 +288,7 @@ function searchSuggest(key) {
keyword
:
key
};
$
.
getJSON
(
'//search.yohobuy.com/product/search/suggest?callback=?'
,
param
,
function
(
jsonData
)
{
$
.
getJSON
(
'//search.yohobuy.com/product/search/suggest?callback=?'
,
param
,
function
(
jsonData
)
{
var
searchSuggestHtml
;
if
(
jsonData
.
code
===
200
)
{
...
...
@@ -315,8 +315,9 @@ function submitSearch() {
}
$searchForm
.
submit
();
}
//触发历史搜索保存
searchSuggestHistory
();
// 触发历史搜索保存
searchSuggestHistory
();
//eslint-disable-line
}
// 同步mini购物车数据
...
...
@@ -355,7 +356,7 @@ function loadCartDetail(key) {
shopping_key
:
key
};
$
.
getJSON
(
'//www.yohobuy.com/common/shoppingCart/?callback=?'
,
param
,
function
(
jsonData
)
{
$
.
getJSON
(
'//www.yohobuy.com/common/shoppingCart/?callback=?'
,
param
,
function
(
jsonData
)
{
var
totalGoods
=
[],
infoArr
=
[
'main_goods'
,
...
...
@@ -368,7 +369,7 @@ function loadCartDetail(key) {
if
(
jsonData
.
code
===
200
)
{
data
=
jsonData
.
data
;
$
.
each
(
infoArr
,
function
(
k
,
v
)
{
$
.
each
(
infoArr
,
function
(
k
,
v
)
{
if
(
data
[
v
])
{
totalGoods
=
$
.
merge
(
totalGoods
,
data
[
v
]);
}
...
...
@@ -395,7 +396,7 @@ function delCartGoods(data, callback) {
product_num
:
data
.
num
};
$
.
getJSON
(
'//www.yohobuy.com/common/delCartGoods/?callback=?'
,
param
,
function
(
jsonData
)
{
$
.
getJSON
(
'//www.yohobuy.com/common/delCartGoods/?callback=?'
,
param
,
function
(
jsonData
)
{
var
strG
=
''
;
if
(
jsonData
.
code
===
200
)
{
...
...
@@ -426,21 +427,21 @@ function requestFrameAct() {
var
func3
=
prefixList
[
2
]
+
'RequestAnimationFrame'
;
if
(
window
[
func1
])
{
return
function
(
callback
)
{
return
function
(
callback
)
{
requestAnimationFrame
(
callback
);
};
}
if
(
window
[
func2
])
{
return
function
(
callback
)
{
return
function
(
callback
)
{
window
[
func2
](
callback
);
};
}
if
(
window
[
func3
])
{
return
function
(
callback
)
{
return
function
(
callback
)
{
window
[
func3
](
callback
);
};
}
return
function
(
callback
)
{
return
function
(
callback
)
{
window
.
setTimeout
(
callback
,
67
);
};
}
...
...
@@ -467,7 +468,7 @@ function tsAnimate() {
if
(
logoAngle
%
360
===
0
)
{
window
.
setTimeout
(
tsAnimate
,
1
*
60
*
1000
);
}
else
{
requestFrame
(
function
()
{
requestFrame
(
function
()
{
tsAnimate
();
});
}
...
...
@@ -485,10 +486,10 @@ function fadeAnimate() {
cycle
=
1
*
60
*
1000
;
}
$logotrans
.
fadeOut
(
loopTime
,
function
()
{
$logotrans
.
fadeOut
(
loopTime
,
function
()
{
$logotrans
.
toggleClass
(
'logo-cn-ie'
);
$logotrans
.
fadeIn
(
loopTime
,
function
()
{
window
.
setTimeout
(
function
()
{
$logotrans
.
fadeIn
(
loopTime
,
function
()
{
window
.
setTimeout
(
function
()
{
fadeAnimate
();
},
cycle
);
});
...
...
@@ -557,7 +558,7 @@ formatThirdMenu(); // 格式化三级菜单
cartTimer
=
setInterval
(
syncCratInfo
,
2000
);
// 定时同步购物车数量
// 获取头部登陆信息
(
function
()
{
(
function
()
{
var
uid
=
getUid
(),
//eslint-disable-line
profileName
=
getProfileName
();
// eslint-disable-line
...
...
@@ -574,14 +575,14 @@ cartTimer = setInterval(syncCratInfo, 2000); // 定时同步购物车数量
$loginBox
.
show
();
}());
fetchUserInfoEvent
.
add
(
function
()
{
fetchUserInfoEvent
.
add
(
function
()
{
if
(
$
(
'.simple-user-center'
).
length
===
0
)
{
return
;
}
syncLoginInfo
();
});
$myYohoBox
.
hover
(
function
()
{
$myYohoBox
.
hover
(
function
()
{
var
uid
=
getUid
();
// eslint-disable-line
$myYohoBox
.
addClass
(
'myyoho-hover'
);
...
...
@@ -591,21 +592,21 @@ $myYohoBox.hover(function () {
}
fetchUserInfoEvent
.
fire
();
},
function
()
{
},
function
()
{
$myYohoBox
.
removeClass
(
'myyoho-hover'
);
});
$yohoGroup
.
hover
(
function
()
{
$yohoGroup
.
hover
(
function
()
{
var
data
=
$
(
this
).
data
();
$
(
this
).
text
(
data
.
cn
);
},
function
()
{
},
function
()
{
var
data
=
$
(
this
).
data
();
$
(
this
).
text
(
data
.
en
);
});
$searchKey
.
keyup
(
function
(
e
)
{
$searchKey
.
keyup
(
function
(
e
)
{
var
val
=
$
.
trim
(
$
(
this
).
val
()),
$child
=
$searchSug
.
find
(
'li'
),
$act
=
$searchSug
.
find
(
'.action'
),
...
...
@@ -641,7 +642,7 @@ $searchKey.keyup(function (e) {
if
(
$searchKey
.
val
()
===
''
)
{
$searchKey
.
mouseenter
();
}
}).
focus
(
function
()
{
}).
focus
(
function
()
{
var
val
=
$
.
trim
(
$
(
this
).
val
());
if
(
val
===
defaultSearch
)
{
...
...
@@ -650,23 +651,23 @@ $searchKey.keyup(function (e) {
$
(
this
).
css
(
'color'
,
'#333'
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
$searchKey
.
mouseenter
();
},
10000
);
}).
blur
(
function
()
{
}).
blur
(
function
()
{
var
val
=
$
.
trim
(
$
(
this
).
val
());
if
(
val
===
''
)
{
$
(
this
).
val
(
defaultSearch
).
css
(
'color'
,
'#999'
);
}
setTimeout
(
function
()
{
setTimeout
(
function
()
{
$searchSug
.
hide
();
},
200
);
});
if
(
$miniCart
&&
$miniCart
.
length
)
{
$goCart
.
hover
(
function
()
{
$goCart
.
hover
(
function
()
{
var
data
,
_html
=
''
;
if
(
$goCart
.
hasClass
(
'on-hover'
))
{
...
...
@@ -682,17 +683,17 @@ if ($miniCart && $miniCart.length) {
}
$miniCart
.
html
(
_html
);
$goCart
.
addClass
(
'on-hover'
);
},
function
()
{
},
function
()
{
$goCart
.
removeClass
(
'on-hover'
);
});
$goCart
.
on
(
'click'
,
'.cart-goods-del'
,
function
()
{
$goCart
.
on
(
'click'
,
'.cart-goods-del'
,
function
()
{
var
$dom
=
$
(
this
),
data
=
$dom
.
data
(),
callback
;
if
(
data
)
{
callback
=
function
()
{
callback
=
function
()
{
$dom
.
closest
(
'.goods-item'
).
remove
();
};
data
.
key
=
$goCart
.
data
().
key
;
...
...
@@ -702,12 +703,12 @@ if ($miniCart && $miniCart.length) {
}
$subNav
.
on
({
mouseenter
:
function
()
{
mouseenter
:
function
()
{
var
$thirdNav
=
$
(
this
).
children
(
'.third-nav-wrapper'
),
$show
=
$thirdNav
.
find
(
'.show-detail'
),
param
=
{};
delayer
=
setTimeout
(
function
()
{
delayer
=
setTimeout
(
function
()
{
$thirdNav
.
show
();
},
200
);
...
...
@@ -719,7 +720,7 @@ $subNav.on({
param
.
width
=
337
;
param
.
height
=
250
;
param
.
_
=
new
Date
();
$
.
getJSON
(
'//new.yohobuy.com/common/getbanner?callback=?'
,
param
,
function
(
JsonData
)
{
$
.
getJSON
(
'//new.yohobuy.com/common/getbanner?callback=?'
,
param
,
function
(
JsonData
)
{
if
(
JsonData
.
code
===
200
)
{
$show
.
addClass
(
'show'
);
$show
.
find
(
'img'
).
attr
(
'src'
,
JsonData
.
data
.
src
);
...
...
@@ -728,7 +729,7 @@ $subNav.on({
}
});
},
mouseleave
:
function
()
{
mouseleave
:
function
()
{
var
$thirdNav
=
$
(
this
).
children
(
'.third-nav-wrapper'
);
if
(
delayer
)
{
...
...
@@ -752,7 +753,7 @@ function actionCover() {
if
(
window
.
location
.
href
===
'http://www.yohobuy.com/'
&&
(
typeof
gender
===
'undefined'
||
gender
===
''
||
gender
===
null
))
{
$
.
get
(
'/guide'
,
function
(
data
)
{
$
.
get
(
'/guide'
,
function
(
data
)
{
newMask
=
document
.
createElement
(
'div'
);
newMask
.
id
=
'cover'
;
newMask
.
innerHTML
=
data
;
...
...
@@ -765,7 +766,7 @@ function actionCover() {
width
:
(
200
*
length
)
+
'px'
,
top
:
containertop
+
'px'
});
$
(
'#cover'
).
bind
(
'click'
,
function
()
{
$
(
'#cover'
).
bind
(
'click'
,
function
()
{
window
.
setCookie
(
'_Gender'
,
'1,3'
,
{
path
:
'/'
,
domain
:
'.yohobuy.com'
,
...
...
@@ -778,7 +779,7 @@ function actionCover() {
});
closeCover
();
});
$
(
'#cover .guide-box .close'
).
bind
(
'click'
,
function
()
{
$
(
'#cover .guide-box .close'
).
bind
(
'click'
,
function
()
{
getSource
(
'弹窗'
,
'CLOSE'
,
'homepage_man'
);
window
.
setCookie
(
'_Gender'
,
'1,3'
,
{
path
:
'/'
,
...
...
@@ -792,7 +793,7 @@ function actionCover() {
});
closeCover
();
});
$
(
'.boys img , .boys .go'
).
bind
(
'click'
,
function
()
{
$
(
'.boys img , .boys .go'
).
bind
(
'click'
,
function
()
{
getSource
(
'弹窗'
,
'BOYS'
,
'homepage_man'
);
window
.
setCookie
(
'_Gender'
,
'1,3'
,
{
path
:
'/'
,
...
...
@@ -806,7 +807,7 @@ function actionCover() {
});
closeCover
();
});
$
(
'.girls img, .girls .go'
).
bind
(
'click'
,
function
()
{
$
(
'.girls img, .girls .go'
).
bind
(
'click'
,
function
()
{
getSource
(
'弹窗'
,
'GIRLS'
,
'homepage_woman'
);
window
.
setCookie
(
'_Gender'
,
'2,3'
,
{
path
:
'/'
,
...
...
@@ -819,7 +820,7 @@ function actionCover() {
expires
:
7
});
});
$
(
'.lifestyle img, .lifestyle .go'
).
bind
(
'click'
,
function
()
{
$
(
'.lifestyle img, .lifestyle .go'
).
bind
(
'click'
,
function
()
{
window
.
setCookie
(
'_Channel'
,
'lifestyle'
,
{
path
:
'/'
,
domain
:
'.yohobuy.com'
,
...
...
@@ -827,11 +828,11 @@ function actionCover() {
});
getSource
(
'弹窗'
,
'LIEFSTYLE'
,
'homepage_lifestyle'
);
});
$
(
'#cover .guide-box'
).
bind
(
'click'
,
function
(
event
)
{
$
(
'#cover .guide-box'
).
bind
(
'click'
,
function
(
event
)
{
event
.
stopPropagation
();
});
});
$
(
'#cover .guide-box'
).
bind
(
'click'
,
function
(
e
)
{
$
(
'#cover .guide-box'
).
bind
(
'click'
,
function
(
e
)
{
e
.
stopPropagation
();
});
}
...
...
@@ -841,7 +842,7 @@ window.submitSearch = submitSearch;
function
emailUserCertTip
()
{
return
$
.
getJSON
(
'//www.yohobuy.com/passport/cert/headerTip?callback=?'
,
function
(
jsonData
)
{
return
$
.
getJSON
(
'//www.yohobuy.com/passport/cert/headerTip?callback=?'
,
function
(
jsonData
)
{
if
(
jsonData
&&
jsonData
.
data
===
'Y'
)
{
$
(
'#yoho-header .yoho-cert-tip'
).
html
(
'<i class="iconfont left"></i> '
+
...
...
@@ -862,7 +863,7 @@ function actionAddKeyWords() {
}
else
{
$searchKey
.
val
(
defaultSearch
).
css
(
'color'
,
'#999'
);
}
$
(
document
).
click
(
function
(
e
)
{
$
(
document
).
click
(
function
(
e
)
{
if
(
!
$
(
e
.
target
).
closest
(
'.searchspan, .search-list'
).
length
)
{
$
(
'.search-list'
).
hide
();
}
...
...
@@ -877,20 +878,21 @@ function actionAddKeyWords() {
function
searchSuggestHistory
()
{
$
.
getJSON
(
'//search.yohobuy.com/product/search/history?query='
+
encodeURIComponent
(
$searchKey
.
val
()),
function
(
jsonData
)
{
encodeURIComponent
(
$searchKey
.
val
()),
function
(
jsonData
)
{
if
(
$searchKey
.
val
()
===
''
)
{
var
searchSuggestHistoryHtml
;
var
searchSuggestHistoryHtml
;
//eslint-disable-line
searchSuggestHistoryHtml
=
handlebars
.
compile
(
$searchHistoryHbs
.
html
()
||
''
);
$searchHistory
.
html
(
searchSuggestHistoryHtml
(
jsonData
)).
show
();
if
(
$searchHistory
.
find
(
"li"
).
length
===
0
)
{
if
(
$searchHistory
.
find
(
'li'
).
length
===
0
)
{
$searchHistory
.
hide
();
}
//历史记录清空
$
(
'.search-suggest-title .searchDel'
).
click
(
function
()
{
// 历史记录清空
$
(
'.search-suggest-title .searchDel'
).
click
(
function
()
{
window
.
setCookie
(
'_History'
,
''
,
{
domain
:
'.yohobuy.com'
});
$
(
this
).
closest
(
'.search-suggest-history'
).
hide
();
return
false
;
...
...
@@ -906,25 +908,25 @@ function searchSuggestHistory() {
* @return {[type]} [description]
*/
$searchKey
.
mouseenter
(
function
()
{
$searchKey
.
mouseenter
(
function
()
{
var
val
=
$
.
trim
(
$
(
this
).
val
());
if
(
val
===
''
)
{
searchSuggestHistory
();
}
}).
mouseleave
(
function
()
{
}).
mouseleave
(
function
()
{
$searchHistory
.
hide
();
});
$
(
'.search-suggest-history'
).
mouseenter
(
function
()
{
$
(
'.search-suggest-history'
).
mouseenter
(
function
()
{
if
(
$searchHistory
.
find
(
"li"
).
length
===
0
)
{
if
(
$searchHistory
.
find
(
'li'
).
length
===
0
)
{
$searchHistory
.
hide
();
}
else
{
}
else
{
$searchHistory
.
show
();
}
}).
mouseleave
(
function
()
{
}).
mouseleave
(
function
()
{
$searchHistory
.
hide
();
});
...
...
@@ -938,7 +940,7 @@ function searchSuggestRecommend(key) {
keyword
:
key
};
$
.
getJSON
(
'//search.yohobuy.com/product/search/recommend?callback=?'
,
param
,
function
(
jsonData
)
{
$
.
getJSON
(
'//search.yohobuy.com/product/search/recommend?callback=?'
,
param
,
function
(
jsonData
)
{
var
searchSuggestRecommendHtml
;
//eslint-disable-line
...
...
@@ -960,7 +962,7 @@ function searchSuggestRecommend(key) {
* 搜索 热门搜索和默认搜索 dom
* @return {[type]} [description]
*/
$
(
function
()
{
$
(
function
()
{
searchSuggestRecommend
();
});
...
...
Please
register
or
login
to post a comment