Authored by 毕凯

侧边栏数据格式化

@@ -42,7 +42,7 @@ exports.switchChannel = (req, res, next) => { @@ -42,7 +42,7 @@ 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: '1,3' 45 + gender: 'girl'
46 }).then(result => { 46 }).then(result => {
47 47
48 res.render('channel', Object.assign({ 48 res.render('channel', Object.assign({
@@ -11,6 +11,16 @@ const camelCase = require('../../../library/camel-case'); @@ -11,6 +11,16 @@ const camelCase = require('../../../library/camel-case');
11 11
12 const api = new API(); 12 const api = new API();
13 13
  14 +const genderData = {
  15 + boy: '1,3',
  16 + girl: '2,3'
  17 +};
  18 +
  19 +const contentCode = {
  20 + boy: '8512bf0755cc549ac323f852c9fd945d',
  21 + girl: '8512bf0755cc549ac323f852c9fd945d'
  22 +};
  23 +
14 const processFloor = (list) => { 24 const processFloor = (list) => {
15 const formatData = {}; 25 const formatData = {};
16 26
@@ -23,8 +33,12 @@ const processFloor = (list) => { @@ -23,8 +33,12 @@ const processFloor = (list) => {
23 return formatData; 33 return formatData;
24 }; 34 };
25 35
26 -const getSideTopColor = (guangChoosed) => {  
27 - // 判断逛的背景色 36 +/**
  37 + * 获取二级菜单顶部颜色
  38 + * @param {[string]} guangChoosed
  39 + * @return {[string]}
  40 + */
  41 +const getSidebarColor = (guangChoosed) => {
28 let color = false; 42 let color = false;
29 43
30 if (guangChoosed === 'girls') { 44 if (guangChoosed === 'girls') {
@@ -43,7 +57,7 @@ const getSideTopColor = (guangChoosed) => { @@ -43,7 +57,7 @@ const getSideTopColor = (guangChoosed) => {
43 * @param {[array]} list 57 * @param {[array]} list
44 * @return {[array]} 58 * @return {[array]}
45 */ 59 */
46 -const processSideBar = (list, guangChoosed) => { 60 +const processSideBar = (list, choosed) => {
47 const formatData = []; 61 const formatData = [];
48 let offset = 0; // 分割数组用到的游标 62 let offset = 0; // 分割数组用到的游标
49 63
@@ -56,7 +70,7 @@ const processSideBar = (list, guangChoosed) => { @@ -56,7 +70,7 @@ const processSideBar = (list, guangChoosed) => {
56 sortNameEn: item.sortNameEn, 70 sortNameEn: item.sortNameEn,
57 back: true, 71 back: true,
58 isSelect: false, 72 isSelect: false,
59 - bgColor: getSideTopColor(guangChoosed) 73 + bgColor: getSidebarColor(choosed)
60 }]; 74 }];
61 75
62 _.forEach(item.sub, (s) => { 76 _.forEach(item.sub, (s) => {
@@ -82,12 +96,12 @@ const processSideBar = (list, guangChoosed) => { @@ -82,12 +96,12 @@ const processSideBar = (list, guangChoosed) => {
82 * 获取频道页面资源位 96 * 获取频道页面资源位
83 */ 97 */
84 const getChannelResource = (gender) => { 98 const getChannelResource = (gender) => {
85 - gender = gender || '1,3'; 99 + gender = gender || 'boy';
86 100
87 return api.get('operations/api/v5/resource/home', sign.apiSign({ 101 return api.get('operations/api/v5/resource/home', sign.apiSign({
88 new_device: true, // eslint-disable-line 102 new_device: true, // eslint-disable-line
89 - gender: gender,  
90 - content_code: '8512bf0755cc549ac323f852c9fd945d', // eslint-disable-line 103 + gender: genderData[gender],
  104 + content_code: contentCode[gender], // eslint-disable-line
91 page: 1, 105 page: 1,
92 limit: 30 106 limit: 30
93 })).then(result => { 107 })).then(result => {
@@ -101,14 +115,14 @@ const getChannelResource = (gender) => { @@ -101,14 +115,14 @@ const getChannelResource = (gender) => {
101 }); 115 });
102 }; 116 };
103 117
104 -const getLeftNav = (guangChoosed) => {  
105 - guangChoosed = guangChoosed || 'all'; 118 +const getLeftNav = (choosed) => {
  119 + choosed = choosed || 'all';
106 120
107 return api.get('operations/api/v6/category/getCategory', sign.apiSign({})).then(result => { 121 return api.get('operations/api/v6/category/getCategory', sign.apiSign({})).then(result => {
108 result = JSON.parse(result); 122 result = JSON.parse(result);
109 123
110 if (result.code === 200) { 124 if (result.code === 200) {
111 - return processSideBar(result.data, guangChoosed); 125 + return processSideBar(result.data, choosed);
112 } else { 126 } else {
113 return result; 127 return result;
114 } 128 }
@@ -123,7 +137,7 @@ const getLeftNav = (guangChoosed) => { @@ -123,7 +137,7 @@ const getLeftNav = (guangChoosed) => {
123 exports.getChannelDate = (params) => { 137 exports.getChannelDate = (params) => {
124 var channelData = {}; 138 var channelData = {};
125 139
126 - return Promise.all([getChannelResource(params.gender), getLeftNav()]).then((data) => { 140 + return Promise.all([getChannelResource(params.gender), getLeftNav(params.gender)]).then((data) => {
127 channelData.content = data[0]; // 资源位数据 141 channelData.content = data[0]; // 资源位数据
128 channelData.sideNav = data[1]; // 侧边栏数据 142 channelData.sideNav = data[1]; // 侧边栏数据
129 143