Authored by 郝肖肖

tab 接口数据

... ... @@ -12,32 +12,46 @@ const plusstarModel = require(`${mRoot}/plusstar`);
/**
* 潮流优选首页
*/
let index = (req, res) => {
let data = [
{
'bgColor': '',
'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',
'title': '11111',
'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'
}, {
'bgColor': '',
'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',
'title': '2222',
'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'
}, {
'bgColor': '',
'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',
'title': '33333',
'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'
}
];
res.render('plusstar/index', {
page: 'plusstar-index',
data: data,
title: '潮流优选'
});
exports.index = (req, res, next) => {
plusstarModel.getAllChannels({}).then(result => {
res.render('plusstar/index', {
page: 'plusstar-index',
result: result,
title: '潮流优选'
});
}).catch(next);
};
module.exports = {
index
/**
* 潮流优选首页-资源位
*/
exports.resources = (req, res, next) => {
let code = req.query.code || '';
// let data = [{
// 'bgColor': '',
// 'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',
// 'title': '11111',
// 'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'
// }, {
// 'bgColor': '',
// 'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',
// 'title': '2222',
// 'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'
// }, {
// 'bgColor': '',
// 'src': 'http://img12.static.yhbimg.com/yhb-img01/2016/04/18/06/02f043ae44ccf0e49fdddd7db39649a889.jpg?imageView2/{mode}/w/{width}/h/{height}',
// 'title': '33333',
// 'url': 'http://cdn.yoho.cn/huodong/0418SALEGIRL/index.html?title=IN季精选&share_id=832'
// }
// ];
plusstarModel.getResources({
content_code: code
}).then(result => {
res.render('plusstar/index', {
page: 'plusstar-index',
result: result,
title: '潮流优选'
});
}).catch(next);
};
... ...
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
/**
* 获取分享页面列表数据
* @param {[int]} uid 用户id
* @param {[int]} activityId 活动id
* 获取潮流优选tab
* @return {[array]}
*/
const index = (params) => {
const getAllChannels = (params) => {
params = params || {};
return api.get('', Object.assign({
method: 'wap.invite.index'
}, params)).then((result) => {
return Object.assign(camelCase(result));
method: 'app.blk.getAllChannels'
}, params)).then(result => {
let data = {channel: []};
if (result.code !== 200) {
return data;
}
_.forEach(result.data, (res, index) => {
data.channel.push({
id: res.channel_id,
mame: res.channel_name,
code: res.content_code,
focus: index === 0 ? true : false
});
});
return data;
});
};
/**
* 获取资源位数据
* @param {[string]} content_code
* @return {[array]}
*/
const getResources = (params) => {
params = params || {};
return serviceAPI.get(
'operations/api/v5/resource/get',
Object.assign(params)
).then(result => {
let data = {};
let list = {};
if (result.code !== 200) {
return data2;
}
_.forEach(result.data, (res, index) => {
list = {};
switch (res.template_name) {
case 'focus':
list = {
data: res.data
};
if (res.focus_type == 1) {
data.focus1 = list;
} else {
data.focus2 = list;
}
break;
case 'title_image':
if (typeof data[res.template_name] === 'undefined') {
data[res.template_name] = [];
}
list = {
title: res.data.title,
moreUrl: res.data.more_url,
moreName: res.data.more_name,
image: res.data.image
};
data.title_image.push(list);
break;
case 'titleFloor':
list = {
title: res.data.title.more_name,
more_url: res.data.more_url,
more_name: res.data.more_name,
data: res.data.image
};
data[res.template_name].push(list);
break;
case 'recommend_content_five':
break;
case 'goods':
break;
}
});
// console.log(data, '=data===');
return data2;
});
};
module.exports = {
index
getAllChannels,
getResources
};
... ...
... ... @@ -24,5 +24,6 @@ router.get('/star/collocation/list', star.collocationList); // 星潮教室星æ
router.post('/star/setFavorite', star.setFavorite); // 收藏文章
router.get('/plusstar', plusstar.index); // 潮流优选
router.get('/plusstar/resources', plusstar.resources); // 潮流优选首页-资源位
module.exports = router;
... ...
<div class='plusstar-page'>
<div class="tab-nav">
<ul>
<li class='focus'>
<span>MEN男士</span>
</li>
<li>
<span>WOMEN女士</span>
</li>
<li>
<span>LIFESTYLE生活</span>
</li>
</ul>
</div>
{{#if result.channel}}
<div class="tab-nav">
<ul>
{{#each result.channel}}
<li class='{{#if focus}} focus {{/if}}' data-code='{{code}}'>
<span>{{mame}}</span>
</li>
{{/each}}
</ul>
</div>
{{/if}}
<!--/tab-nav-->
<div class="resources">
... ...
... ... @@ -18,8 +18,11 @@ module.exports = {
// api: 'http://devapi.yoho.cn:58078/',
// service: 'http://devservice.yoho.cn:58077/'
api: 'http://testapi.yoho.cn:28078/',
service: 'http://testservice.yoho.cn:28077/'
// api: 'http://testapi.yoho.cn:28078/',
// service: 'http://testservice.yoho.cn:28077/'
api: 'http://dev-api.yohops.com:9999/',
service: 'http://dev-service.yohops.com:9999/'
},
subDomains: {
host: '.m.yohobuy.com',
... ...