Blame view

apps/passport/models/user-api.js 1.39 KB
htoooth authored
1 2 3 4 5
/**
 * Created by TaoHuang on 2016/6/17.
 */
'use strict';
htoooth authored
6 7
const _ = require('lodash');
const api = global.yoho.API;
htoooth authored
8 9 10 11 12
const EMPTY = {};

/**
 * 根据手机号获取用户信息
 */
htoooth authored
13
const findByMobileAsync = (area, mobile) => {
htoooth authored
14
htoooth authored
15
    return api.get('', {
htoooth authored
16 17 18
        mobile: mobile,
        area: area,
        method: 'app.passport.getProfileByMobile'
毕凯 authored
19 20
    }).then(result => {
        if (!result.code || result.code !== 200 || !result.data || _.isEmpty(result.data)) {
htoooth authored
21
            return EMPTY;
毕凯 authored
22 23 24 25 26 27
        }

        return result.data;
    }).catch(() => {
        return EMPTY;
    });
htoooth authored
28 29 30 31 32
};

/**
 * 根据邮箱获取用户信息
 */
htoooth authored
33 34
const findByEmailAsync = (email) => {
    return api.get('', {
htoooth authored
35 36
        email: email,
        method: 'app.passport.getProfileByEmail'
htoooth authored
37 38 39 40
    }).then(result => {
        if (!result.code || result.code !== 200 || !result.data || _.isEmpty(result.data)) {
            return EMPTY;
        }
htoooth authored
41
htoooth authored
42
        return result.data;
htoooth authored
43
htoooth authored
44 45 46 47 48 49 50 51 52 53 54 55
    }).catch(() => {
        return EMPTY;
    });
};

const profile = (uid) => {
    let param = {
        uid: uid,
        method: 'app.passport.profile'
    };

    return api.get('', param);
htoooth authored
56
};
htoooth authored
57
htoooth authored
58
m  
刘传洋 authored
59 60 61 62 63 64 65 66 67 68 69
const checkNoCertEmailUser = (uid) => {

    let param = {
        method: 'app.passport.checkIsNeedPopupRelated',
        uid: uid
    };

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

htoooth authored
70 71
module.exports = {
    findByMobileAsync,
htoooth authored
72
    findByEmailAsync,
m  
刘传洋 authored
73 74
    profile,
    checkNoCertEmailUser
htoooth authored
75
};