|
@@ -5,36 +5,72 @@ |
|
@@ -5,36 +5,72 @@ |
5
|
*/
|
5
|
*/
|
6
|
|
6
|
|
7
|
'use strict';
|
7
|
'use strict';
|
8
|
-const service = global.yoho.ServiceAPI;
|
|
|
9
|
-const api = global.yoho.API;
|
8
|
+const serviceAPI = global.yoho.ServiceAPI;
|
10
|
const _ = require('lodash');
|
9
|
const _ = require('lodash');
|
11
|
const helpers = global.yoho.helpers;
|
10
|
const helpers = global.yoho.helpers;
|
12
|
const utils = '../../../utils';
|
11
|
const utils = '../../../utils';
|
13
|
const productProcess = require(`${utils}/product-process`);
|
12
|
const productProcess = require(`${utils}/product-process`);
|
14
|
|
13
|
|
|
|
14
|
+module.exports = class extends global.yoho.BaseModel {
|
|
|
15
|
+ constructor(ctx) {
|
|
|
16
|
+ super(ctx);
|
|
|
17
|
+ }
|
|
|
18
|
+
|
|
|
19
|
+ // 获取学校省份列表
|
|
|
20
|
+ getProvince() {
|
|
|
21
|
+ return this.get({
|
|
|
22
|
+ data: {
|
|
|
23
|
+ method: 'app.studentMarket.getAddressList'
|
|
|
24
|
+ },
|
|
|
25
|
+ param: {
|
|
|
26
|
+ cache: true
|
|
|
27
|
+ }
|
|
|
28
|
+ });
|
|
|
29
|
+ }
|
15
|
|
30
|
|
16
|
-// 获取学生个人信息
|
|
|
17
|
-const _studentInfo = (params) => {
|
|
|
18
|
- return api.get('', {
|
31
|
+ // 获取学校列表
|
|
|
32
|
+ getSchool(code) {
|
|
|
33
|
+ return this.get({
|
|
|
34
|
+ data: {
|
|
|
35
|
+ method: 'app.studentMarket.getSchoolInfoList',
|
|
|
36
|
+ areaCode: code
|
|
|
37
|
+ }
|
|
|
38
|
+ });
|
|
|
39
|
+ }
|
|
|
40
|
+
|
|
|
41
|
+ // 获取学生个人信息
|
|
|
42
|
+ _studentInfo(params) {
|
|
|
43
|
+ return this.get({
|
|
|
44
|
+ data: {
|
19
|
method: 'app.passport.getUserBase',
|
45
|
method: 'app.passport.getUserBase',
|
20
|
uid: params.shareUid
|
46
|
uid: params.shareUid
|
21
|
- }, {code: 200});
|
|
|
22
|
-};
|
47
|
+ },
|
|
|
48
|
+ param: {
|
|
|
49
|
+ code: 200
|
|
|
50
|
+ }
|
|
|
51
|
+ });
|
|
|
52
|
+ }
|
23
|
|
53
|
|
24
|
-// 判断哪个学校认证的
|
|
|
25
|
-const _getCollege = (params) => {
|
|
|
26
|
- return api.get('', {
|
54
|
+ // 判断哪个学校认证的
|
|
|
55
|
+ _getCollege(params) {
|
|
|
56
|
+ return this.get({
|
|
|
57
|
+ data: {
|
27
|
method: 'app.student.getCollegeByUid',
|
58
|
method: 'app.student.getCollegeByUid',
|
28
|
uid: params.uid
|
59
|
uid: params.uid
|
29
|
- }, {code: 200});
|
|
|
30
|
-};
|
60
|
+ },
|
|
|
61
|
+ param: {
|
|
|
62
|
+ code: 200
|
|
|
63
|
+ }
|
|
|
64
|
+ });
|
|
|
65
|
+ }
|
31
|
|
66
|
|
32
|
-const checkStudent = (params) => {
|
|
|
33
|
- return api.get('', {
|
67
|
+ checkStudent(params) {
|
|
|
68
|
+ return this.get({
|
|
|
69
|
+ data: {
|
34
|
method: 'app.student.checkIsStudent',
|
70
|
method: 'app.student.checkIsStudent',
|
35
|
uid: params.uid
|
71
|
uid: params.uid
|
|
|
72
|
+ }
|
36
|
}).then(result => {
|
73
|
}).then(result => {
|
37
|
-
|
|
|
38
|
let resu = {};
|
74
|
let resu = {};
|
39
|
|
75
|
|
40
|
if (result && result.data) {
|
76
|
if (result && result.data) {
|
|
@@ -44,9 +80,9 @@ const checkStudent = (params) => { |
|
@@ -44,9 +80,9 @@ const checkStudent = (params) => { |
44
|
return resu;
|
80
|
return resu;
|
45
|
|
81
|
|
46
|
});
|
82
|
});
|
47
|
-};
|
83
|
+ }
|
48
|
|
84
|
|
49
|
-const moreGoods = (params) => {
|
85
|
+ moreGoods(params) {
|
50
|
let apiData = {
|
86
|
let apiData = {
|
51
|
method: 'app.student.vip',
|
87
|
method: 'app.student.vip',
|
52
|
uid: params.uid,
|
88
|
uid: params.uid,
|
|
@@ -59,7 +95,13 @@ const moreGoods = (params) => { |
|
@@ -59,7 +95,13 @@ const moreGoods = (params) => { |
59
|
order: 's_n_desc'
|
95
|
order: 's_n_desc'
|
60
|
});
|
96
|
});
|
61
|
}
|
97
|
}
|
62
|
- return api.get('', apiData, {code: 200}).then(result => {
|
98
|
+
|
|
|
99
|
+ return this.get({
|
|
|
100
|
+ data: apiData,
|
|
|
101
|
+ param: {
|
|
|
102
|
+ code: 200
|
|
|
103
|
+ }
|
|
|
104
|
+ }).then(result => {
|
63
|
let resu = {
|
105
|
let resu = {
|
64
|
goods: []
|
106
|
goods: []
|
65
|
};
|
107
|
};
|
|
@@ -72,11 +114,10 @@ const moreGoods = (params) => { |
|
@@ -72,11 +114,10 @@ const moreGoods = (params) => { |
72
|
|
114
|
|
73
|
return resu;
|
115
|
return resu;
|
74
|
});
|
116
|
});
|
75
|
-};
|
|
|
76
|
-
|
|
|
77
|
-// 获取学生状态
|
|
|
78
|
-const _studentState = (params) => {
|
117
|
+ }
|
79
|
|
118
|
|
|
|
119
|
+ // 获取学生状态
|
|
|
120
|
+ _studentState(params) {
|
80
|
let resu = {
|
121
|
let resu = {
|
81
|
studentState: {}
|
122
|
studentState: {}
|
82
|
};
|
123
|
};
|
|
@@ -89,10 +130,10 @@ const _studentState = (params) => { |
|
@@ -89,10 +130,10 @@ const _studentState = (params) => { |
89
|
return resu;
|
130
|
return resu;
|
90
|
} else if (params.shareUid !== 'undefined' && typeof params.shareUid !== 'undefined') {
|
131
|
} else if (params.shareUid !== 'undefined' && typeof params.shareUid !== 'undefined') {
|
91
|
// 已登录,为分享链接,验证是否已认证
|
132
|
// 已登录,为分享链接,验证是否已认证
|
92
|
- return service.all([
|
|
|
93
|
- _studentInfo(params),
|
|
|
94
|
- checkStudent(params),
|
|
|
95
|
- _getCollege(params)
|
133
|
+ return Promise.all([
|
|
|
134
|
+ this._studentInfo(params),
|
|
|
135
|
+ this.checkStudent(params),
|
|
|
136
|
+ this._getCollege(params)
|
96
|
]).then(result => {
|
137
|
]).then(result => {
|
97
|
if (result && result[1] === 1) {
|
138
|
if (result && result[1] === 1) {
|
98
|
resu.studentState = {
|
139
|
resu.studentState = {
|
|
@@ -112,9 +153,9 @@ const _studentState = (params) => { |
|
@@ -112,9 +153,9 @@ const _studentState = (params) => { |
112
|
});
|
153
|
});
|
113
|
} else {
|
154
|
} else {
|
114
|
// 已登录,为原链接,验证是否已认证
|
155
|
// 已登录,为原链接,验证是否已认证
|
115
|
- return service.all([
|
|
|
116
|
- _getCollege(params),
|
|
|
117
|
- checkStudent(params)
|
156
|
+ return Promise.all([
|
|
|
157
|
+ this._getCollege(params),
|
|
|
158
|
+ this.checkStudent(params)
|
118
|
]).then(result => {
|
159
|
]).then(result => {
|
119
|
|
160
|
|
120
|
// 已认证
|
161
|
// 已认证
|
|
@@ -134,36 +175,46 @@ const _studentState = (params) => { |
|
@@ -134,36 +175,46 @@ const _studentState = (params) => { |
134
|
return resu;
|
175
|
return resu;
|
135
|
});
|
176
|
});
|
136
|
}
|
177
|
}
|
137
|
-};
|
178
|
+ }
|
138
|
|
179
|
|
139
|
-// 获取学生认证总数
|
|
|
140
|
-const _studentTotal = () => {
|
|
|
141
|
- return api.get('', {
|
180
|
+ // 获取学生认证总数
|
|
|
181
|
+ _studentTotal() {
|
|
|
182
|
+ return this.get({
|
|
|
183
|
+ data: {
|
142
|
method: 'app.student.verifiedStudentTotal'
|
184
|
method: 'app.student.verifiedStudentTotal'
|
|
|
185
|
+ }
|
143
|
});
|
186
|
});
|
144
|
-};
|
187
|
+ }
|
145
|
|
188
|
|
146
|
-// 获取学校认证总数
|
|
|
147
|
-const _schoolTotal = () => {
|
|
|
148
|
- return api.get('', {
|
189
|
+ // 获取学校认证总数
|
|
|
190
|
+ _schoolTotal() {
|
|
|
191
|
+ return this.get({
|
|
|
192
|
+ data: {
|
149
|
method: 'app.student.getCollegeTotal'
|
193
|
method: 'app.student.getCollegeTotal'
|
|
|
194
|
+ }
|
150
|
});
|
195
|
});
|
151
|
-};
|
196
|
+ }
|
152
|
|
197
|
|
153
|
-// 资源位
|
|
|
154
|
-const _resource = () => {
|
|
|
155
|
- return service.get('/operations/api/v5/resource/get', {
|
198
|
+ // 资源位
|
|
|
199
|
+ _resource() {
|
|
|
200
|
+ return this.get({
|
|
|
201
|
+ api: serviceAPI,
|
|
|
202
|
+ url: '/operations/api/v5/resource/get',
|
|
|
203
|
+ data: {
|
156
|
content_code: '1cff7f47ca7057ef6ac00cbf2efc37ad',
|
204
|
content_code: '1cff7f47ca7057ef6ac00cbf2efc37ad',
|
|
|
205
|
+ }
|
157
|
});
|
206
|
});
|
158
|
-};
|
207
|
+ }
|
159
|
|
208
|
|
160
|
-// 获取分享记录
|
|
|
161
|
-const _shareLog = (params) => {
|
209
|
+ // 获取分享记录
|
|
|
210
|
+ _shareLog(params) {
|
162
|
|
211
|
|
163
|
if (params.uid) {
|
212
|
if (params.uid) {
|
164
|
- return api.get('', {
|
213
|
+ return this.get({
|
|
|
214
|
+ data: {
|
165
|
method: 'app.student.getShareLog',
|
215
|
method: 'app.student.getShareLog',
|
166
|
shareUid: params.uid
|
216
|
shareUid: params.uid
|
|
|
217
|
+ }
|
167
|
});
|
218
|
});
|
168
|
} else {
|
219
|
} else {
|
169
|
let resu = '';
|
220
|
let resu = '';
|
|
@@ -171,18 +222,20 @@ const _shareLog = (params) => { |
|
@@ -171,18 +222,20 @@ const _shareLog = (params) => { |
171
|
return Promise.resolve(resu);
|
222
|
return Promise.resolve(resu);
|
172
|
}
|
223
|
}
|
173
|
|
224
|
|
174
|
-};
|
225
|
+ }
|
175
|
|
226
|
|
176
|
-// 获取学校认证人数
|
|
|
177
|
-const getSchoolNum = (params) => {
|
|
|
178
|
- return api.get('', {
|
227
|
+ // 获取学校认证人数
|
|
|
228
|
+ getSchoolNum(params) {
|
|
|
229
|
+ return this.get({
|
|
|
230
|
+ data: {
|
179
|
method: 'app.student.verifiedStudentTotalByCollege',
|
231
|
method: 'app.student.verifiedStudentTotalByCollege',
|
180
|
college_name: params.schoolName
|
232
|
college_name: params.schoolName
|
181
|
- }, {
|
233
|
+ },
|
|
|
234
|
+ param: {
|
182
|
cache: true,
|
235
|
cache: true,
|
183
|
code: 200
|
236
|
code: 200
|
|
|
237
|
+ }
|
184
|
}).then(result => {
|
238
|
}).then(result => {
|
185
|
-
|
|
|
186
|
let obj = {
|
239
|
let obj = {
|
187
|
num: result.data,
|
240
|
num: result.data,
|
188
|
name: params.schoolName
|
241
|
name: params.schoolName
|
|
@@ -192,17 +245,16 @@ const getSchoolNum = (params) => { |
|
@@ -192,17 +245,16 @@ const getSchoolNum = (params) => { |
192
|
|
245
|
|
193
|
return result;
|
246
|
return result;
|
194
|
});
|
247
|
});
|
195
|
-};
|
248
|
+ }
|
196
|
|
249
|
|
197
|
-const index = (params) => {
|
|
|
198
|
- return service.all([
|
|
|
199
|
- _studentTotal(),
|
|
|
200
|
- _schoolTotal(),
|
|
|
201
|
- _shareLog(params),
|
|
|
202
|
- _studentState(params),
|
|
|
203
|
- _resource(),
|
250
|
+ index(params) {
|
|
|
251
|
+ return Promise.all([
|
|
|
252
|
+ this._studentTotal(),
|
|
|
253
|
+ this._schoolTotal(),
|
|
|
254
|
+ this._shareLog(params),
|
|
|
255
|
+ this._studentState(params),
|
|
|
256
|
+ this._resource(),
|
204
|
]).then(result => {
|
257
|
]).then(result => {
|
205
|
-
|
|
|
206
|
let resu = {
|
258
|
let resu = {
|
207
|
shareLog: [],
|
259
|
shareLog: [],
|
208
|
picList: [],
|
260
|
picList: [],
|
|
@@ -292,12 +344,5 @@ const index = (params) => { |
|
@@ -292,12 +344,5 @@ const index = (params) => { |
292
|
}
|
344
|
}
|
293
|
return resu;
|
345
|
return resu;
|
294
|
});
|
346
|
});
|
295
|
-
|
|
|
296
|
-};
|
|
|
297
|
-
|
|
|
298
|
-module.exports = {
|
|
|
299
|
- index,
|
|
|
300
|
- getSchoolNum,
|
|
|
301
|
- checkStudent,
|
|
|
302
|
- moreGoods
|
347
|
+ }
|
303
|
}; |
348
|
}; |