Authored by 王水玲

Merge branch 'feature/channel' of http://git.dev.yoho.cn/web/yohobuy-node into feature/channel

... ... @@ -42,9 +42,9 @@ exports.switchChannel = (req, res, next) => {
*/
exports.boys = (req, res) => {
channelModel.getChannelDate({
gender: 'girl'
gender: 'boys',
uid: 123
}).then(result => {
res.render('channel', Object.assign({
module: mod,
page: 'home',
... ... @@ -59,3 +59,11 @@ exports.boys = (req, res) => {
}, result));
}).catch(console.trace);
};
exports.bottomBanner = (req, res) => {
let gender = req.query.gender || 'boys';
channelModel.getBottomBannerDate(gender).then(result => {
res.send(result);
}).catch(console.trace);
};
... ...
... ... @@ -12,13 +12,28 @@ const camelCase = require('../../../library/camel-case');
const api = new API();
const genderData = {
boy: '1,3',
girl: '2,3'
boys: '1,3',
girls: '2,3'
};
/**
* 楼层资源的位置码
* @type {Object}
*/
const contentCode = {
boy: '8512bf0755cc549ac323f852c9fd945d',
girl: '8512bf0755cc549ac323f852c9fd945d'
boys: '8512bf0755cc549ac323f852c9fd945d',
girls: '189b6686065dbd6755dd6906cf03c002',
kids: 'b8c1bff53d4ea60f978926d538620636',
lifestyle: '61cd852c6afcf60660196154f66a3a62'
};
/**
* 频道底部 Banner位置码
* @type {Object}
*/
const bottomBannerCode = {
boys: 'a2ec977c027d0cd9cdccb356ddf16b08',
girls: '8c8bd1b89a22e5895f05882e0825b493'
};
/**
... ... @@ -99,18 +114,20 @@ const processFloor = (list) => {
* @param {[object]} gender
* @return {[type]}
*/
const getChannelResource = (gender) => {
gender = gender || 'boy';
const getChannelResource = (params) => {
params.gender = params.gender || 'boys';
return api.get('operations/api/v5/resource/home', sign.apiSign({
new_device: true, // eslint-disable-line
gender: genderData[gender],
content_code: contentCode[gender], // eslint-disable-line
params = Object.assign({
gender: genderData[params.gender],
content_code: contentCode[params.gender], // eslint-disable-line
page: 1,
limit: 30
})).then(result => {
result = JSON.parse(result);
}, params);
if (!params.uid) {
params.new_device = true; // eslint-disable-line
}
return api.get('operations/api/v5/resource/home', sign.apiSign(params)).then(result => {
if (result.code === 200) {
return processFloor(result.data.list);
} else {
... ... @@ -128,8 +145,6 @@ const getLeftNav = (choosed) => {
choosed = choosed || 'all';
return api.get('operations/api/v6/category/getCategory', sign.apiSign({})).then(result => {
result = JSON.parse(result);
if (result.code === 200) {
return processSideBar(result.data, choosed);
} else {
... ... @@ -146,10 +161,25 @@ const getLeftNav = (choosed) => {
exports.getChannelDate = (params) => {
var channelData = {};
return Promise.all([getChannelResource(params.gender), getLeftNav(params.gender)]).then((data) => {
return Promise.all([getChannelResource(params), getLeftNav(params.gender)]).then((data) => {
channelData.content = data[0]; // 资源位数据
channelData.sideNav = data[1]; // 侧边栏数据
return channelData;
});
};
exports.getBottomBannerDate = (gender) => {
gender = gender || 'boys';
if (gender === 'boys' || gender === 'girls') {
return api.get('operations/api/v5/resource/get', sign.apiSign({
content_code: bottomBannerCode[gender] // eslint-disable-line
}));
}
return Promise.resolve({
code: 400,
data: '',
message: '参数错误'
});
};
... ...
... ... @@ -17,5 +17,6 @@ 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('/channel/bottomBanner', channel.bottomBanner);
module.exports = router;
... ...
... ... @@ -26,7 +26,8 @@ class API {
let options = {
url: `${ApiUrl}${url}`,
qs: data
qs: data,
json: true
};
let timer = new Timer();
... ... @@ -36,7 +37,7 @@ class API {
ret.then((body)=>{
let duration = timer.put('getApi');// 接口返回
log.info('API GET: %s, parms: %j , durationMs: %d ms , body: %s', options.url, options.qs, duration, body);
// log.info('API GET: %s, parms: %j , durationMs: %d ms , body: %s', options.url, options.qs, duration, body);
}).catch((error)=>{
let duration = timer.put('getApi');// 接口返回
log.error('API GET: %s, parms: %j , durationMs: %d ms error: %s , statusCode: %d', options.url, options.qs, duration, error.message, error.statusCode);
... ...
... ... @@ -40,7 +40,7 @@ module.exports = function(specificGender) {
url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3' : '/product/recom/maylikelife';
} else {
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
'1,3' : '2,3';
'boys' : 'girls';
url = '/product/recom/maylike?gender=' + gender;
}
... ... @@ -101,14 +101,13 @@ module.exports = function(specificGender) {
// 有货币页面不加载底部
if (gender && !specificGender) {
if (gender === '1,3') {
url = '/boys/bottomBanner';
} else {
url = '/girls/bottomBanner';
}
url = '/channel/bottomBanner';
$.ajax({
type: 'GET',
url: url,
data: {
gender: gender
},
success: function(res) {
if (res && res.img) {
$('#load-more-img').show();
... ...
.footer-tab {
position: fixed;
left: 0;
left: 50%;
bottom: 0;
margin-left: -320px;
width: 100%;
height: 100px;
max-width: 640px;
padding-top: 20px;
box-sizing: border-box;
background: #fff;
... ...
... ... @@ -23,7 +23,10 @@
@import "coupon";
.mobile-container {
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 640px;
overflow: hidden;
}
... ...
... ... @@ -6,8 +6,11 @@
clear: fix;
}
* {
*,
*:before,
*:after {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
box-sizing: border-box;
}
html,
... ...