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

'use strict';
const aes = require('./aes-pwd');
const FROM = require('../../../config/from');
const PAGE = 'H5';

class RegServiceModel extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    getAreaData() {
        return [
            {
                areaCode: '+61',
                selected: false,
                name: '澳大利亚'
            }, {
                areaCode: '+82',
                selected: false,
                name: '韩国'
            }, {
                areaCode: '+1',
                selected: false,
                name: '加拿大'
            }, {
                areaCode: '+60',
                selected: false,
                name: '马来西亚'
            }, {
                areaCode: '+1',
                selected: false,
                name: '美国'
            }, {
                areaCode: '+81',
                selected: false,
                name: '日本'
            }, {
                areaCode: '+65',
                selected: false,
                name: '新加坡'
            }, {
                areaCode: '+44',
                selected: false,
                name: '英国'
            }, {
                areaCode: '+86',
                selected: true, // default choose
                name: '中国'
            }, {
                areaCode: '+853',
                selected: false,
                name: '中国澳门'
            }, {
                areaCode: '+886',
                selected: false,
                name: '中国台湾'
            }, {
                areaCode: '+852',
                selected: false,
                name: '中国香港'
            }];
    }

    sendCodeToMobile(params) {
        return this.post({data: {
            method: 'app.register.sendRegCodeToMobile',
            area: params.area,
            mobile: params.mobile,
            udid: params.udid,
            fromPage: PAGE,
            degrees: params.captcha,
            superCapture: params.superCapture
        }});
    }

    validMobileCode(area, mobile, code) {
        return this.post({
            data: {
                method: 'app.register.validRegCode',
                area: area,
                mobile: mobile,
                code: code
            }
        });
    }

    regMobile(area, mobile, password, shoppingKey) {
        let params = {
            method: 'app.passport.register',
            area: area,
            profile: mobile,
            password: password
        };

        if (shoppingKey) {
            params.shopping_key = shoppingKey;
        }

        return this.post({ data: params});
    }

    regMobileAes(area, mobile, password, shoppingKey, smsCode, inviteCode, isFromMy, clientIp, from) {
        isFromMy = isFromMy || '0';

        let params = {
            method: 'app.passport.registerAES',
            area: area,
            profile: mobile,
            password: aes.aesPwd(password),
            verifyCode: smsCode,
            inviteCode: inviteCode,
            isFromMy,
            business_line: FROM[from].business_line
        };

        if (shoppingKey) {
            params.shopping_key = shoppingKey;
        }

        return this.post({
            data: params
        });
    }

    /**
    * 好友邀请信息
    */
    inviteUserInfo(inviteCode) {
        return this.get({
            data: {
                method: 'app.invitecode.userinfo',
                inviteCode: inviteCode
            }
        });
    }
}

module.exports = RegServiceModel;