Authored by ccbikai

增加另外三个频道页面

... ... @@ -7,6 +7,8 @@
const _ = require('lodash');
const channelModel = require('../models/channel');
const helpers = require('../../../library/helpers');
const log = require('../../../library/logger');
const cookie = require('../../../library/cookie');
const mod = 'channel';
let footerTab = {
... ... @@ -17,6 +19,10 @@ let footerTab = {
mineUrl: helpers.url('/home') // 个人中心
};
const channelLogger = (err) => {
log.error(err);
};
/**
* 频道选择
* @param {object} req
... ... @@ -43,7 +49,7 @@ exports.switchChannel = (req, res, next) => {
exports.boys = (req, res) => {
channelModel.getChannelDate({
gender: 'boys',
uid: 123
uid: cookie.getUid(req)
}).then(result => {
res.render('channel', Object.assign({
module: mod,
... ... @@ -57,7 +63,67 @@ exports.boys = (req, res) => {
showFooterTab: footerTab,
pageFooter: true
}, result));
}).catch(console.trace);
}).catch(channelLogger);
};
exports.girls = (req, res) => {
channelModel.getChannelDate({
gender: 'girls',
uid: cookie.getUid(req)
}).then(result => {
res.render('channel', Object.assign({
module: mod,
page: 'home',
title: '女生首页',
girlsHomePage: true,
homeHeader: {
searchUrl: helpers.url('/search', null, 'search')
},
maybeLike: true,
showFooterTab: footerTab,
pageFooter: true
}, result));
}).catch(channelLogger);
};
exports.kids = (req, res) => {
channelModel.getChannelDate({
gender: 'kids',
uid: cookie.getUid(req)
}).then(result => {
res.render('channel', Object.assign({
module: mod,
page: 'home',
title: '潮童首页',
kidsHomePage: true,
homeHeader: {
searchUrl: helpers.url('/search', null, 'search')
},
maybeLike: true,
showFooterTab: footerTab,
pageFooter: true
}, result));
}).catch(channelLogger);
};
exports.lifestyle = (req, res) => {
channelModel.getChannelDate({
gender: 'lifestyle',
uid: cookie.getUid(req)
}).then(result => {
res.render('channel', Object.assign({
module: mod,
page: 'home',
title: '创意生活首页',
lifestyleHomePage: true,
homeHeader: {
searchUrl: helpers.url('/search', null, 'search')
},
maybeLike: true,
showFooterTab: footerTab,
pageFooter: true
}, result));
}).catch(channelLogger);
};
exports.bottomBanner = (req, res) => {
... ...
... ... @@ -5,7 +5,7 @@
*/
'use strict';
const _ = require('lodash');
const API = require('../../../library/api').API;
const API = require('../../../library/api').ServiceAPI;
const sign = require('../../../library/sign');
const camelCase = require('../../../library/camel-case');
... ... @@ -128,7 +128,7 @@ const getChannelResource = (params) => {
}
return api.get('operations/api/v5/resource/home', sign.apiSign(params)).then(result => {
if (result.code === 200) {
if (result && result.code === 200) {
return processFloor(result.data.list);
} else {
return result;
... ... @@ -145,7 +145,7 @@ const getLeftNav = (choosed) => {
choosed = choosed || 'all';
return api.get('operations/api/v6/category/getCategory', sign.apiSign({})).then(result => {
if (result.code === 200) {
if (result && result.code === 200) {
return processSideBar(result.data, choosed);
} else {
return result;
... ...
... ... @@ -13,10 +13,10 @@ const channel = require(cRoot);
const router = express.Router(); // eslint-disable-line
router.get('/boys', channel.switchChannel, channel.boys);
router.get('/girls', channel.switchChannel, channel.girls);
router.get('/kids', channel.switchChannel, channel.kids);
router.get('/lifestyle', channel.switchChannel, channel.lifestyle);
// router.get('/girls', channel.switchChannel, channel.girls);
// router.get('/kids', channel.switchChannel, channel.kids);
// router.get('/lifestyle', channel.switchChannel, channel.lifestyle);
router.get('/channel/bottomBanner', channel.bottomBanner);
module.exports = router;
... ...
... ... @@ -6,7 +6,7 @@
*/
module.exports = {
siteUrl: 'http://www.yohobuy.com',
siteUrl: 'http://m.yohobuy.com',
domains: {
api: 'http://testapi.yoho.cn:28078/',
service: 'http://testservice.yoho.cn:28077/'
... ...
... ... @@ -36,7 +36,7 @@
{{> footer}}
{{#if devEnv}}
<script src="//localhost:5001{{module}}.{{page}}.js"></script>
<script src="//localhost:5001/{{module}}.{{page}}.js"></script>
{{^}}
<script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script>
{{/if}}
... ...
... ... @@ -60,7 +60,8 @@ class API {
_.forEach(urls, function(el) {
rps.push(rp({
url: `${ApiUrl}${el.url}`,
qs: el.data
qs: el.data,
json: true
}));
});
... ... @@ -78,7 +79,8 @@ class API {
return rp({
url: `${ApiUrl}${url}`,
method: 'post',
form: data
form: data,
json: true
});
}
}
... ...
/**
* 获取 UID
* @param {[object]} req
* @return {[string]}
*/
exports.getUid = (req) => {
var _uid = 0,
cookie = req.cookies._UID,
cookieList;
if (req.isApp) {
return req.query.uid || 0;
}
if (cookie) {
cookieList = cookie.split('::');
if (cookieList[1] && !isNaN(cookieList[1])) {
_uid = cookieList[1];
}
}
return _uid;
};
... ...
... ... @@ -193,7 +193,7 @@ gulp.task('webpack-dev-server', () => {
new WebpackDevServer(webpack(devConfig), {
contentBase: '.',
publicPath: '//localhost:5001',
publicPath: '//localhost:5001/',
hot: true,
stats: {
colors: true
... ...