Authored by 郭成尧

RegServiceModel

... ... @@ -8,7 +8,7 @@
'use strict';
const helpers = global.yoho.helpers;
const RegService = require('../models/reg-service');
const RegServiceModel = require('../models/reg-service');
const BindService = require('../models/bind-service');
const AuthHelper = require('../models/auth-helper');
const _ = require('lodash');
... ... @@ -49,7 +49,7 @@ const bind = {
isWechatLogin: sourceType === 'wechat',
openId: openId, // openId
areaCode: '+86', // 默认区号
countrys: RegService.getAreaData(), // 国别码
countrys: req.ctx(RegServiceModel).getAreaData(), // 国别码
serviceUrl: serviceUrl, // 在线客服
module: 'passport',
page: 'bind',
... ...
const _ = require('lodash');
const co = Promise.coroutine;
const RegService = require('../models/reg-service');
const RegServiceModel = require('../models/reg-service');
const LoginNewModel = require('../models/login-new');
class Login {
... ... @@ -64,7 +64,7 @@ class Login {
localCss: true,
width750: true,
captchaShow: req.yoho.captchaShow,
countrys: RegService.getAreaData()
countrys: req.ctx(RegServiceModel).getAreaData()
});
}
}
... ...
const _ = require('lodash');
const url = require('url');
const helpers = global.yoho.helpers;
const RegService = require('../models/reg-service');
const RegServiceModel = require('../models/reg-service');
const utils = require(global.utils);
const sign = global.yoho.sign;
const co = require('bluebird').coroutine;
... ... @@ -54,7 +54,7 @@ class Reg {
let inviteCode = req.query.inviteCode;
if (inviteCode) {
let inviteUserInfo = yield RegService.inviteUserInfo(inviteCode);
let inviteUserInfo = yield req.ctx(RegServiceModel).inviteUserInfo(inviteCode);
inviteValue = _.get(inviteUserInfo, 'data.trendWord', inviteCode);
}
... ... @@ -65,7 +65,7 @@ class Reg {
localCss: true,
width750: true,
inviteValue: inviteValue,
countrys: RegService.getAreaData() // 地区信息列表
countrys: req.ctx(RegServiceModel).getAreaData() // 地区信息列表
});
})().catch(next);
}
... ... @@ -109,7 +109,7 @@ class Reg {
}
co(function* () {
let validMobileCodeResult = yield RegService.validMobileCode(area, mobile, smsCode);
let validMobileCodeResult = yield req.ctx(RegServiceModel).validMobileCode(area, mobile, smsCode);
if (!validMobileCodeResult.code) {
return res.json(validMobileCodeResult);
... ... @@ -121,7 +121,7 @@ class Reg {
return res.json(validMobileCodeResult);
}
let regMobileAesResult = yield RegService.regMobileAes(area, mobile, password,
let regMobileAesResult = yield req.ctx(RegServiceModel).regMobileAes(area, mobile, password,
shoppingKey, smsCode, inviteCode, isFromMy, from);
if (regMobileAesResult.code !== 200 || !regMobileAesResult.data ||
... ... @@ -192,7 +192,7 @@ class Reg {
// 向手机发送注册验证码
RegService.sendCodeToMobile(area, mobile).then((result) => {
req.ctx(RegServiceModel).sendCodeToMobile(area, mobile).then((result) => {
if (result.code !== 200) {
data.message = result.message;
return res.json(data);
... ...
... ... @@ -6,7 +6,7 @@ const moment = require('moment');
const cookie = global.yoho.cookie;
const EventEmitter = require('events');
const utils = require(global.utils);
const RegService = require('../models/reg-service');
const RegServiceModel = require('../models/reg-service');
const PhoneService = require('../models/phone-service');
const AuthHelper = require('../models/auth-helper');
const LoginNewModel = require('../models/login-new');
... ... @@ -41,7 +41,7 @@ class SmsLogin {
width750: true,
localCss: true,
banner: banner,
countrys: RegService.getAreaData(), // 地区信息列表
countrys: req.ctx(RegServiceModel).getAreaData(), // 地区信息列表
backUrl: 'javascript:history.go(-1)', // eslint-disable-line
loginUrl: '/passport/login',
registerUrl: '/passport/reg/index', // 注册的URL链接
... ... @@ -334,7 +334,7 @@ class SmsLogin {
// 验证注册的标识码是否有效
let resultCopy = null;
RegService.regMobileAes(area, mobile, password,
req.ctx(RegServiceModel).regMobileAes(area, mobile, password,
shoppingKey, registerCode, null, clientIp, from).then(result => {
if (!result.code || result.code !== 200) {
return res.send(result);
... ...
... ... @@ -6,12 +6,14 @@
*/
'use strict';
const api = global.yoho.API;
const aes = require('./aes-pwd');
const FROM = require('../../../config/from');
const RegService = {
class RegServiceModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getAreaData() {
return [
{
... ... @@ -63,26 +65,27 @@ const RegService = {
selected: false,
name: '中国香港'
}];
},
}
sendCodeToMobile(area, mobile) {
let params = {
return this.post({data: {
method: 'app.register.sendRegCodeToMobile',
area: area,
mobile: mobile
};
}});
}
return api.post('', params);
},
validMobileCode(area, mobile, code) {
let params = {
return this.post({
data: {
method: 'app.register.validRegCode',
area: area,
mobile: mobile,
code: code
};
}
});
}
return api.post('', params);
},
regMobile(area, mobile, password, shoppingKey) {
let params = {
method: 'app.passport.register',
... ... @@ -95,8 +98,9 @@ const RegService = {
params.shopping_key = shoppingKey;
}
return api.post('', params);
},
return this.post({ data: params});
}
regMobileAes(area, mobile, password, shoppingKey, smsCode, inviteCode, isFromMy, clientIp, from) {
isFromMy = isFromMy || '0';
... ... @@ -115,24 +119,22 @@ const RegService = {
params.shopping_key = shoppingKey;
}
return api.post('', params, {
headers: {
'user-agent': 'yoho/nodejs',
'X-YOHO-IP': clientIp,
'X-Forwarded-For': clientIp
}
return this.post({
data: params
});
},
}
/**
* 好友邀请信息
*/
inviteUserInfo(inviteCode) {
return api.get('', {
return this.get({
data: {
method: 'app.invitecode.userinfo',
inviteCode: inviteCode
}
});
}
};
}
module.exports = RegService;
module.exports = RegServiceModel;
... ...