login-api.js 1.19 KB
/**
 * Created by TaoHuang on 2016/7/25.
 */

'use strict';

const api = global.yoho.API;

const signinAsync = (area, profile, password, shoppingKey) => {
    let param = {
        method: 'app.passport.signin',
        area: area,
        profile: profile,
        password: password
    };

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

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

const signinByOtherOpenIDAsync = (nickname, openId, sourceType, shoppingKey) => {
    let param = {
        nickname: nickname,
        openId: openId,
        source_type: sourceType,
        method: 'app.passport.signinByOpenID'
    };

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

    return api.get('', param);
};

const signinByWechatAsync = (nickname, openId, sourceType, shoppingKey, unionId) => {
    let param = {
        nickname: nickname,
        openId: openId,
        unionId: unionId,
        source_type: sourceType,
        method: 'app.passport.signinByWechat'
    };

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

    return api.get('', param);
};

module.exports = {
    signinAsync,
    signinByOtherOpenIDAsync,
    signinByWechatAsync
};