Authored by OF1706

头部banner

... ... @@ -15,43 +15,43 @@ const index = (req, res) => {
let width = req.query.width || '';
let height = req.query.height || '';
gtModel.getResource(contentCode).then(data=>{
if (!data.data) {
res.jsonp({
code: 200,
data: '没有数据',
message: 'User info'
});
} else {
let banner = '';
let md = data.data[0];
if (md && md.data) {
if (md.template_name === 'single_image') {
banner = md.data[0];
} else if (md.template_name === 'single_name_image')
gtModel.getResource(contentCode).then(data =>{
if (!data.data) {
res.jsonp({
code: 200,
data: '没有数据',
message: 'User info'
});
} else {
let banner = '';
let md = data.data[0];
if (md && md.data) {
if (md.template_name === 'single_image') {
banner = md.data[0];
} else if (md.template_name === 'single_name_image')
{
banner = md.data;
}
if ( banner) {
if (!width || !height) {
width = 2600;
height = 60;
banner = md.data;
}
if (banner) {
if (!width || !height) {
width = 2600;
height = 60;
}
}
banner.src = helpers.image(banner.src, width, height, 2);
banner.url = banner.url;
res.jsonp({
code: 200,
data: banner
});
}
}
banner.src = helpers.image(banner.src, width, height, 2);
banner.url = banner.url;
res.jsonp({
code: 200,
data: banner
});
}
}
});
};
... ...
... ... @@ -6,28 +6,23 @@
'use strict';
const helpers = global.yoho.helpers;
const serviceApi = global.yoho.ServiceAPI;
const URL_OPERATIONS_RESOURCE_GET = 'operations/api/v5/resource/get';
/**
* 获取资源数据
*
* @param string $content_code
* @param string $client_type
* @param boolean $isOnlyUrl false
* @string content_code
* @return array
*/
const getResource = content_code => {
return serviceApi.get(URL_OPERATIONS_RESOURCE_GET, {
content_code:content_code
},{cache: true});
content_code: content_code
}, {cache: true});
};
module.exports = {
getResource
getResource
};
... ...