vipDay.js
4.45 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* eslint-disable camelcase */
'use strict';
const url = require('url');
const _ = require('lodash');
const serviceAPI = global.yoho.ServiceAPI;
const utils = require(global.utils + '/product-process');
const helpers = global.yoho.helpers;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
// 签到
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BC%9A%E5%91%98%E6%97%A5%E7%AD%BE%E5%88%B0.md
signin(uid) {
return this.get({
api: serviceAPI,
url: '/activity/UserdaySigninController/signin',
data: {uid}
});
}
// 写留言
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BF%9D%E5%AD%98%E7%94%A8%E6%88%B7%E7%95%99%E8%A8%80.md
saveMsg(uid, nick_name, content) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayLeaveWordsController/addLeaveWords',
data: {
uid,
nick_name,
content
}
});
}
queryLeaveWordsList(uid) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayLeaveWordsController/queryLeaveWordsList',
data: {
uid
}
});
}
// 拼手气大转盘 抽奖
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%8B%BC%E6%89%8B%E6%B0%94%E5%A4%A7%E8%BD%AC%E7%9B%98%E6%8A%BD%E5%A5%96.md
addPrizeLog(uid, prize_type) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayPrizeLogController/addPrizeLog',
data: {
uid,
prize_type
}
});
}
// 查询 中奖纪录
queryPrizeLog(uid, prize_type) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayPrizeLogController/queryPrizeLog',
data: {
uid,
prize_type
}
});
}
// 获取用户的有货币
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/tree/master/%E6%9C%89%E8%B4%A7%E5%B8%81
getCoins(uid) {
return this.get({
data: {
method: 'app.yohocoin.total',
uid
}
});
}
// 获取抽奖人数
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%9F%A5%E8%AF%A2%E5%8F%82%E4%B8%8E%E6%8A%BD%E5%A5%96%E4%BA%BA%E6%95%B0.md
getJoinNum(prize_type) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayPrizeLogController/queryPrizeLogNum',
data: {
prize_type
}
});
}
/**
* cate [object Object]
*/
getGoods(cate) {
let skns = '';
let cates = Object.keys(cate);
_.forEach(cate, function(val) {
skns = skns.concat(',').concat(val.join(','));
});
skns = skns.slice(1);
return this.get({
data: {
method: 'h5.product.batch',
productSkn: skns
}
}).then(result => {
if (result.code !== 200) {
return {
code: result.code,
message: result.message
};
}
let productList = utils.processProductList(result.data.product_list);
let data = {};
productList.forEach(product=> {
let skn = product.productSkn;
let imgSrc = url.parse(product.defaultImages || '');
product.defaultImages = ['//', imgSrc.hostname, imgSrc.pathname].join('');
product.url = helpers.appUrlFormat(product.url, 'go.productDetail', {
product_skn: skn
});
for (let c of cates) {
let index = cate[c].indexOf(skn);
if (index !== -1) {
cate[c].splice(index, 1);
data[c] || (data[c] = []);
data[c].push(product);
break;
}
}
});
return {
code: 200,
data
};
});
}
};