Authored by 郭成尧

PhoneServiceModel

... ... @@ -7,7 +7,7 @@ const cookie = global.yoho.cookie;
const EventEmitter = require('events');
const utils = require(global.utils);
const RegServiceModel = require('../models/reg-service');
const PhoneService = require('../models/phone-service');
const PhoneServiceModel = require('../models/phone-service');
const AuthHelper = require('../models/auth-helper');
const LoginNewModel = require('../models/login-new');
... ... @@ -81,7 +81,7 @@ class SmsLogin {
_.set(req.session, 'smsLogin.step', 2);
req.session.captcha = null;
PhoneService.sendSMS(mobile, area, 1);
req.ctx(PhoneServiceModel).sendSMS(mobile, area, 1);
res.json({
code: 200,
... ... @@ -153,7 +153,7 @@ class SmsLogin {
let area = _.get(req.session, 'smsLogin.area');
let mobile = _.get(req.session, 'smsLogin.mobile');
PhoneService.sendSMS(mobile, area, 1).then(result => {
req.ctx(PhoneServiceModel).sendSMS(mobile, area, 1).then(result => {
if (result.code === 200) {
_.set(req.session, 'smsLogin.step', 2);
... ... @@ -212,8 +212,8 @@ class SmsLogin {
}
Promise.all([
PhoneService.checkUserPhoneExist(mobile, area),
PhoneService.verifySMS(mobile, area, code, 1)
req.ctx(PhoneServiceModel).checkUserPhoneExist(mobile, area),
req.ctx(PhoneServiceModel).verifySMS(mobile, area, code, 1)
])
.then(result => {
let r1 = result[0] || {};
... ... @@ -258,7 +258,7 @@ class SmsLogin {
}
// 手机号码已注册 --> 直接登录
PhoneService.autoSignin({
req.ctx(PhoneServiceModel).autoSignin({
profile: mobile,
code: r2.data.code,
area,
... ...
/* eslint no-unused-vars: ["error", { "args": "none" }] */
'use strict';
const API = global.yoho.API;
const FROM = require('../../../config/from');
class PhoneService {
class PhoneServiceModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
// 校验 手机 是否 已注册
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/校验是否是注册用户.md
static checkUserPhoneExist(mobile, area) {
return API.get('', {
method: 'app.passport.checkUserExist',
mobile,
area
checkUserPhoneExist(mobile, area) {
return this.get({
data: {
method: 'app.passport.checkUserExist',
mobile,
area
}
});
}
// 手机号 自动登录
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/手机号自动登录.md
static autoSignin(param) {
return API.get('', {
method: 'app.passport.autoSignin',
profile: param.profile,
area: param.area,
code: param.code,
shopping_key: param.shopping_key,
business_line: FROM[param.from].business_line
autoSignin(param) {
return this.get({
data: {
method: 'app.passport.autoSignin',
profile: param.profile,
area: param.area,
code: param.code,
shopping_key: param.shopping_key,
business_line: FROM[param.from].business_line
}
});
}
// 发送 验证码
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/发送验证码.md
static sendSMS(mobile, area, type) {
return API.get('', {
method: 'app.message.sendSms',
mobile,
area,
type
sendSMS(mobile, area, type) {
return this.get({
data: {
method: 'app.message.sendSms',
mobile,
area,
type
}
});
}
// 校验 验证码
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/验证验证码.md
static verifySMS(mobile, area, code, type) {
return API.get('', {
method: 'app.message.verifySmsCode',
mobile,
area,
code,
type
verifySMS(mobile, area, code, type) {
return this.get({
data: {
method: 'app.message.verifySmsCode',
mobile,
area,
code,
type
}
});
}
}
module.exports = PhoneService;
module.exports = PhoneServiceModel;
... ...