auth.js
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import request from '@/sheep/request';
const AuthUtil = {
// 使用手机 + 密码登录
loginByPhonePassword: (data) => {
return request({
url: '/app/auth/loginByPhonePassword',
method: 'POST',
data,
custom: {
showSuccess: true,
successMsg: '登录成功',
},
});
},
// 使用手机 + 验证码登录
loginBySms: (data) => {
return request({
url: '/app/auth/loginBySms',
method: 'POST',
data,
custom: {
showSuccess: true,
successMsg: '登录成功',
},
});
},
// 发送手机验证码
sendSmsCode: (data) => {
return request({
url: '/app/auth/sendSmsCode',
method: 'POST',
data,
custom: {
showLoading: false,
},
});
},
// 登出系统
logout: () => {
return request({
url: '/app/auth/logout',
method: 'POST',
custom: {
showLoading: false, // 不用加载中
showError: false, // 不展示错误提示
},
});
},
// 刷新令牌
refreshToken: (refreshToken) => {
return request({
url: '/app/auth/refreshToken',
method: 'POST',
params: {
refreshToken,
},
custom: {
showLoading: false, // 不用加载中
showError: false, // 不展示错误提示
},
});
},
// 重置密码
setPassword: (data) => {
return request({
url: '/app/auth/setPassword',
method: 'POST',
data,
});
},
// 社交授权的跳转
socialAuthRedirect: (type, redirectUri) => {
return request({
url: '/member/auth/social-auth-redirect',
method: 'GET',
params: {
type,
redirectUri,
},
custom: {
showSuccess: true,
loadingMsg: '登录中',
},
});
},
// 社交快捷登录
socialLogin: (type, code, state) => {
return request({
url: '/member/auth/social-login',
method: 'POST',
data: {
type,
code,
state,
},
custom: {
showSuccess: true,
loadingMsg: '登录中',
},
});
},
// 微信小程序的手机授权登录
weixinMiniAppLogin: (code, phone) => {
return request({
url: '/app/auth/loginByPhone',
method: 'POST',
data: {
code,
phone,
role: 1,
},
custom: {
showSuccess: true,
loadingMsg: '登录中',
successMsg: '登录成功',
},
});
},
// 微信小程序的一键登录
weixinMiniAppLoginByCode: (code) => {
return request({
url: '/app/auth/login',
method: 'POST',
data: {
code,
},
custom: {
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;