Authored by 李靖

资源位

... ... @@ -7,6 +7,8 @@ const resourcesProcess = require(`${utils}/resources-process`);
class CouponList extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.topCode = '865184f7d758e34a1c9d48cae86d86ae'; // 顶部资源位
this.bottomCode = 'a08f03ca0aece80920221e4d8b1e0312'; // 底部资源位
}
getCoupons(params) {
... ... @@ -60,47 +62,35 @@ class CouponList extends global.yoho.BaseModel {
});
}
// 资源位
getResTop() {
let options = {
url: '/operations/api/v5/resource/home',
data: {
content_code: '865184f7d758e34a1c9d48cae86d86ae',
},
api: global.yoho.ServiceAPI
};
return this.get(options).then(result => {
return this.resData(result);
});
return this.resData(this.topCode);
}
// 资源位
getResBottom() {
return this.resData(this.bottomCode);
}
resData(resCode) {
let options = {
url: '/operations/api/v5/resource/home',
data: {
content_code: 'a08f03ca0aece80920221e4d8b1e0312',
content_code: resCode,
},
api: global.yoho.ServiceAPI
};
return this.get(options).then(result => {
return this.resData(result);
});
}
resData(result) {
if (result && result.code === 200 && result.data && result.data.list) {
for (let item of result.data.list) {
item.template_name === 'single_image' &&
item.data.length === 1 &&
(item.singleOne = true);
if (result && result.code === 200 && result.data && result.data.list) {
for (let item of result.data.list) {
item.template_name === 'single_image' &&
item.data.length === 1 &&
(item.singleOne = true);
}
return resourcesProcess(result.data.list);
} else {
return result;
}
return resourcesProcess(result.data.list);
} else {
return result;
}
});
}
index(params) {
... ...