...
|
...
|
@@ -9,16 +9,14 @@ |
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const PassportHelper = require('../models/passport-helper');
|
|
|
const BindService = require('../models/bind-api');
|
|
|
const loginService = require('../models/login-service');
|
|
|
const BindService = require('../models/bind-service');
|
|
|
const LoginService = require('../models/login-service');
|
|
|
|
|
|
const Sources = {
|
|
|
qq: 'QQ',
|
|
|
sina: '微博',
|
|
|
alipay: '支付宝',
|
|
|
wechat: '微信',
|
|
|
renren: '人人',
|
|
|
douban: '豆瓣'
|
|
|
wechat: '微信'
|
|
|
};
|
|
|
|
|
|
const DEFAULT_URL = 'http://img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100';
|
...
|
...
|
@@ -173,7 +171,7 @@ const bind = { |
|
|
let sourceType = req.body.sourceType;
|
|
|
|
|
|
if (mobile && openId && area && sourceType) {
|
|
|
BindService.bindCheck(mobile, openId, sourceType, area).then(result => {
|
|
|
BindService.bindCheckAsync(mobile, openId, sourceType, area).then(result => {
|
|
|
if (!result || !result.code) {
|
|
|
return {code: 400, message: '', data: ''};
|
|
|
} else if (result.code === 200 && result.data.is_register === 0) {
|
...
|
...
|
@@ -210,7 +208,7 @@ const bind = { |
|
|
let mobile = req.body.mobile;
|
|
|
let area = req.body.area;
|
|
|
|
|
|
BindService.sendBindMsg(area, mobile).then(result => {
|
|
|
BindService.sendBindMsgAsync(area, mobile).then(result => {
|
|
|
if (result && result.code) {
|
|
|
res.json(result);
|
|
|
} else {
|
...
|
...
|
@@ -223,7 +221,7 @@ const bind = { |
|
|
let area = req.body.area;
|
|
|
let code = req.body.code;
|
|
|
|
|
|
BindService.checkBindCode(area, mobile, code).then(result => {
|
|
|
BindService.checkBindCodeAsync(area, mobile, code).then(result => {
|
|
|
if (result && result.code) {
|
|
|
res.json(result);
|
|
|
} else {
|
...
|
...
|
@@ -238,14 +236,14 @@ const bind = { |
|
|
let sourceType = _.trim(req.body.sourceType);
|
|
|
let password = _.trim(req.body.password) || '';
|
|
|
|
|
|
BindService.bindMobile(openId, sourceType, mobile, area, password).then(result => {
|
|
|
BindService.bindMobileAsync(openId, sourceType, mobile, area, password).then(result => {
|
|
|
if (result && result.code) {
|
|
|
if (result.code === 200 && result.data && result.data.uid) {
|
|
|
let refer = helpers.urlFormat('/passport/thirdlogin/bindsuccess', {
|
|
|
sourceType: sourceType + '_bind'
|
|
|
});
|
|
|
|
|
|
return loginService.syncUserSession(result.data.uid, req, res).then(() => {
|
|
|
return LoginService.syncUserSession(result.data.uid, req, res).then(() => {
|
|
|
return {code: 200, message: result.message, data: {refer: refer}};
|
|
|
});
|
|
|
} else {
|
...
|
...
|
@@ -264,14 +262,14 @@ const bind = { |
|
|
let areaCode = req.body.areaCode || '86';
|
|
|
let sourceType = req.body.sourceType;
|
|
|
|
|
|
return BindService.relateMobile(openId, sourceType, mobile, areaCode).then(result => {
|
|
|
return BindService.relateMobileAsync(openId, sourceType, mobile, areaCode).then(result => {
|
|
|
if (result && result.code) {
|
|
|
if (result.code === 200 && result.data && result.data.uid) {
|
|
|
let refer = helpers.urlFormat('/passport/thirdlogin/relatesuccess', {
|
|
|
sourceType: sourceType + '_bind'
|
|
|
});
|
|
|
|
|
|
return loginService.syncUserSession(result.data.uid, req, res).then(() => {
|
|
|
return LoginService.syncUserSession(result.data.uid, req, res).then(() => {
|
|
|
return {code: 200, message: result.message, data: {refer: refer}};
|
|
|
});
|
|
|
} else {
|
...
|
...
|
|