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
biao
9 years ago
Commit
cce513c7a5938b5de50cfc903daaa85ba9610331
1 parent
d41732cc
update for header model
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
74 deletions
.gitignore
apps/index/controllers/index.js
apps/index/router.js
doraemon/models/HeaderModel.js
.gitignore
View file @
cce513c
...
...
@@ -2,4 +2,6 @@ node_modules/
dist/
npm-debug.log
public/css/*
public/bundle/*
\ No newline at end of file
public/bundle/*
*.swp
...
...
apps/index/controllers/index.js
0 → 100644
View file @
cce513c
var
headerModel
=
require
(
'../../../doraemon/models/HeaderModel'
);
function
getHeaderData
(
cb
)
{
headerModel
.
getHeaderData
(
function
(
err
,
data
)
{
if
(
err
)
{
cb
(
err
);
return
;
}
cb
(
null
,
data
);
});
}
exports
.
getHeaderData
=
getHeaderData
;
...
...
apps/index/router.js
View file @
cce513c
...
...
@@ -8,82 +8,12 @@
const
router
=
require
(
'express'
).
Router
();
const
cRoot
=
'./controllers'
;
const
homeDataController
=
require
(
cRoot
);
// Your controller here
router
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
render
(
'index'
,
{
title
:
'home'
,
devEnv
:
true
,
version
:
'0.0.1'
,
headerData
:
{
header
:
true
,
type
:
'boy'
,
yohoGroup
:
[
{
link
:
'http://www.yoho.cn'
,
cn
:
'集团官网'
,
en
:
'YOHO!'
},
{
link
:
'http://www.yohoboys.com'
,
cn
:
'男生潮流'
,
en
:
'YOHO!BOYS'
},
{
link
:
'http://www.yohogirls.com'
,
cn
:
'女生潮流'
,
en
:
'YOHO!GIRLS'
},
{
link
:
'http://www.yohoshow.com'
,
cn
:
'物趣分享'
,
en
:
'YOHO!SHOW'
},
{
link
:
'http://www.yohood.cn'
,
cn
:
'潮流嘉年华'
,
en
:
'YO\'HOOD'
}
],
navbars
:
[
{
active
:
true
,
link
:
'http://www.yohobuy.com/'
,
cn
:
'男生'
,
en
:
'BOYS'
},
{
link
:
'http://new.yohobuy.com/woman'
,
cn
:
'女生'
,
en
:
'GIRLS'
}
],
subNav
:
[
{
link
:
'#'
,
name
:
'新品到着'
},
{
link
:
'#'
,
name
:
'品牌一览'
},
{
link
:
'#'
,
name
:
'服饰'
,
thirdNav
:
[]
},
{
link
:
'#'
,
name
:
'鞋履'
,
thirdNav
:
[]
},
{
link
:
'#'
,
name
:
'逛'
,
isNew
:
true
},
]
}
homeDataController
.
getHeaderData
(
function
(
err
,
data
)
{
res
.
render
(
'index'
,
data
);
});
});
module
.
exports
=
router
;
...
...
doraemon/models/HeaderModel.js
0 → 100644
View file @
cce513c
var
rp
=
require
(
'request-promise'
);
var
_
=
require
(
'lodash'
);
function
getConfig
()
{
return
{
title
:
'home'
,
devEnv
:
true
,
version
:
'0.0.1'
}
}
function
getMenuData
()
{
return
[
{
link
:
'http://www.yoho.cn'
,
cn
:
'集团官网'
,
en
:
'YOHO!'
},
{
link
:
'http://www.yohoboys.com'
,
cn
:
'男生潮流'
,
en
:
'YOHO!BOYS'
},
{
link
:
'http://www.yohogirls.com'
,
cn
:
'女生潮流'
,
en
:
'YOHO!GIRLS'
},
{
link
:
'http://www.yohoshow.com'
,
cn
:
'物趣分享'
,
en
:
'YOHO!SHOW'
},
{
link
:
'http://www.yohood.cn'
,
cn
:
'潮流嘉年华'
,
en
:
'YO\'HOOD'
}
];
}
function
getNavBar
(
data
)
{
var
navBars
=
[];
_
.
forEach
(
data
,
function
(
item
)
{
var
obj
=
{};
obj
.
link
=
item
.
sort_url
;
obj
.
cn
=
item
.
sort_name
;
obj
.
en
=
item
.
sort_name_en
;
navBars
.
push
(
obj
);
});
return
navBars
;
}
function
getSubNav
(
data
)
{
var
subNav
=
[];
_
.
forEach
(
data
,
function
(
item
)
{
var
obj
=
{};
obj
.
link
=
item
.
sort_url
;
obj
.
name
=
item
.
sort_name
;
obj
.
isHot
=
item
.
is_hot
===
'Y'
?
true
:
false
;
obj
.
isNew
=
item
.
is_new
===
'Y'
?
true
:
false
;
subNav
.
push
(
obj
);
});
return
subNav
;
}
function
getAllHeaderData
(
resData
)
{
var
config
=
getConfig
();
var
data
=
{
headerData
:
{
header
:
true
,
type
:
'boy'
,
yohoGroup
:
getMenuData
(),
navbars
:
getNavBar
(
resData
),
subNav
:
getSubNav
(
resData
)
}
};
return
_
.
merge
(
config
,
data
);
}
exports
.
getHeaderData
=
function
(
done
)
{
var
opt
=
{
uri
:
'http://testservice.yoho.cn:28077/operations/api/v6/category/getCategory'
,
qs
:
{
app_version
:
'3.8.2'
,
client_type
:
'web'
,
os_version
:
'yohobuy:h5'
,
screen_size
:
'720x1280'
,
v
:
'7'
,
client_secret
:
'f47f9d46f09d930496dee2a9082ff041'
},
headers
:
{
'content-type'
:
'application/json;charset=UTF-8'
}
};
rp
(
opt
)
.
then
(
function
(
res
)
{
var
response
=
JSON
.
parse
(
res
);
var
data
=
getAllHeaderData
(
response
.
data
);
done
(
null
,
data
);
})
.
catch
(
function
(
err
)
{
done
(
err
);
});
}
...
...
Please
register
or
login
to post a comment