scan the QR code to log in on the WeChat public account

This commit is contained in:
landaiqing
2024-08-15 23:57:12 +08:00
parent cab3b1ee96
commit 3140eaca99
11 changed files with 432 additions and 45 deletions

37
src/api/oauth/index.ts Normal file
View File

@@ -0,0 +1,37 @@
import {service} from "@/utils/alova/service.ts";
/**
* 生成客户端id
*/
export const generateClientId = () => {
return service.Get('/api/oauth/generate_client_id',
{
meta: {
ignoreToken: true,
}
}
);
};
/**
* 获取临时二维码
* @param clientId
*/
export const generateQrCode = (clientId: string) => {
return service.Get('/api/oauth/get_temp_qrcode',
{
params: {
client_id: clientId
},
meta: {
ignoreToken: true,
},
cacheFor: {
// 设置缓存模式为持久化模式
mode: 'restore',
// 缓存时间
expire: 30 * 24 * 60 * 60 * 1000,
tag: 'v1'
}
}
);
};

View File

@@ -1,5 +1,5 @@
import {service} from "@/utils/alova/service.ts";
import {PhoneLogin} from "@/types/user";
import {AccountLogin, PhoneLogin, ResetPassword} from "@/types/user";
/**
* 获取用户信息
@@ -64,3 +64,38 @@ export const phoneLoginApi = (param: PhoneLogin) => {
}
);
};
/**
* 账号登录
* @param param
*/
export const accountLoginApi = (param: AccountLogin) => {
return service.Post('/api/user/login', {
account: param.account,
password: param.password,
},
{
meta: {
ignoreToken: true,
authRole: 'login'
}
}
);
};
/**
* 重置密码
* @param param
*/
export const resetPasswordApi = (param: ResetPassword) => {
return service.Post('/api/user/reset_password', {
phone: param.phone,
captcha: param.captcha,
password: param.password,
repassword: param.repassword
},
{
meta: {
ignoreToken: true,
}
}
);
};