...
|
...
|
@@ -43,7 +43,7 @@ class passportModel extends global.yoho.BaseModel { |
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
}
|
|
|
signinByOpenID({ nickname, openId, sourceType, businessLine}) {
|
|
|
signinByOpenID({ nickname, openId, sourceType, sourceTypeSecond, businessLine}) {
|
|
|
let param = {
|
|
|
nickname: nickname || '',
|
|
|
openId: openId,
|
...
|
...
|
@@ -55,6 +55,10 @@ class passportModel extends global.yoho.BaseModel { |
|
|
param.business_line = businessLine;
|
|
|
}
|
|
|
|
|
|
if (sourceTypeSecond) {
|
|
|
param.source_type_second = sourceTypeSecond;
|
|
|
}
|
|
|
|
|
|
return this.get({ data: param });
|
|
|
}
|
|
|
syncUserSession({uid, sessionKey, req, res}) {
|
...
|
...
|
@@ -119,25 +123,33 @@ class passportModel extends global.yoho.BaseModel { |
|
|
log.info(`[sync profile error] uid: ${uid} | err: ${JSON.stringify(e)}`);
|
|
|
});
|
|
|
}
|
|
|
sendTaobaoBindCode(mobile) {
|
|
|
return this.post({
|
|
|
data: {
|
|
|
method: 'app.bind.sendCodeByTB',
|
|
|
source_type: 'taobao',
|
|
|
mobile
|
|
|
}
|
|
|
});
|
|
|
sendTaobaoBindCode(mobile, sourceTypeSecond) {
|
|
|
let data = {
|
|
|
method: 'app.bind.sendCodeByTB',
|
|
|
source_type: 'taobao',
|
|
|
mobile
|
|
|
};
|
|
|
|
|
|
if (sourceTypeSecond) {
|
|
|
data.source_type_second = sourceTypeSecond;
|
|
|
}
|
|
|
|
|
|
return this.post({ data });
|
|
|
}
|
|
|
bindTaobaoAccountByCode({ mobile, code, openId }) {
|
|
|
return this.post({
|
|
|
data: {
|
|
|
method: 'app.bind.bindTBByCode',
|
|
|
source_type: 'taobao',
|
|
|
mobile,
|
|
|
code,
|
|
|
open_id: openId
|
|
|
}
|
|
|
});
|
|
|
bindTaobaoAccountByCode({ mobile, code, openId, sourceTypeSecond }) {
|
|
|
let data = {
|
|
|
method: 'app.bind.bindTBByCode',
|
|
|
source_type: 'taobao',
|
|
|
mobile,
|
|
|
code,
|
|
|
open_id: openId
|
|
|
};
|
|
|
|
|
|
if (sourceTypeSecond) {
|
|
|
data.source_type_second = sourceTypeSecond;
|
|
|
}
|
|
|
|
|
|
return this.post({ data });
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
@@ -161,7 +173,8 @@ const login = { |
|
|
|
|
|
return model.signinByOpenID({
|
|
|
openId: user.open_uid,
|
|
|
sourceType: 'taobao'
|
|
|
sourceType: 'taobao',
|
|
|
sourceTypeSecond: req.yoho.isAliApp ? 'xianyu' : ''
|
|
|
}).then(result => {
|
|
|
let redirectUrl = loginPage;
|
|
|
|
...
|
...
|
@@ -218,7 +231,7 @@ const bind = { |
|
|
let info = bind.getBindThirdInfo(bindCode);
|
|
|
|
|
|
if (info.type === 'taobao') {
|
|
|
req.ctx(passportModel).sendTaobaoBindCode(mobile).then(res.json).catch(next);
|
|
|
req.ctx(passportModel).sendTaobaoBindCode(mobile, req.yoho.isAliApp ? 'xianyu' : '').then(res.json).catch(next);
|
|
|
} else {
|
|
|
res.json({
|
|
|
code: 200,
|
...
|
...
|
@@ -236,7 +249,8 @@ const bind = { |
|
|
model.bindTaobaoAccountByCode({
|
|
|
mobile,
|
|
|
code,
|
|
|
openId: info.openId
|
|
|
openId: info.openId,
|
|
|
sourceTypeSecond: req.yoho.isAliApp ? 'xianyu' : ''
|
|
|
}).then(result => {
|
|
|
if (_.get(result, 'data.is_bind') === 'Y') {
|
|
|
model.syncUserSession({
|
...
|
...
|
|