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
htoooth
8 years ago
Commit
8ee6f71a5e1d6932460072fd29bcf731f0f07c5e
1 parent
f875f8c4
add udid
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
26 deletions
apps/home/controllers/Favorite.js
apps/home/controllers/Index.js
apps/home/router.js
doraemon/middleware/set-yoho-data.js
apps/home/controllers/Favorite.js
View file @
8ee6f71
...
...
@@ -17,24 +17,9 @@ const TABS = {
article
:
'article'
};
const
udidRequired
=
(
req
,
res
,
next
)
=>
{
let
udid
=
req
.
cookies
.
udid
;
if
(
!
udid
)
{
udid
=
md5
(
req
.
ip
||
requestIp
.
getClientIp
(
req
));
if
(
res
&&
res
.
cookie
)
{
res
.
cookie
(
'udid'
,
udid
);
}
req
.
user
.
udid
=
udid
;
}
next
();
};
const
index
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
udid
=
req
.
user
.
udid
;
let
udid
=
req
.
yoho
.
udid
;
let
page
=
+
req
.
query
.
page
||
1
;
let
type
=
req
.
query
.
type
||
TABS
.
product
;
let
selectedSort
=
+
req
.
query
.
sort_id
||
0
;
...
...
@@ -145,8 +130,5 @@ module.exports = {
notice
,
cancelNotice
,
cancel
,
udidRequired
cancel
};
...
...
apps/home/controllers/Index.js
View file @
8ee6f71
...
...
@@ -41,6 +41,8 @@ const index = (req, res, next)=>{
helpUsUrl
:
''
});
})().
catch
(
next
);
let
uid
=
req
.
user
.
uid
;
};
module
.
exports
=
{
...
...
apps/home/router.js
View file @
8ee6f71
...
...
@@ -240,17 +240,13 @@ router.get('/message/pickCoupon', messageController.pickCoupon);
/********************************* 我的收藏开始 *****************************************/
// 我的收藏
router
.
get
(
'/favorite'
,
[
getCommonHeader
,
getHomeNav
],
favoriteController
.
udidRequired
,
favoriteController
.
index
);
router
.
get
(
'/favorite'
,
[
getCommonHeader
,
getHomeNav
],
favoriteController
.
index
);
// 品牌页新品到着
router
.
get
(
'/favorite/newproduct'
,
favoriteController
.
newProduct
);
// 降价提醒
router
.
get
(
'/favorite/reduction'
,
[
getCommonHeader
,
getHomeNav
],
favoriteController
.
reduction
);
router
.
get
(
'/favorite/reduction'
,
[
getCommonHeader
,
getHomeNav
],
favoriteController
.
reduction
);
// 设置降价提醒
router
.
get
(
'/favorite/notice'
,
favoriteController
.
notice
);
...
...
doraemon/middleware/set-yoho-data.js
View file @
8ee6f71
...
...
@@ -6,6 +6,9 @@
'use strict'
;
const
requestIp
=
require
(
'request-ip'
);
const
md5
=
require
(
'md5'
);
const
_getGender
=
(
channel
)
=>
{
switch
(
channel
)
{
case
'boys'
:
...
...
@@ -17,6 +20,21 @@ const _getGender = (channel) => {
}
};
const
udidRequired
=
(
req
,
res
,
next
)
=>
{
let
udid
=
req
.
cookies
.
udid
;
if
(
!
udid
)
{
udid
=
md5
(
req
.
ip
||
requestIp
.
getClientIp
(
req
));
if
(
res
&&
res
.
cookie
)
{
res
.
cookie
(
'udid'
,
udid
);
}
req
.
user
.
udid
=
udid
;
}
next
();
};
module
.
exports
=
()
=>
{
return
(
req
,
res
,
next
)
=>
{
let
yoho
=
{
...
...
@@ -35,6 +53,21 @@ module.exports = () => {
yoho
.
isApp
=
req
.
query
.
app_version
||
req
.
query
.
appVersion
;
// uuid
yoho
.
udid
=
(
function
()
{
let
udid
=
req
.
cookies
.
udid
;
if
(
!
udid
)
{
udid
=
md5
(
req
.
ip
||
requestIp
.
getClientIp
(
req
));
if
(
res
&&
res
.
cookie
)
{
res
.
cookie
(
'udid'
,
udid
);
}
}
return
udid
;
}());
Object
.
assign
(
res
.
locals
,
yoho
);
Object
.
assign
(
req
.
yoho
,
yoho
);
next
();
...
...
Please
register
or
login
to post a comment