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

'use strict';

const api = global.yoho.API;

class RegService {

    static 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: '中国香港'
            }];
    }

    static sendCodeToMobile(area, mobile) {
        let params = {
            method: 'app.register.sendRegCodeToMobile',
            area: area,
            mobile: mobile
        };

        return api.post('', params);
    }

    static validMobileCode(area, mobile, code) {
        let params = {
            method: 'app.register.validRegCode',
            area: area,
            mobile: mobile,
            code: code
        };

        return api.post('', params);
    }

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

        if (shoppingKey) {
            params.shopping_key = shoppingKey; // esline-disable-line
        }

        return api.post('', params);
    }
}

module.exports = RegService;