Merge pull request '登录免授权' (#14) from answer/zyEtMAll-mobile:wss into master

Reviewed-on: #14
This commit is contained in:
root 2025-06-09 05:12:40 +00:00
commit 7b4eaf3219

View File

@ -1,132 +1,148 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
const AuthUtil = { const AuthUtil = {
// 使用手机 + 密码登录 // 使用手机 + 密码登录
login: (data) => { login: (data) => {
return request({ return request({
url: '/member/auth/login', url: '/member/auth/login',
method: 'POST', method: 'POST',
data, data,
custom: { custom: {
showSuccess: true, showSuccess: true,
loadingMsg: '登录中', loadingMsg: '登录中',
successMsg: '登录成功', successMsg: '登录成功',
}, },
}); });
}, },
// 使用手机 + 验证码登录 // 使用手机 + 验证码登录
smsLogin: (data) => { smsLogin: (data) => {
return request({ return request({
url: '/member/auth/sms-login', url: '/member/auth/sms-login',
method: 'POST', method: 'POST',
data, data,
custom: { custom: {
showSuccess: true, showSuccess: true,
loadingMsg: '登录中', loadingMsg: '登录中',
successMsg: '登录成功', successMsg: '登录成功',
}, },
}); });
}, },
// 发送手机验证码 // 发送手机验证码
sendSmsCode: (mobile, scene) => { sendSmsCode: (mobile, scene) => {
return request({ return request({
url: '/member/auth/send-sms-code', url: '/member/auth/send-sms-code',
method: 'POST', method: 'POST',
data: { data: {
mobile, mobile,
scene, scene,
}, },
custom: { custom: {
loadingMsg: '发送中', loadingMsg: '发送中',
showSuccess: true, showSuccess: true,
successMsg: '发送成功', successMsg: '发送成功',
}, },
}); });
}, },
// 登出系统 // 登出系统
logout: () => { logout: () => {
return request({ return request({
url: '/member/auth/logout', url: '/member/auth/logout',
method: 'POST', method: 'POST',
}); });
}, },
// 刷新令牌 // 刷新令牌
refreshToken: (refreshToken) => { refreshToken: (refreshToken) => {
return request({ return request({
url: '/member/auth/refresh-token', url: '/member/auth/refresh-token',
method: 'POST', method: 'POST',
params: { params: {
refreshToken, refreshToken,
}, },
custom: { custom: {
loading: false, // 不用加载中 loading: false, // 不用加载中
showError: false, // 不展示错误提示 showError: false, // 不展示错误提示
}, },
}); });
}, },
// 社交授权的跳转 // 社交授权的跳转
socialAuthRedirect: (type, redirectUri) => { socialAuthRedirect: (type, redirectUri) => {
return request({ return request({
url: '/member/auth/social-auth-redirect', url: '/member/auth/social-auth-redirect',
method: 'GET', method: 'GET',
params: { params: {
type, type,
redirectUri, redirectUri,
}, },
custom: { custom: {
showSuccess: true, showSuccess: true,
loadingMsg: '登陆中', loadingMsg: '登陆中',
}, },
}); });
}, },
// 社交快捷登录 // 社交快捷登录
socialLogin: (type, code, state) => { socialLogin: (type, code, state) => {
return request({ return request({
url: '/member/auth/social-login', url: '/member/auth/social-login',
method: 'POST', method: 'POST',
data: { data: {
type, type,
code, code,
state, state,
}, },
custom: { custom: {
showSuccess: true, showSuccess: true,
loadingMsg: '登陆中', loadingMsg: '登陆中',
}, },
}); });
}, },
// 微信小程序的一键登录 // 查询
weixinMiniAppLogin: (phoneCode, loginCode, state) => { checkLogin: (type, code, state) => {
return request({ return request({
url: '/member/auth/weixin-mini-app-login', url: '/member/auth/checkLogin',
method: 'POST', method: 'POST',
data: { data: {
phoneCode, type,
loginCode, code,
state, state,
}, },
custom: { custom: {
showSuccess: true, showSuccess: true,
loadingMsg: '登陆中', // loadingMsg: '查询中',
successMsg: '登录成功', },
}, });
}); },
}, // 微信小程序的一键登录
// 创建微信 JS SDK 初始化所需的签名 weixinMiniAppLogin: (phoneCode, loginCode, state) => {
createWeixinMpJsapiSignature: (url) => { return request({
return request({ url: '/member/auth/weixin-mini-app-login',
url: '/member/auth/create-weixin-jsapi-signature', method: 'POST',
method: 'POST', data: {
params: { phoneCode,
url, loginCode,
}, state,
custom: { },
showError: false, custom: {
showLoading: false, showSuccess: true,
}, loadingMsg: '登陆中',
}); successMsg: '登录成功',
}, },
// });
},
// 创建微信 JS SDK 初始化所需的签名
createWeixinMpJsapiSignature: (url) => {
return request({
url: '/member/auth/create-weixin-jsapi-signature',
method: 'POST',
params: {
url,
},
custom: {
showError: false,
showLoading: false,
},
});
},
//
}; };
export default AuthUtil; export default AuthUtil;