OfficeSystem/api/user.js
2025-11-13 14:52:54 +08:00

75 lines
1.4 KiB
JavaScript

/**
* 用户相关 API
*/
/**
* 获取用户信息
* @returns {Promise} 返回用户信息
*/
export const getUserInfo = () => {
return uni.$uv.http.get('/getInfo', {
custom: {
auth: true // 启用 token 认证
}
});
};
/**
* 获取验证码图片
* @returns {Promise<{img: string, uuid: string, captchaEnabled: boolean}>}
*/
export const getCaptchaImage = () => {
return uni.$uv.http.get('/captchaImage', {
// 验证码无需 token
custom: {
auth: false,
toast: false
}
});
};
/**
* 登录
* @param {Object} payload 登录参数
* @param {string} payload.username 用户名
* @param {string} payload.password 密码
* @param {string} [payload.code] 验证码
* @param {string} [payload.uuid] 验证码唯一标识
* @returns {Promise<any>} 登录结果
*/
export const login = (payload) => {
return uni.$uv.http.post('/login', payload, {
custom: {
auth: false,
catch: true,
toast: false
}
});
};
/**
* 退出登录
* @returns {Promise<any>} 退出结果
*/
export const logout = () => {
return uni.$uv.http.post('/logout', {}, {
custom: {
auth: true,
catch: true
}
});
};
/**
* 获取所有用户列表
* @returns {Promise<Array>} 返回用户列表
*/
export const getUserListAll = () => {
return uni.$uv.http.get('system/user/listAll', {
custom: {
auth: true // 启用 token 认证
}
});
};