Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
郭成尧
8 years ago
Commit
cdf9602bad3985e8e74738a69c6b5f018dadb3d4
1 parent
09c0c26d
'shop-brand-fav-ok'
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
83 deletions
apps/product/controllers/list.js
public/js/product/search/list.js
public/js/product/shop/shop.js
apps/product/controllers/list.js
View file @
cdf9602
...
...
@@ -104,9 +104,9 @@ const _shop = (req, res, shopId) => {
shopHeadHide
:
true
,
gender
:
req
.
query
.
gender
,
channel
:
req
.
query
.
channel
,
pageHeader
:
headerModel
.
setNav
({
navTitle
:
result
.
storeName
}),
// pageHeader: headerModel.setNav({
// navTitle: result.storeName
// }),
title
:
result
.
storeName
+
'|'
+
result
.
storeName
+
'潮流服装服饰-Yoho!Buy有货'
,
keywords
:
result
.
storeName
+
','
+
result
.
storeName
+
'服装服饰,'
+
result
.
storeName
+
'潮流服装服饰'
,
description
:
result
.
storeName
+
'|Yoho!Buy有货'
+
result
.
storeName
+
'潮流服饰官方授权店!100%品牌正品保证,支持货到付款。'
,
...
...
@@ -305,7 +305,10 @@ const shopIntro = (req, res, next) => {
* opt 操作标识("ok":表示收藏,"cancel":表示取消收藏)
*/
const
favoriteBrand
=
(
req
,
res
,
next
)
=>
{
res
.
setHeader
(
'Access-Control-Allow-Origin'
,
req
.
protocol
+
'://'
+
req
.
headers
.
origin
);
let
allowOrigin
=
_
.
get
(
req
,
'headers.origin'
,
null
)
?
req
.
headers
.
origin
:
req
.
protocol
+
'://'
+
req
.
headers
.
host
;
res
.
setHeader
(
'Access-Control-Allow-Origin'
,
allowOrigin
);
res
.
setHeader
(
'Access-Control-Allow-Credentials'
,
'true'
);
let
id
=
req
.
query
.
id
;
...
...
@@ -313,29 +316,28 @@ const favoriteBrand = (req, res, next) => {
let
opt
=
req
.
query
.
opt
||
'ok'
;
let
type
=
req
.
query
.
type
||
'product'
;
let
appVersion
=
req
.
query
.
appVersion
||
false
;
let
url
=
helpers
.
urlFormat
(
'/signin.html'
)
+
'?refer='
+
decodeURI
(
req
.
cookies
.
refer
);
let
refer
=
req
.
get
(
'Referer'
)
||
`
$
{
global
.
yoho
.
config
.
siteUrl
}
/${req.cookies._Channel || ''}`
;
let
url
=
helpers
.
urlFormat
(
'/signin.html'
)
+
'?refer='
+
refer
;
if
(
appVersion
===
'true'
)
{
uid
=
req
.
cookies
.
appUid
;
url
=
`
$
{
url
}
&
openby
:
yohobuy
=
{
"action"
:
"go.weblogin"
,
"params"
:{
"jumpurl"
:{
"url"
:
$
{
decodeURI
(
req
.
cookies
.
refer
)},
"param"
:{}},
"requesturl"
:{
"param"
:{},
"url"
:
""
},
"priority"
:
"Y"
}}
`
;
// eslint-disable-line
}
if
(
_
.
isNumber
(
id
))
{
res
.
json
({
if
(
!
id
)
{
return
res
.
json
({
code
:
401
,
message
:
'参数不正确'
,
data
:
false
});
return
false
;
}
if
(
!
uid
)
{
res
.
json
({
re
turn
re
s
.
json
({
code
:
400
,
message
:
'未登录'
,
data
:
url
});
return
false
;
}
if
(
opt
!==
'ok'
)
{
// 取消收藏
...
...
public/js/product/search/list.js
View file @
cdf9602
...
...
@@ -72,7 +72,7 @@ require('../../common');
ellipsis
.
init
();
// pageCache 获取是否收藏
(
function
()
{
(
function
()
{
if
(
$
(
'.domain'
).
val
())
{
$
.
ajax
({
url
:
'/product/index/brandFav'
,
...
...
@@ -80,12 +80,12 @@ ellipsis.init();
domain
:
$
(
'.domain'
).
val
()
},
dataType
:
'json'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
data
.
collected
)
{
$
(
'.brand-header .btn-col'
).
addClass
(
'coled'
);
}
},
error
:
function
()
{
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
}
});
...
...
@@ -96,12 +96,12 @@ ellipsis.init();
shopId
:
$
(
'.shopId'
).
val
()
},
dataType
:
'json'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
data
.
collect
)
{
$
(
'.brand-header .btn-col'
).
addClass
(
'coled'
);
}
},
error
:
function
()
{
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
}
});
...
...
@@ -114,7 +114,7 @@ function inputAction() {
var
$icon
=
$
(
'.search-icon'
);
var
$searchItems
=
$
(
'.search-items'
);
$input
.
on
(
'input'
,
function
()
{
$input
.
on
(
'input'
,
function
()
{
if
(
$input
.
val
()
===
''
)
{
$icon
.
css
(
'color'
,
'#b2b2b2'
);
$clear
.
addClass
(
'hide'
);
...
...
@@ -134,14 +134,14 @@ function inputAction() {
keyword
:
$input
.
val
()
},
dataType
:
'json'
,
success
:
function
(
data
)
{
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"></i></span></li>'
;
data
[
i
].
count
+
' items<i class="iconfont"></i></span></li>'
;
}
$searchAssociate
.
html
(
ajaxHtml
);
...
...
@@ -150,12 +150,12 @@ function inputAction() {
$searchAssociate
.
html
(
''
);
}
$searchAssociate
.
find
(
'li'
).
on
(
'touchend'
,
function
()
{
$searchAssociate
.
find
(
'li'
).
on
(
'touchend'
,
function
()
{
$buriedpoint
.
val
(
$
(
this
).
find
(
'.keyword'
).
html
());
$search
.
closest
(
'form'
).
submit
();
});
},
error
:
function
()
{
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
}
});
...
...
@@ -164,14 +164,14 @@ function inputAction() {
inputAction
();
$clear
.
on
(
'touchend'
,
function
()
{
$clear
.
on
(
'touchend'
,
function
()
{
$input
.
val
(
''
).
trigger
(
'input'
);
});
/**
* 手动触发搜索
*/
$search
.
on
(
'touchend'
,
function
()
{
$search
.
on
(
'touchend'
,
function
()
{
$
(
this
).
closest
(
'form'
).
submit
();
return
false
;
});
...
...
@@ -344,7 +344,7 @@ function search(opt) {
type
:
'GET'
,
url
:
location
.
protocol
+
'//m.yohobuy.com/product/search/search'
,
data
:
setting
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
var
noResult
=
'<p class="no-result">未找到相关搜索结果</p>'
,
num
,
$container
;
...
...
@@ -391,7 +391,7 @@ function search(opt) {
window
.
rePosFooter
();
$
(
'.good-detail-text .name'
).
each
(
function
()
{
$
(
'.good-detail-text .name'
).
each
(
function
()
{
$this
=
$
(
this
);
$title
=
$this
.
find
(
'a'
);
...
...
@@ -403,15 +403,15 @@ function search(opt) {
switch
(
navType
)
{
case
'newest'
:
window
.
_yas
(
1
*
new
Date
(),
'1.0.16'
,
'yohobuy_m'
,
window
.
_ozuid
,
''
,
$
(
'.new-goods .good-info .good-detail-img .good-thumb'
));
''
,
$
(
'.new-goods .good-info .good-detail-img .good-thumb'
));
break
;
case
'price'
:
window
.
_yas
(
1
*
new
Date
(),
'1.0.16'
,
'yohobuy_m'
,
window
.
_ozuid
,
''
,
$
(
'.price-goods .good-info .good-detail-img .good-thumb'
));
''
,
$
(
'.price-goods .good-info .good-detail-img .good-thumb'
));
break
;
case
'discount'
:
window
.
_yas
(
1
*
new
Date
(),
'1.0.16'
,
'yohobuy_m'
,
window
.
_ozuid
,
''
,
$
(
'.discount-goods .good-info .good-detail-img .good-thumb'
));
''
,
$
(
'.discount-goods .good-info .good-detail-img .good-thumb'
));
break
;
default
:
break
;
...
...
@@ -433,13 +433,13 @@ $.ajax({
type
:
'GET'
,
url
:
location
.
protocol
+
'//m.yohobuy.com/product/search/filter'
,
data
:
defaultOpt
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
$goodsContainer
.
append
(
data
);
// 初始化filter&注册filter回调
filter
.
initFilter
({
fCbFn
:
search
,
hCbFn
:
function
()
{
hCbFn
:
function
()
{
// 切换active状态到$pre上
$pre
.
addClass
(
'active'
);
...
...
@@ -460,11 +460,11 @@ writeSearch.bindWirteLocal($('#search-form'));
// 4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
// 5.当前active为筛选并且点击其他项时,隐藏筛选面板
$listNav
.
bind
(
'contextmenu'
,
function
()
{
$listNav
.
bind
(
'contextmenu'
,
function
()
{
return
false
;
});
$listNav
.
on
(
'touchend touchcancel'
,
function
(
e
)
{
$listNav
.
on
(
'touchend touchcancel'
,
function
(
e
)
{
var
$this
=
$
(
e
.
target
).
closest
(
'li'
),
nav
,
navType
,
...
...
@@ -566,7 +566,7 @@ function scrollHandler() {
}
// srcoll to load more
$
(
window
).
scroll
(
function
()
{
$
(
window
).
scroll
(
function
()
{
window
.
requestAnimationFrame
(
scrollHandler
);
});
...
...
@@ -574,7 +574,7 @@ if ($brandHeader.length > 0) {
// 品牌介绍
btnIntroHammer
=
new
Hammer
(
$brandHeader
.
children
(
'.btn-intro'
)[
0
]);
btnIntroHammer
.
on
(
'tap'
,
function
()
{
btnIntroHammer
.
on
(
'tap'
,
function
()
{
$introBox
.
removeClass
(
'hide'
);
// 防止混合scroll发生
...
...
@@ -583,7 +583,7 @@ if ($brandHeader.length > 0) {
// 关闭品牌介绍
introHammer
=
new
Hammer
(
document
.
getElementById
(
'intro-box'
));
introHammer
.
on
(
'tap'
,
function
(
e
)
{
introHammer
.
on
(
'tap'
,
function
(
e
)
{
var
$this
=
$
(
e
.
target
);
e
.
srcEvent
.
preventDefault
();
...
...
@@ -597,7 +597,7 @@ if ($brandHeader.length > 0) {
// 品牌收藏
brandColHammer
=
new
Hammer
(
$brandHeader
.
children
(
'.btn-col'
)[
0
]);
brandColHammer
.
on
(
'tap'
,
function
(
e
)
{
brandColHammer
.
on
(
'tap'
,
function
(
e
)
{
var
$this
=
$
(
e
.
target
).
closest
(
'.btn-col'
);
var
id
=
$brandHeader
.
data
(
'id'
),
...
...
@@ -617,10 +617,10 @@ if ($brandHeader.length > 0) {
opt
:
opt
,
type
:
$brandHeader
.
data
(
'isbaseshop'
)
?
'shop'
:
'brand'
},
xhrFields
:
{
withCredentials
:
true
},
success
:
function
(
data
)
{
xhrFields
:
{
withCredentials
:
true
},
success
:
function
(
data
)
{
if
(
data
.
code
===
200
)
{
$this
.
toggleClass
(
'coled'
);
...
...
@@ -636,7 +636,7 @@ if ($brandHeader.length > 0) {
tip
.
show
(
data
.
message
);
}
},
error
:
function
()
{
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
}
});
...
...
@@ -646,9 +646,9 @@ if ($brandHeader.length > 0) {
// 初始请求最新第一页数据
search
();
$listNav
.
on
(
'touchstart'
,
'li'
,
function
()
{
$listNav
.
on
(
'touchstart'
,
'li'
,
function
()
{
$listNav
.
find
(
'li'
).
removeClass
(
'bytouch'
);
$
(
this
).
addClass
(
'bytouch'
);
}).
on
(
'touchend touchcancel'
,
'li'
,
function
()
{
}).
on
(
'touchend touchcancel'
,
'li'
,
function
()
{
$listNav
.
find
(
'li'
).
removeClass
(
'bytouch'
);
});
...
...
public/js/product/shop/shop.js
View file @
cdf9602
...
...
@@ -43,7 +43,7 @@ var winH = $(window).height(),
require
(
'../../common'
);
// pagecache判断app设置cookie,判断是否收藏
(
function
()
{
(
function
()
{
var
param
=
location
.
search
;
var
isApp
=
param
.
indexOf
(
'app_version'
)
>
-
1
||
param
.
indexOf
(
'appVersion'
)
>
-
1
;
...
...
@@ -51,7 +51,7 @@ require('../../common');
$
.
ajax
({
type
:
'GET'
,
url
:
'/product/index/shopAppCookie'
,
error
:
function
()
{
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
}
});
...
...
@@ -63,12 +63,12 @@ require('../../common');
data
:
{
shopId
:
$
(
'.shopid'
).
val
(),
},
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
data
.
collect
)
{
$collect
.
attr
(
'class'
,
'already-collect'
);
}
},
error
:
function
()
{
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
}
});
...
...
@@ -191,14 +191,14 @@ function getPageGoods(info) {
type
:
'GET'
,
url
:
info
.
url
,
data
:
info
.
data
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
data
===
' '
)
{
nav
.
end
=
true
;
}
info
.
callBack
(
data
);
},
error
:
function
()
{
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
searching
=
false
;
}
...
...
@@ -228,7 +228,7 @@ function newData(callback) {
getParam
(
req
);
req
.
callBack
=
function
(
data
)
{
req
.
callBack
=
function
(
data
)
{
$
(
'#new-arrival'
).
append
(
data
);
navInfo
.
new
.
page
++
;
myScroll
&&
myScroll
.
refresh
();
...
...
@@ -253,7 +253,7 @@ function hotData(callback) {
getParam
(
req
);
req
.
callBack
=
function
(
data
)
{
req
.
callBack
=
function
(
data
)
{
$
(
'#popularity'
).
append
(
data
);
navInfo
.
hot
.
page
++
;
myScroll
&&
myScroll
.
refresh
();
...
...
@@ -273,12 +273,10 @@ function tabChange(dom, index) {
}
// 首页导航
(
function
(
nav
,
posNav
,
main
)
{
(
function
(
nav
,
posNav
,
main
)
{
$
(
nav
+
' li, '
+
posNav
+
' li'
).
not
(
'li.all-goods'
).
on
(
'touchstart'
,
function
()
{
$
(
nav
+
' li, '
+
posNav
+
' li'
).
not
(
'li.all-goods'
).
on
(
'touchstart'
,
function
()
{
var
index
=
$
(
this
).
index
(),
activeTab
=
$
(
this
).
attr
(
'tab'
);
...
...
@@ -376,7 +374,7 @@ function scrollHandler() {
}
if
(
sTop
+
winH
*
2
>
scH
)
{
scrollCall
=
function
()
{
scrollCall
=
function
()
{
var
translate
=
'translate3d(0, '
+
(
-
scH
)
+
'px, 0)'
;
$nav1
.
css
({
transform
:
translate
,
...
...
@@ -468,7 +466,7 @@ function scrollHandler() {
$
(
'#scroller'
).
trigger
(
'scroll'
);
}
document
.
addEventListener
(
'touchmove'
,
function
(
e
)
{
document
.
addEventListener
(
'touchmove'
,
function
(
e
)
{
// sub classify不阻止默认事件
if
(
$
(
e
.
target
).
closest
(
'.sub-classify'
).
length
===
0
)
{
e
.
preventDefault
();
...
...
@@ -476,12 +474,12 @@ document.addEventListener('touchmove', function(e) {
},
false
);
/* if (!isIphone) {
return;
}*/
return;
}*/
// window ready 后重新refresh iscroll
$
(
window
).
ready
(
function
()
{
$
(
window
).
ready
(
function
()
{
// myScroll && myScroll.refresh();
imgH
=
$
(
'#nav-top'
).
outerHeight
();
nav1H
=
$
(
'#nav'
).
outerHeight
();
...
...
@@ -497,14 +495,14 @@ $(window).ready(function() {
click
:
true
});
setTimeout
(
function
()
{
setTimeout
(
function
()
{
scH
=
$
(
'#scroller'
).
outerHeight
();
},
500
);
myScroll
.
on
(
'scroll'
,
scrollHandler
);
myScroll
.
on
(
'scrollStart'
,
function
()
{
myScroll
.
on
(
'scrollStart'
,
function
()
{
// stop auto play when scroll
bannerSwiper
&&
bannerSwiper
.
stopAutoplay
();
...
...
@@ -512,7 +510,7 @@ $(window).ready(function() {
multiSwiper
&&
multiSwiper
.
stopAutoplay
();
});
myScroll
.
on
(
'scrollEnd'
,
function
()
{
myScroll
.
on
(
'scrollEnd'
,
function
()
{
// start auto play when scroll end
bannerSwiper
&&
bannerSwiper
.
startAutoplay
();
...
...
@@ -657,7 +655,7 @@ function search(opt) {
type
:
'GET'
,
url
:
opt
.
url
?
opt
.
url
:
''
,
data
:
setting
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
var
$container
,
num
;
...
...
@@ -707,7 +705,7 @@ function search(opt) {
bindGoodThumbClick
();
},
error
:
function
()
{
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
searching
=
false
;
loading
.
hideLoadingMask
();
...
...
@@ -716,11 +714,11 @@ function search(opt) {
}
$listNav
.
bind
(
'contextmenu'
,
function
(
e
)
{
$listNav
.
bind
(
'contextmenu'
,
function
(
e
)
{
return
false
;
});
$subNav
.
on
(
'touchend touchcancel'
,
function
(
e
)
{
$subNav
.
on
(
'touchend touchcancel'
,
function
(
e
)
{
var
$this
=
$
(
e
.
target
).
closest
(
'li'
),
cname
,
nav
,
...
...
@@ -863,11 +861,11 @@ $subNav.on('touchend touchcancel', function(e) {
});
filter
.
initFilter
({
fCbFn
:
function
(
option
)
{
fCbFn
:
function
(
option
)
{
search
(
option
);
myScroll
&&
myScroll
.
enable
();
},
hCbFn
:
function
()
{
hCbFn
:
function
()
{
// 切换active状态到$pre上
$pre
.
addClass
(
'active'
);
...
...
@@ -878,17 +876,17 @@ filter.initFilter({
missStatus
:
true
});
$listNav
.
on
(
'touchstart'
,
'li'
,
function
(
e
)
{
$listNav
.
on
(
'touchstart'
,
'li'
,
function
(
e
)
{
$
(
this
).
addClass
(
'bytouch'
);
}).
on
(
'touchend touchcancel'
,
function
()
{
}).
on
(
'touchend touchcancel'
,
function
()
{
$listNav
.
find
(
'li'
).
removeClass
(
'bytouch'
);
// myScroll && myScroll.refresh();
});
$nav2
.
on
(
'touchstart'
,
'li'
,
function
(
e
)
{
$nav2
.
on
(
'touchstart'
,
'li'
,
function
(
e
)
{
$
(
this
).
addClass
(
'bytouch'
);
}).
on
(
'touchend touchcancel'
,
function
()
{
}).
on
(
'touchend touchcancel'
,
function
()
{
$nav2
.
find
(
'li'
).
removeClass
(
'bytouch'
);
// myScroll && myScroll.refresh();
...
...
@@ -896,7 +894,7 @@ $nav2.on('touchstart', 'li', function(e) {
// 底部导航点击
function
fotterClick
(
group
)
{
$
(
group
+
' li'
).
on
(
'touchstart'
,
function
()
{
$
(
group
+
' li'
).
on
(
'touchstart'
,
function
()
{
$
(
'.sub-group'
).
addClass
(
'hide'
);
$
(
this
).
find
(
'.sub-group'
).
removeClass
(
'hide'
);
});
...
...
@@ -912,16 +910,16 @@ function stopPropagation(e) {
}
}
$
(
document
).
bind
(
'touchstart'
,
function
()
{
$
(
document
).
bind
(
'touchstart'
,
function
()
{
$
(
'.sub-group'
).
addClass
(
'hide'
);
});
$
(
'.shop-foot-wrapper'
).
bind
(
'touchstart'
,
function
(
e
)
{
$
(
'.shop-foot-wrapper'
).
bind
(
'touchstart'
,
function
(
e
)
{
stopPropagation
(
e
);
});
// 店铺收藏 || 取消收藏
$collect
.
on
(
'touchstart'
,
function
()
{
$collect
.
on
(
'touchstart'
,
function
()
{
var
opt
;
if
(
searching
)
{
...
...
@@ -944,10 +942,10 @@ $collect.on('touchstart', function() {
opt
:
opt
,
type
:
'shop'
},
xhrFields
:
{
withCredentials
:
true
},
success
:
function
(
data
)
{
xhrFields
:
{
withCredentials
:
true
},
success
:
function
(
data
)
{
var
url
=
''
;
if
(
data
.
code
===
200
)
{
...
...
@@ -961,20 +959,20 @@ $collect.on('touchstart', function() {
}
if
(
data
.
code
===
400
)
{
url
=
data
;
url
=
data
.
data
;
if
(
$
(
'#jump-login'
).
length
<=
0
)
{
$
(
'body'
).
append
(
'<a href=\''
+
url
+
'\'><span id="jump-login"><span></a>'
);
}
$
(
'#jump-login'
).
click
();
}
setTimeout
(
function
()
{
setTimeout
(
function
()
{
myScroll
&&
myScroll
.
refresh
();
scH
=
$
(
'#scroller'
).
outerHeight
();
},
500
);
searching
=
false
;
},
error
:
function
()
{
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
searching
=
false
;
}
...
...
Please
register
or
login
to post a comment