youdas/common/server/user.js
2025-06-22 00:59:30 +08:00

70 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import HttpRequest from "../system/request";
import { decryptRouteMap } from "../system/routeMap";
/**
* 获取用户信息
* @returns {Promise} 用户信息
*/
export const getUserInfo = async () => {
const res = await HttpRequest.get('/userInfo');
if (res.status == 1) {
let userInfo = res.data;
if (userInfo.other != null && userInfo.other != undefined) {
userInfo.other = decryptRouteMap(userInfo.other);
userInfo['currency1'] = userInfo.other['a'];
userInfo['currency2'] = userInfo.other['b'];
userInfo['currency3'] = userInfo.other['c'];
userInfo['uid'] = userInfo.other['uid'];
userInfo['pid'] = userInfo.other['pid'];
delete userInfo.other;
}
console.log("userInfo", userInfo);
return userInfo;
}
return null;
}
/**
* 申请注销账号
* @returns {Promise} 是否成功
*/
export const deleteAccount = async () => {
const res = await HttpRequest.post('/deleteAccount');
return res;
}
/**
* 手机号登录
* @param {String} phone 手机号
* @param {String} code 验证码
* @param {String} pid 推广码
* @returns {Promise} 是否成功
*/
export const mobileLogin = async (phone, code, pid = 0) => {
const res = await HttpRequest.post('/mobileLogin', {
mobile: phone,
code: code,
pid: pid
});
return res;
}
/**
* 修改用户信息
* @param {String} nickname 昵称
* @param {String} avatar 头像
* @param {String} imagebase 图片base64
* @param {Number} gender 性别(1-男2-女3-保密0-未设置)
* @returns {Promise} 是否成功
*/
export const updateUserInfo = async (nickname, avatar, imagebase, gender = 3) => {
const res = await HttpRequest.post('/update_userinfo', {
nickname,
headimg: avatar,
imagebase,
gender
});
return res.status == 1;
}