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) => { @@ -42,9 +42,9 @@ exports.switchChannel = (req, res, next) => {
42 */ 42 */
43 exports.boys = (req, res) => { 43 exports.boys = (req, res) => {
44 channelModel.getChannelDate({ 44 channelModel.getChannelDate({
45 - gender: 'girl' 45 + gender: 'boys',
  46 + uid: 123
46 }).then(result => { 47 }).then(result => {
47 -  
48 res.render('channel', Object.assign({ 48 res.render('channel', Object.assign({
49 module: mod, 49 module: mod,
50 page: 'home', 50 page: 'home',
@@ -59,3 +59,11 @@ exports.boys = (req, res) => { @@ -59,3 +59,11 @@ exports.boys = (req, res) => {
59 }, result)); 59 }, result));
60 }).catch(console.trace); 60 }).catch(console.trace);
61 }; 61 };
  62 +
  63 +exports.bottomBanner = (req, res) => {
  64 + let gender = req.query.gender || 'boys';
  65 +
  66 + channelModel.getBottomBannerDate(gender).then(result => {
  67 + res.send(result);
  68 + }).catch(console.trace);
  69 +};
@@ -12,13 +12,28 @@ const camelCase = require('../../../library/camel-case'); @@ -12,13 +12,28 @@ const camelCase = require('../../../library/camel-case');
12 const api = new API(); 12 const api = new API();
13 13
14 const genderData = { 14 const genderData = {
15 - boy: '1,3',  
16 - girl: '2,3' 15 + boys: '1,3',
  16 + girls: '2,3'
17 }; 17 };
18 18
  19 +/**
  20 + * 楼层资源的位置码
  21 + * @type {Object}
  22 + */
19 const contentCode = { 23 const contentCode = {
20 - boy: '8512bf0755cc549ac323f852c9fd945d',  
21 - girl: '8512bf0755cc549ac323f852c9fd945d' 24 + boys: '8512bf0755cc549ac323f852c9fd945d',
  25 + girls: '189b6686065dbd6755dd6906cf03c002',
  26 + kids: 'b8c1bff53d4ea60f978926d538620636',
  27 + lifestyle: '61cd852c6afcf60660196154f66a3a62'
  28 +};
  29 +
  30 +/**
  31 + * 频道底部 Banner位置码
  32 + * @type {Object}
  33 + */
  34 +const bottomBannerCode = {
  35 + boys: 'a2ec977c027d0cd9cdccb356ddf16b08',
  36 + girls: '8c8bd1b89a22e5895f05882e0825b493'
22 }; 37 };
23 38
24 /** 39 /**
@@ -99,18 +114,20 @@ const processFloor = (list) => { @@ -99,18 +114,20 @@ const processFloor = (list) => {
99 * @param {[object]} gender 114 * @param {[object]} gender
100 * @return {[type]} 115 * @return {[type]}
101 */ 116 */
102 -const getChannelResource = (gender) => {  
103 - gender = gender || 'boy'; 117 +const getChannelResource = (params) => {
  118 + params.gender = params.gender || 'boys';
104 119
105 - return api.get('operations/api/v5/resource/home', sign.apiSign({  
106 - new_device: true, // eslint-disable-line  
107 - gender: genderData[gender],  
108 - content_code: contentCode[gender], // eslint-disable-line 120 + params = Object.assign({
  121 + gender: genderData[params.gender],
  122 + content_code: contentCode[params.gender], // eslint-disable-line
109 page: 1, 123 page: 1,
110 limit: 30 124 limit: 30
111 - })).then(result => {  
112 - result = JSON.parse(result); 125 + }, params);
  126 + if (!params.uid) {
  127 + params.new_device = true; // eslint-disable-line
  128 + }
113 129
  130 + return api.get('operations/api/v5/resource/home', sign.apiSign(params)).then(result => {
114 if (result.code === 200) { 131 if (result.code === 200) {
115 return processFloor(result.data.list); 132 return processFloor(result.data.list);
116 } else { 133 } else {
@@ -128,8 +145,6 @@ const getLeftNav = (choosed) => { @@ -128,8 +145,6 @@ const getLeftNav = (choosed) => {
128 choosed = choosed || 'all'; 145 choosed = choosed || 'all';
129 146
130 return api.get('operations/api/v6/category/getCategory', sign.apiSign({})).then(result => { 147 return api.get('operations/api/v6/category/getCategory', sign.apiSign({})).then(result => {
131 - result = JSON.parse(result);  
132 -  
133 if (result.code === 200) { 148 if (result.code === 200) {
134 return processSideBar(result.data, choosed); 149 return processSideBar(result.data, choosed);
135 } else { 150 } else {
@@ -146,10 +161,25 @@ const getLeftNav = (choosed) => { @@ -146,10 +161,25 @@ const getLeftNav = (choosed) => {
146 exports.getChannelDate = (params) => { 161 exports.getChannelDate = (params) => {
147 var channelData = {}; 162 var channelData = {};
148 163
149 - return Promise.all([getChannelResource(params.gender), getLeftNav(params.gender)]).then((data) => { 164 + return Promise.all([getChannelResource(params), getLeftNav(params.gender)]).then((data) => {
150 channelData.content = data[0]; // 资源位数据 165 channelData.content = data[0]; // 资源位数据
151 channelData.sideNav = data[1]; // 侧边栏数据 166 channelData.sideNav = data[1]; // 侧边栏数据
152 167
153 return channelData; 168 return channelData;
154 }); 169 });
155 }; 170 };
  171 +
  172 +exports.getBottomBannerDate = (gender) => {
  173 + gender = gender || 'boys';
  174 +
  175 + if (gender === 'boys' || gender === 'girls') {
  176 + return api.get('operations/api/v5/resource/get', sign.apiSign({
  177 + content_code: bottomBannerCode[gender] // eslint-disable-line
  178 + }));
  179 + }
  180 + return Promise.resolve({
  181 + code: 400,
  182 + data: '',
  183 + message: '参数错误'
  184 + });
  185 +};
@@ -17,5 +17,6 @@ router.get('/boys', channel.switchChannel, channel.boys); @@ -17,5 +17,6 @@ router.get('/boys', channel.switchChannel, channel.boys);
17 // router.get('/girls', channel.switchChannel, channel.girls); 17 // router.get('/girls', channel.switchChannel, channel.girls);
18 // router.get('/kids', channel.switchChannel, channel.kids); 18 // router.get('/kids', channel.switchChannel, channel.kids);
19 // router.get('/lifestyle', channel.switchChannel, channel.lifestyle); 19 // router.get('/lifestyle', channel.switchChannel, channel.lifestyle);
  20 +router.get('/channel/bottomBanner', channel.bottomBanner);
20 21
21 module.exports = router; 22 module.exports = router;
@@ -26,7 +26,8 @@ class API { @@ -26,7 +26,8 @@ class API {
26 26
27 let options = { 27 let options = {
28 url: `${ApiUrl}${url}`, 28 url: `${ApiUrl}${url}`,
29 - qs: data 29 + qs: data,
  30 + json: true
30 }; 31 };
31 32
32 let timer = new Timer(); 33 let timer = new Timer();
@@ -36,7 +37,7 @@ class API { @@ -36,7 +37,7 @@ class API {
36 37
37 ret.then((body)=>{ 38 ret.then((body)=>{
38 let duration = timer.put('getApi');// 接口返回 39 let duration = timer.put('getApi');// 接口返回
39 - log.info('API GET: %s, parms: %j , durationMs: %d ms , body: %s', options.url, options.qs, duration, body); 40 + // log.info('API GET: %s, parms: %j , durationMs: %d ms , body: %s', options.url, options.qs, duration, body);
40 }).catch((error)=>{ 41 }).catch((error)=>{
41 let duration = timer.put('getApi');// 接口返回 42 let duration = timer.put('getApi');// 接口返回
42 log.error('API GET: %s, parms: %j , durationMs: %d ms error: %s , statusCode: %d', options.url, options.qs, duration, error.message, error.statusCode); 43 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) { @@ -40,7 +40,7 @@ module.exports = function(specificGender) {
40 url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3' : '/product/recom/maylikelife'; 40 url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3' : '/product/recom/maylikelife';
41 } else { 41 } else {
42 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? 42 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
43 - '1,3' : '2,3'; 43 + 'boys' : 'girls';
44 url = '/product/recom/maylike?gender=' + gender; 44 url = '/product/recom/maylike?gender=' + gender;
45 } 45 }
46 46
@@ -101,14 +101,13 @@ module.exports = function(specificGender) { @@ -101,14 +101,13 @@ module.exports = function(specificGender) {
101 101
102 // 有货币页面不加载底部 102 // 有货币页面不加载底部
103 if (gender && !specificGender) { 103 if (gender && !specificGender) {
104 - if (gender === '1,3') {  
105 - url = '/boys/bottomBanner';  
106 - } else {  
107 - url = '/girls/bottomBanner';  
108 - } 104 + url = '/channel/bottomBanner';
109 $.ajax({ 105 $.ajax({
110 type: 'GET', 106 type: 'GET',
111 url: url, 107 url: url,
  108 + data: {
  109 + gender: gender
  110 + },
112 success: function(res) { 111 success: function(res) {
113 if (res && res.img) { 112 if (res && res.img) {
114 $('#load-more-img').show(); 113 $('#load-more-img').show();
1 .footer-tab { 1 .footer-tab {
2 position: fixed; 2 position: fixed;
3 - left: 0; 3 + left: 50%;
4 bottom: 0; 4 bottom: 0;
  5 + margin-left: -320px;
5 width: 100%; 6 width: 100%;
6 height: 100px; 7 height: 100px;
  8 + max-width: 640px;
7 padding-top: 20px; 9 padding-top: 20px;
8 box-sizing: border-box; 10 box-sizing: border-box;
9 background: #fff; 11 background: #fff;
@@ -23,7 +23,10 @@ @@ -23,7 +23,10 @@
23 @import "coupon"; 23 @import "coupon";
24 24
25 .mobile-container { 25 .mobile-container {
  26 + margin-left: auto;
  27 + margin-right: auto;
26 width: 100%; 28 width: 100%;
  29 + max-width: 640px;
27 overflow: hidden; 30 overflow: hidden;
28 } 31 }
29 32
@@ -6,8 +6,11 @@ @@ -6,8 +6,11 @@
6 clear: fix; 6 clear: fix;
7 } 7 }
8 8
9 -* { 9 +*,
  10 +*:before,
  11 +*:after {
10 -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 12 -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  13 + box-sizing: border-box;
11 } 14 }
12 15
13 html, 16 html,