File tree Expand file tree Collapse file tree 2 files changed +27
-15
lines changed Expand file tree Collapse file tree 2 files changed +27
-15
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ import { http } from '@/http/http'
7
7
export interface ILoginForm {
8
8
username : string
9
9
password : string
10
- code : string
11
- uuid : string
10
+ code ? : string
11
+ uuid ? : string
12
12
}
13
13
14
14
/**
Original file line number Diff line number Diff line change @@ -26,23 +26,35 @@ onLoad((options) => {
26
26
27
27
const userStore = useUserStore ()
28
28
const tokenStore = useTokenStore ()
29
- function doLogin() {
29
+ async function doLogin() {
30
30
if (tokenStore .hasLogin ) {
31
31
uni .navigateBack ()
32
32
return
33
33
}
34
- userStore .setUserInfo ({
35
- userId: 123456 ,
36
- username: ' abc123456' ,
37
- nickname: ' 菲鸽' ,
38
- avatar: ' https://oss.laf.run/ukw0y1-site/avatar.jpg' ,
39
- })
40
- // 这里用单token来模拟
41
- tokenStore .setTokenInfo ({
42
- token: ' 123456' ,
43
- expiresIn: 60 * 60 * 24 * 7 ,
44
- })
45
- console .log (redirectUrl .value )
34
+ try {
35
+ // 1/2 调用接口回来后设置用户信息
36
+ // const res = await login({
37
+ // username: '菲鸽',
38
+ // password: '123456',
39
+ // })
40
+ // console.log('接口拿到的登录信息:', res)
41
+ userStore .setUserInfo ({
42
+ userId: 123456 ,
43
+ username: ' abc123456' ,
44
+ nickname: ' 菲鸽' ,
45
+ avatar: ' https://oss.laf.run/ukw0y1-site/avatar.jpg' ,
46
+ })
47
+ // 2/2 调用接口回来后设置token信息
48
+ // 这里用单token来模拟
49
+ tokenStore .setTokenInfo ({
50
+ token: ' 123456' ,
51
+ expiresIn: 60 * 60 * 24 * 7 ,
52
+ })
53
+ console .log (redirectUrl .value )
54
+ }
55
+ catch (error ) {
56
+ console .log (' 登录失败' , error )
57
+ }
46
58
let path = redirectUrl .value
47
59
if (! path .startsWith (' /' )) {
48
60
path = ` /${path } `
You can’t perform that action at this time.
0 commit comments