...
|
...
|
@@ -56,8 +56,8 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
};
|
|
|
|
|
|
if (result) {
|
|
|
if (result[0] && result[0].data && result[0].data.list) {
|
|
|
if (result[0].data.list[0] && result[0].data.list[0].data && result[0].data.list[0].data[0]) {
|
|
|
if (_.get(result, '[0].data.list', false)) {
|
|
|
if (_.get(result[0].data.list[0], 'data[0]', false)) {
|
|
|
let val = result[0].data.list[0].data[0];
|
|
|
|
|
|
resu.bigPic = {
|
...
|
...
|
@@ -67,22 +67,36 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
}
|
|
|
}
|
|
|
|
|
|
if (result[1] && result[1].data && result[1].data.product_list) {
|
|
|
if (_.get(result, '[1].data.product_list', false)) {
|
|
|
let build = [];
|
|
|
let data = result[1].data.product_list;
|
|
|
|
|
|
_.forEach(data, (val) => {
|
|
|
let discount = this.getDiscound(val.sales_price, val.market_price);
|
|
|
|
|
|
build.push({
|
|
|
productName: val.product_name,
|
|
|
salesPrice: val.sales_price,
|
|
|
marketPrice: val.market_price,
|
|
|
marketPrice: val.market_price === val.sales_price ? '' : val.market_price,
|
|
|
defaultImages: val.default_images ? val.default_images.split(',')[0] : '',
|
|
|
productSkn: val.product_skn
|
|
|
productSkn: val.product_skn,
|
|
|
discount: discount
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.goodList = build;
|
|
|
}
|
|
|
|
|
|
if (_.get(result, '[1].data.coupon_list', false)) {
|
|
|
let couponNum = result[1].data.coupon_list.length;
|
|
|
|
|
|
if (couponNum % 2 !== 0) {
|
|
|
resu.odd = true;
|
|
|
} else {
|
|
|
resu.odd = false;
|
|
|
}
|
|
|
resu.couponList = result[1].data.coupon_list;
|
|
|
}
|
|
|
}
|
|
|
return resu;
|
|
|
});
|
...
|
...
|
@@ -96,17 +110,20 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
goodList: []
|
|
|
};
|
|
|
|
|
|
if (result[0] && result[0].data && result[0].data.product_list) {
|
|
|
if (_.get(result, '[0].data.product_list', false)) {
|
|
|
let build = [];
|
|
|
let data = result[0].data.product_list;
|
|
|
|
|
|
_.forEach(data, (val) => {
|
|
|
let discount = this.getDiscound(val.sales_price, val.market_price);
|
|
|
|
|
|
build.push({
|
|
|
productName: val.product_name,
|
|
|
salesPrice: val.sales_price,
|
|
|
marketPrice: val.market_price,
|
|
|
marketPrice: val.market_price === val.sales_price ? '' : val.market_price,
|
|
|
defaultImages: val.default_images ? val.default_images.split(',')[0] : '',
|
|
|
productSkn: val.product_skn
|
|
|
productSkn: val.product_skn,
|
|
|
discount: discount
|
|
|
});
|
|
|
});
|
|
|
|
...
|
...
|
@@ -115,4 +132,47 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
return resu;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
getDiscound(salesPrice, marketPrice) {
|
|
|
let dis = Math.ceil(parseInt(salesPrice, 10) / parseInt(marketPrice, 10) * 10);
|
|
|
let disMes = '';
|
|
|
|
|
|
switch (dis) {
|
|
|
case 0:
|
|
|
disMes = '<span>1</span>折';
|
|
|
break;
|
|
|
case 1:
|
|
|
disMes = '<span>1</span>折';
|
|
|
break;
|
|
|
case 2:
|
|
|
disMes = '<span>2</span>折';
|
|
|
break;
|
|
|
case 3:
|
|
|
disMes = '<span>3</span>折';
|
|
|
break;
|
|
|
case 4:
|
|
|
disMes = '<span>4</span>折';
|
|
|
break;
|
|
|
case 5:
|
|
|
disMes = '<span>5</span>折';
|
|
|
break;
|
|
|
case 6:
|
|
|
disMes = '<span>6</span>折';
|
|
|
break;
|
|
|
case 7:
|
|
|
disMes = '<span>7</span>折';
|
|
|
break;
|
|
|
case 8:
|
|
|
disMes = '<span>8</span>折';
|
|
|
break;
|
|
|
case 9:
|
|
|
disMes = '<span>9</span>折';
|
|
|
break;
|
|
|
default:
|
|
|
disMes = '热卖';
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return disMes;
|
|
|
}
|
|
|
}; |
...
|
...
|
|