...
|
...
|
@@ -9,7 +9,6 @@ const utils = '../../../utils'; |
|
|
const contentCodeConfig = require('../../../config/content-code');
|
|
|
const _ = require('lodash');
|
|
|
const ServiceAPI = require(`${library}/api`).ServiceAPI;
|
|
|
const sign = require(`${library}/sign`);
|
|
|
const camelCase = require(`${library}/camel-case`);
|
|
|
const logger = require(`${library}/logger`);
|
|
|
const resourcesProcess = require(`${utils}/resources-process`);
|
...
|
...
|
@@ -67,7 +66,7 @@ const channelList = [ |
|
|
* @param {[string]} choosed
|
|
|
* @return {[string]}
|
|
|
*/
|
|
|
const getSidebarColor = (choosed) => {
|
|
|
const _getSidebarColor = (choosed) => {
|
|
|
let color = false;
|
|
|
|
|
|
if (choosed === 'girls') {
|
...
|
...
|
@@ -86,7 +85,7 @@ const getSidebarColor = (choosed) => { |
|
|
* @param {[array]} list
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const processSideBar = (list, choosed) => {
|
|
|
const _processSideBar = (list, choosed) => {
|
|
|
const formatData = [];
|
|
|
let offset = 0; // 分割数组用到的游标
|
|
|
|
...
|
...
|
@@ -100,7 +99,7 @@ const processSideBar = (list, choosed) => { |
|
|
sortNameEn: item.sortNameEn,
|
|
|
back: true,
|
|
|
isSelect: false,
|
|
|
bgColor: getSidebarColor(choosed)
|
|
|
bgColor: _getSidebarColor(choosed)
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -121,7 +120,7 @@ const processSideBar = (list, choosed) => { |
|
|
* @param {[object]} gender
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
const getChannelResource = (params) => {
|
|
|
const _getChannelResource = (params) => {
|
|
|
params.gender = params.gender || 'boys';
|
|
|
|
|
|
params = Object.assign({
|
...
|
...
|
@@ -134,7 +133,7 @@ const getChannelResource = (params) => { |
|
|
params.new_device = true; // eslint-disable-line
|
|
|
}
|
|
|
|
|
|
return api.get('operations/api/v5/resource/home', sign.apiSign(params), true).then(result => {
|
|
|
return api.get('operations/api/v5/resource/home', params, true).then(result => {
|
|
|
if (result && result.code === 200) {
|
|
|
return resourcesProcess(result.data.list);
|
|
|
} else {
|
...
|
...
|
@@ -149,12 +148,12 @@ const getChannelResource = (params) => { |
|
|
* @param {[string]} choosed
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
const getLeftNav = (choosed) => {
|
|
|
const _getLeftNav = (choosed) => {
|
|
|
choosed = choosed || 'all';
|
|
|
|
|
|
return api.get('operations/api/v6/category/getCategory', sign.apiSign({}), true).then(result => {
|
|
|
return api.get('operations/api/v6/category/getCategory', {}, true).then(result => {
|
|
|
if (result && result.code === 200) {
|
|
|
return processSideBar(result.data, choosed);
|
|
|
return _processSideBar(result.data, choosed);
|
|
|
} else {
|
|
|
logger.error('侧边栏数据接口返回状态码 不是 200');
|
|
|
return result;
|
...
|
...
|
@@ -166,8 +165,8 @@ const getLeftNav = (choosed) => { |
|
|
* 获取频道选择页数据
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
const getChannelList = () => {
|
|
|
return api.get('operations/api/v5/entrance/getEntrance', sign.apiSign({}), true).then((result) => {
|
|
|
const _getChannelList = () => {
|
|
|
return api.get('operations/api/v5/entrance/getEntrance', {}, true).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
const list = {};
|
|
|
|
...
|
...
|
@@ -199,10 +198,10 @@ const getChannelList = () => { |
|
|
* 获取频道选择页 背景
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
const getChannelBg = () => {
|
|
|
return api.get('operations/api/v5/resource/get', sign.apiSign({
|
|
|
const _getChannelBg = () => {
|
|
|
return api.get('operations/api/v5/resource/get', {
|
|
|
content_code: contentCode.index
|
|
|
}), true).then(result => {
|
|
|
}, true).then(result => {
|
|
|
if (result && result.code === 200) {
|
|
|
return result.data.length && result.data[0] && result.data[0].data && result.data[0].data.list[0];
|
|
|
} else {
|
...
|
...
|
@@ -219,8 +218,8 @@ const getChannelBg = () => { |
|
|
* @param {[string]} gender
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.getChannelSwitchData = () => {
|
|
|
return Promise.all([getChannelList(), getChannelBg()]);
|
|
|
let getChannelSwitchData = () => {
|
|
|
return Promise.all([_getChannelList(), _getChannelBg()]);
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -228,10 +227,10 @@ exports.getChannelSwitchData = () => { |
|
|
* @param {[object]} params
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
exports.getChannelData = (params) => {
|
|
|
let getChannelData = (params) => {
|
|
|
var channelData = {};
|
|
|
|
|
|
return Promise.all([getChannelResource(params), getLeftNav(params.gender)]).then((data) => {
|
|
|
return Promise.all([_getChannelResource(params), _getLeftNav(params.gender)]).then((data) => {
|
|
|
channelData.content = data[0]; // 资源位数据
|
|
|
channelData.sideNav = data[1]; // 侧边栏数据
|
|
|
|
...
|
...
|
@@ -244,13 +243,13 @@ exports.getChannelData = (params) => { |
|
|
* @param {[string]} gender
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.getBottomBannerData = (gender) => {
|
|
|
let getBottomBannerData = (gender) => {
|
|
|
gender = gender || 'boys';
|
|
|
|
|
|
if (gender === 'boys' || gender === 'girls') {
|
|
|
return api.get('operations/api/v5/resource/get', sign.apiSign({
|
|
|
return api.get('operations/api/v5/resource/get', {
|
|
|
content_code: bottomBannerCode[gender] // eslint-disable-line
|
|
|
}), true);
|
|
|
}, true);
|
|
|
}
|
|
|
return Promise.resolve({
|
|
|
code: 400,
|
...
|
...
|
@@ -258,3 +257,9 @@ exports.getBottomBannerData = (gender) => { |
|
|
message: '参数错误'
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getChannelData,
|
|
|
getChannelSwitchData,
|
|
|
getBottomBannerData
|
|
|
}; |
...
|
...
|
|