
import RequestManager from '../request';
import common from '../common';
/**
 * 获取用户信息
 * @returns {Promise}
 */
export const getUserInfo = async () => {
    const res = await RequestManager.get('/userInfo');
    if (res.status == 1) {
        res.data.money = common.removeTrailingZeros(res.data.money);
        res.data.integral = common.removeTrailingZeros(res.data.integral);
        res.data.money2 = common.removeTrailingZeros(res.data.money2);
        return res.data;
    } else {
        return null;
    }
};

/**
 * 微信APP登录
 * @param {String} unionId 微信APP unionId
 * @param {String} nickname 微信APP 昵称
 * @param {String} headimg 微信APP 头像
 * @param {Number} pid 推广码
 * @returns {Promise} 是否成功
 */
export const wxAppLogin = async (unionId, nickname, headimg, pid = 0) => {
    const res = await RequestManager.post('/wx_app_login', { unionId, nickname, headimg, pid });
    return res;
}