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
zhangxiaoru
8 years ago
Commit
cc80e80c0bd660337be96263f61a50a28662629d
1 parent
d26539f6
search
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
10 deletions
apps/product/controllers/search.js
apps/product/models/search.js
apps/product/views/action/search/page.hbs
public/js/channel/home.page.js
public/js/product/detail/like.js
public/js/product/search/list.js
apps/product/controllers/search.js
View file @
cc80e80
...
...
@@ -184,7 +184,8 @@ const search = (req, res, next) => {
searchModel
.
getSearchData
(
params
).
then
((
result
)
=>
{
res
.
render
(
'search/page'
,
{
layout
:
false
,
new
:
result
new
:
result
.
list
,
total
:
result
.
total
});
}).
catch
(
next
);
};
...
...
apps/product/models/search.js
View file @
cc80e80
...
...
@@ -145,10 +145,15 @@ const _searchGoods = (params) => {
const
getSearchData
=
(
params
)
=>
{
return
_searchGoods
(
params
).
then
((
result
)
=>
{
if
(
result
&&
result
.
code
===
200
)
{
return
productProcess
.
processProductList
(
result
.
data
.
product_list
||
[],
{
let
newList
=
{};
newList
.
total
=
result
.
data
.
total
;
newList
.
list
=
productProcess
.
processProductList
(
result
.
data
.
product_list
||
[],
{
isApp
:
params
.
isApp
||
(
params
.
appVersion
&&
params
.
appVersion
!==
'false'
),
gender
:
_coverChannel
[
params
.
coverChannel
]
});
return
newList
;
}
else
{
logger
.
error
(
'get product search api return code is not 200'
);
return
[];
...
...
@@ -233,7 +238,6 @@ const getSearchIndex = () => {
},
{
cache
:
true
}).
then
((
result
)
=>
{
console
.
log
(
result
)
if
(
result
&&
result
.
code
===
200
)
{
return
result
.
data
;
}
else
{
...
...
apps/product/views/action/search/page.hbs
View file @
cc80e80
<div
class=
"total"
data-id=
"
{{
total
}}
"
></div>
{{#
new
}}
{{>
common
/
goods
}}
{{/
new
}}
...
...
public/js/channel/home.page.js
View file @
cc80e80
...
...
@@ -254,4 +254,4 @@ $('.search-btn').click(function() {
})
},
true
);
}
})
})
;
...
...
public/js/product/detail/like.js
View file @
cc80e80
...
...
@@ -51,7 +51,7 @@ $('#likeBtn').on('touchstart', function() {
COL_TYPE
:
2
})
},
true
);
}
}
}
else
{
opt
=
'ok'
;
favorite
=
1
;
...
...
@@ -65,7 +65,7 @@ $('#likeBtn').on('touchstart', function() {
COL_TYPE
:
1
})
},
true
);
}
}
}
$
.
ajax
({
...
...
@@ -82,7 +82,7 @@ $('#likeBtn').on('touchstart', function() {
if
(
opt
===
'cancel'
)
{
tip
.
show
(
'取消收藏成功'
);
}
else
if
(
opt
===
'ok'
)
{
tip
.
show
(
'收藏成功'
);
tip
.
show
(
'收藏成功'
);
}
}
else
if
(
data
.
code
===
400
)
{
location
.
href
=
data
.
data
;
// 未登录跳转登录页
...
...
public/js/product/search/list.js
View file @
cc80e80
...
...
@@ -67,6 +67,8 @@ var $listNav = $('#list-nav'),
introHammer
,
brandColHammer
;
var
getChannel
,
C_ID
,
RES_QTY
,
qwert
;
require
(
'../../common'
);
ellipsis
.
init
();
...
...
@@ -199,6 +201,19 @@ misort = getQueryString('misort');
coin
=
getQueryString
(
'coin'
);
app_version
=
getQueryString
(
'app_version'
)
||
getQueryString
(
'appVersion'
);
getChannel
=
function
functionName
()
{
var
name
=
window
.
cookie
(
'_Channel'
);
return
{
boys
:
1
,
girls
:
2
,
kids
:
3
,
lifestyle
:
4
}[
name
]
||
1
;
};
C_ID
=
getChannel
();
/**
* 筛选注册的回调,筛选子项点击后逻辑
* 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
...
...
@@ -358,6 +373,8 @@ function search(opt) {
searching
=
true
;
loading
.
showLoadingMask
();
qwert
=
setting
;
$
.
ajax
({
type
:
'GET'
,
url
:
location
.
protocol
+
'//m.yohobuy.com/product/search/search'
,
...
...
@@ -365,7 +382,9 @@ function search(opt) {
success
:
function
(
data
)
{
var
noResult
=
'<p class="no-result">未找到相关搜索结果</p>'
,
num
,
$container
;
$container
,
goodIds
=
[],
FILTER_VALUE
;
switch
(
navType
)
{
case
'newest'
:
...
...
@@ -391,14 +410,66 @@ function search(opt) {
if
(
nav
.
reload
)
{
$container
.
html
(
data
);
lazyLoad
(
$container
.
find
(
'.lazy'
));
RES_QTY
=
$container
.
find
(
'.total'
).
data
(
'id'
);
FILTER_VALUE
=
JSON
.
stringify
(
setting
).
replace
(
/
\{
|
\}
|
\"
/g
,
""
);
$container
.
find
(
'.good-info'
).
each
(
function
()
{
var
goodid
=
$
(
this
).
data
(
'good-id'
);
if
(
goodid
)
{
goodIds
.
push
(
goodid
);
}
});
if
(
window
.
_yas
&&
window
.
_yas
.
sendCustomInfo
)
{
window
.
_yas
.
sendCustomInfo
({
op
:
'YB_KEYWORD_GOOS_LIST_L'
,
param
:
JSON
.
stringify
({
C_ID
:
C_ID
,
KEYWORD
:
setting
.
query
||
''
,
RES_QTY
:
RES_QTY
,
PRD_LIST
:
goodIds
,
PAGE_NUM
:
setting
.
page
,
FILTER_VALUE
:
FILTER_VALUE
,
SORT_TYPE
:
setting
.
type
})
},
true
);
}
}
else
{
num
=
$container
.
find
(
'.good-info'
).
length
;
$container
.
append
(
data
);
if
(
$container
.
find
(
'.total'
))
{
$container
.
find
(
'.total'
)[
1
].
remove
();
}
$container
.
find
(
'.good-info:gt('
+
(
num
-
1
)
+
')'
).
each
(
function
()
{
var
goodid
=
$
(
this
).
data
(
'good-id'
);
if
(
goodid
)
{
goodIds
.
push
(
goodid
);
}
})
if
(
window
.
_yas
&&
window
.
_yas
.
sendCustomInfo
)
{
window
.
_yas
.
sendCustomInfo
({
op
:
'YB_KEYWORD_GOOS_LIST_L'
,
param
:
JSON
.
stringify
({
C_ID
:
C_ID
,
KEYWORD
:
setting
.
query
||
''
,
RES_QTY
:
RES_QTY
,
PRD_LIST
:
goodIds
,
PAGE_NUM
:
setting
.
page
,
FILTER_VALUE
:
FILTER_VALUE
,
SORT_TYPE
:
setting
.
type
})
},
true
);
}
// lazy good-infos who append in
lazyLoad
(
$container
.
find
(
'.good-info:gt('
+
(
num
-
1
)
+
') .lazy'
));
}
}
nav
.
reload
=
false
;
...
...
@@ -435,9 +506,10 @@ function search(opt) {
break
;
}
}
}
});
}
require
(
'../../common/suspend-cart'
);
// 悬浮购物车
...
...
@@ -670,3 +742,27 @@ $listNav.on('touchstart', 'li', function() {
}).
on
(
'touchend touchcancel'
,
'li'
,
function
()
{
$listNav
.
find
(
'li'
).
removeClass
(
'bytouch'
);
});
$
(
'#goods-container'
).
on
(
'click'
,
'.good-info'
,
function
(
event
)
{
var
PRD_ID
=
$
(
this
).
data
(
'good-id'
),
PRD_NUM
=
$
(
this
).
index
()
+
1
,
FILTER_VALUE
=
JSON
.
stringify
(
qwert
).
replace
(
/
\{
|
\}
|
\"
/g
,
""
);
event
.
preventDefault
();
if
(
window
.
_yas
&&
window
.
_yas
.
sendCustomInfo
)
{
window
.
_yas
.
sendCustomInfo
({
op
:
'YB_KEYWORD_GOODS_LIST_C'
,
param
:
JSON
.
stringify
({
C_ID
:
C_ID
,
KEYWORD
:
qwert
.
query
||
''
,
PRD_ID
:
PRD_ID
,
PRD_NUM
:
PRD_NUM
,
PAGE_NUM
:
qwert
.
page
,
FILTER_VALUE
:
FILTER_VALUE
,
SORT_TYPE
:
qwert
.
type
})
},
true
);
}
return
false
;
})
...
...
Please
register
or
login
to post a comment