reg-service.js
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* 注册 model
*/
'use strict';
const passportHelper = require('./passport-helper');
const Api = require('./reg-api');
const CaptchaServiceModel = require('./captcha-img-service');
const _ = require('lodash');
const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064'; // 注册左边的banner
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.api = new Api(ctx);
this.captchaService = new CaptchaServiceModel(ctx);
this.sendCodeToMobile = this.api.sendCodeToMobile.bind(this.api);
this.regMobileAes = this.api.regMobileAes.bind(this.api);
}
getRegData() {
return passportHelper.getLeftBannerAsync(REGISTER_LEFT_BANNER_CODE);
}
async validMobileCode(area, mobile, code) {
let result = await this.api.validMobileCode(area, mobile, code);
let captchaNeeded = await this.captchaService.try();
_.set(result, 'data.needCaptcha', captchaNeeded);
return result;
}
};