|
|
var rp = require('request-promise');
|
|
|
var _ = require('lodash');
|
|
|
/**
|
|
|
* header model
|
|
|
* @author: 赵彪<bill.zhao@yoho.cn>
|
|
|
* @date: 2016/05/03
|
|
|
*/
|
|
|
|
|
|
// var API = require('../../library/api');
|
|
|
'use strict';
|
|
|
|
|
|
const _ = require('lodash');
|
|
|
const lRoot = '../../library/';
|
|
|
|
|
|
function getConfig() {
|
|
|
return {
|
|
|
const API = require(`${lRoot}/api`);
|
|
|
const sign = require(`${lRoot}/sign`);
|
|
|
|
|
|
const api = new API('http://testservice.yoho.cn:28077');
|
|
|
|
|
|
const getConfig = () => ({
|
|
|
title: 'home',
|
|
|
devEnv: true,
|
|
|
version: '0.0.1'
|
|
|
};
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function getMenuData() {
|
|
|
return [
|
|
|
|
|
|
const getMenuData = () => (
|
|
|
[
|
|
|
{
|
|
|
link: 'http://www.yoho.cn',
|
|
|
cn: '集团官网',
|
...
|
...
|
@@ -39,16 +48,16 @@ function getMenuData() { |
|
|
cn: '潮流嘉年华',
|
|
|
en: 'YO\'HOOD'
|
|
|
}
|
|
|
];
|
|
|
}
|
|
|
]
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
function getNavBar(data) {
|
|
|
var navBars = [];
|
|
|
const getNavBar = (data) => {
|
|
|
let navBars = [];
|
|
|
|
|
|
_.forEach(data, function(item) {
|
|
|
var obj = {};
|
|
|
let obj = {};
|
|
|
|
|
|
obj.link = item.sort_url;
|
|
|
obj.cn = item.sort_name;
|
...
|
...
|
@@ -58,28 +67,74 @@ function getNavBar(data) { |
|
|
});
|
|
|
|
|
|
return navBars;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function getSubNav(data) {
|
|
|
var subNav = [];
|
|
|
const getBrandItems = (data) => {
|
|
|
let brandItems = [];
|
|
|
|
|
|
_.forEach(data, function(item) {
|
|
|
var obj = {};
|
|
|
let obj = {};
|
|
|
|
|
|
obj.link = item.sort_url;
|
|
|
obj.hot = item.is_hot;
|
|
|
obj.brandName = item.sort_name;
|
|
|
|
|
|
brandItems.push(obj);
|
|
|
});
|
|
|
|
|
|
|
|
|
return brandItems;
|
|
|
};
|
|
|
|
|
|
const getThirdNav = (data) => {
|
|
|
let thirdNav = [];
|
|
|
|
|
|
_.forEach(data, function(item) {
|
|
|
let obj = {};
|
|
|
|
|
|
obj.link = item.sort_url;
|
|
|
obj.title = item.sort_name;
|
|
|
obj.imgCode = item.content_code;
|
|
|
|
|
|
if (item.sub) {
|
|
|
obj.brandItems = getBrandItems(item.sub);
|
|
|
}
|
|
|
|
|
|
thirdNav.push(obj);
|
|
|
});
|
|
|
|
|
|
|
|
|
return thirdNav;
|
|
|
};
|
|
|
|
|
|
const getSubNav = (data) => {
|
|
|
let subNav = [];
|
|
|
|
|
|
_.forEach(data, function(item) {
|
|
|
let obj = {};
|
|
|
|
|
|
obj.link = item.sort_url;
|
|
|
obj.name = item.sort_name;
|
|
|
obj.isHot = item.is_hot === 'Y' ? true : false;
|
|
|
obj.isNew = item.is_new === 'Y' ? true : false;
|
|
|
|
|
|
if (item.sub) {
|
|
|
obj.thirdNav = getThirdNav(item.sub);
|
|
|
}
|
|
|
|
|
|
subNav.push(obj);
|
|
|
});
|
|
|
|
|
|
|
|
|
console.log(subNav);
|
|
|
|
|
|
return subNav;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
exports.getAllHeaderData = function(resData) {
|
|
|
var config = getConfig();
|
|
|
var data = {
|
|
|
let config = getConfig();
|
|
|
let data = {
|
|
|
headerData: {
|
|
|
header: true,
|
|
|
type: 'boy',
|
...
|
...
|
@@ -93,25 +148,14 @@ exports.getAllHeaderData = function(resData) { |
|
|
};
|
|
|
|
|
|
exports.getHeaderData = function() {
|
|
|
var opt = {
|
|
|
uri: 'http://testservice.yoho.cn:28077/operations/api/v6/category/getCategory',
|
|
|
qs: {
|
|
|
let data = sign.apiSign({
|
|
|
|
|
|
/* eslint-disable */
|
|
|
app_version: '3.8.2',
|
|
|
client_type: 'web',
|
|
|
os_version: 'yohobuy:h5',
|
|
|
screen_size: '720x1280',
|
|
|
v: '7',
|
|
|
client_secret: 'f47f9d46f09d930496dee2a9082ff041'
|
|
|
|
|
|
/* eslint-enable */
|
|
|
},
|
|
|
headers: {
|
|
|
'content-type': 'application/json;charset=UTF-8'
|
|
|
}
|
|
|
};
|
|
|
});
|
|
|
|
|
|
return rp(opt);
|
|
|
return api.get('/operations/api/v6/category/getCategory', data);
|
|
|
};
|
|
|
|
...
|
...
|
|