|
|
'use strict';
|
|
|
|
|
|
const _ = require('lodash');
|
|
|
const utils = '../../../utils';
|
|
|
const resourcesProcess = require(`${utils}/resources-process`);
|
|
|
|
|
|
class CouponList extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
...
|
...
|
@@ -58,12 +60,64 @@ 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 => {
|
|
|
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;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 资源位
|
|
|
getResBottom() {
|
|
|
let options = {
|
|
|
url: '/operations/api/v5/resource/home',
|
|
|
data: {
|
|
|
content_code: 'a08f03ca0aece80920221e4d8b1e0312',
|
|
|
},
|
|
|
api: global.yoho.ServiceAPI
|
|
|
};
|
|
|
|
|
|
return this.get(options).then(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);
|
|
|
}
|
|
|
return resourcesProcess(result.data.list);
|
|
|
} else {
|
|
|
return result;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
index(params) {
|
|
|
return Promise.all([
|
|
|
this.getCoupons(params)
|
|
|
this.getCoupons(params),
|
|
|
this.getResTop(),
|
|
|
this.getResBottom()
|
|
|
]).then(result => {
|
|
|
let resu = {
|
|
|
shopCoupons: []
|
|
|
shopCoupons: [],
|
|
|
contentTop: {},
|
|
|
contentBottom: {}
|
|
|
};
|
|
|
|
|
|
if (_.get(result, '[0].data')) {
|
...
|
...
|
@@ -78,6 +132,15 @@ class CouponList extends global.yoho.BaseModel { |
|
|
resu.shopCoupons.push(build);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (_.get(result, '[1]')) {
|
|
|
resu.contentTop.content = result[1];
|
|
|
}
|
|
|
|
|
|
if (_.get(result, '[2]')) {
|
|
|
resu.contentBottom.content = result[2];
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
}
|
...
|
...
|
|