seckill-detail.js
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* [商品获取数据]
*/
'use strict';
const _ = require('lodash');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
/**
* 获取秒杀列表
*/
getSeckillData(param) {
let params = {
method: 'app.seckill.data',
product_skn: param.productskn
};
return this.get({
data: params,
param: {code: 200}
})
// mock
.catch()
.then(result => {
let data = {};
if (_.get(result, 'data') && !_.isArray(result.data)) {
data = result.data;
if (data.storageSum > 0) {
data.storageSum = 1;
}
if (data.secKillSku) {
_.forEach(data.secKillSku, item => {
if (item.storageNum > 0) {
item.storageNum = 1;
}
});
}
} else {
data.status = 0;
}
return data;
});
}
};