youdas/common/server/user.js
2025-06-21 23:03:06 +08:00

53 lines
1.4 KiB
JavaScript

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;
}