...
|
...
|
@@ -7,10 +7,13 @@ |
|
|
const _ = require('lodash');
|
|
|
const md5 = require('yoho-md5');
|
|
|
const Context = require('../common/context');
|
|
|
const rp = require('request-promise');
|
|
|
const Api = require('../common/api');
|
|
|
const apiDomain = global.yoho.apiDomain;
|
|
|
const config = global.yoho.config;
|
|
|
|
|
|
const regSession = '${0}=([^;]+);';
|
|
|
|
|
|
class UserService extends Context {
|
|
|
constructor() {
|
|
|
super();
|
...
|
...
|
@@ -22,9 +25,6 @@ class UserService extends Context { |
|
|
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: '用户名密码错误'});
|
|
|
}
|
...
|
...
|
@@ -32,6 +32,35 @@ class UserService extends Context { |
|
|
});
|
|
|
}
|
|
|
|
|
|
shopLogin(account, password) {
|
|
|
return rp.get({
|
|
|
url: apiDomain.shop.loginInter,
|
|
|
resolveWithFullResponse: true,
|
|
|
qs: {
|
|
|
user: account,
|
|
|
password: password
|
|
|
}
|
|
|
}).then(response => {
|
|
|
let sessId = '', sid = '';
|
|
|
|
|
|
_.each(response.rawHeaders, header => {
|
|
|
let sessIdMatched = header.match(new RegExp(regSession.replace('${0}', 'PHPSESSID')));
|
|
|
let sidMatched = header.match(new RegExp(regSession.replace('${0}', 'connect\.sid')));
|
|
|
|
|
|
if (sessIdMatched) {
|
|
|
sessId = sessIdMatched[1];
|
|
|
}
|
|
|
if (sidMatched) {
|
|
|
sid = sidMatched[1];
|
|
|
}
|
|
|
});
|
|
|
return {
|
|
|
PHPSESSID: sessId,
|
|
|
'connect.sid': sid
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
|
|
|
getShops(pid) {
|
|
|
return this.api.get(apiDomain.platform.queryShopsByAdminPid, {
|
|
|
userId: pid
|
...
|
...
|
|