user-service.js
1.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
/**
* Created by TaoHuang on 2017/4/17.
*/
'use strict';
const _ = require('lodash');
const md5 = require('yoho-md5');
const Context = require('../common/context');
const Api = require('../common/api');
const apiDomain = global.yoho.apiDomain;
const config = global.yoho.config;
class UserService extends Context {
constructor() {
super();
this.api = this.instance(Api);
}
login(account, password) {
return this.api.post(apiDomain.erp.login, {
account,
password,
platform: config.platform
}).then(userInfo => {
this.api.get(`http://192.168.102.211:30016/loginInter?user=${account}&password=${password}`).then(res => {
console.log(res);
});
if (userInfo.code !== 200 || !userInfo.data.pid) {
return Promise.reject({code: 500, message: '用户名密码错误'});
}
return userInfo.data;
});
}
getShops(pid) {
return this.api.get(apiDomain.platform.queryShopsByAdminPid, {
userId: pid
}).then(result => {
if (result.code === 200) {
_.each(result.data, shop => {
shop.id = md5(shop.shopName);
});
}
return result;
});
}
profile(pid) {
return this.instance(Api).get(apiDomain.shop.profile.url, {userId: pid});
}
}
module.exports = UserService;