bind-service.js 1.13 KB
/**
 * 注册数据接口
 *
 * @author JiangFeng<jeff.jiang@yoho.cn>
 * @date 2016/06/21
 */

'use strict';

const _ = require('lodash');
const BindApi = require('./bind-api');
const CaptchaImgService = require('./captcha-img-service');

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);

        this.captchaService = new CaptchaImgService(ctx);
        this.bindApi = new BindApi(ctx);

        this.bindCheck = this.bindApi.bindCheck.bind(this.bindApi);
        this.checkBindCode = this.bindApi.checkBindCode.bind(this.bindApi);
        this.bindMobile = this.bindApi.bindMobile.bind(this.bindApi);
        this.relateMobile = this.bindApi.relateMobile.bind(this.bindApi);
        this.changeCheck = this.bindApi.changeCheck.bind(this.bindApi);
        this.changeMobile = this.bindApi.changeCheck.bind(this.bindApi);
    }

    async sendBindMsg(area, mobile, id, captcha) {
        let result = await this.bindApi.sendBindMsg(area, mobile, id, captcha);
        let captchaNeed = await this.captchaService.try();

        _.set(result, 'data.needCaptcha', captchaNeed);

        return result;
    }
};