Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
飞
飞鹤小程序
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
FH
飞鹤小程序
Commits
b79ddd57
Commit
b79ddd57
authored
Oct 15, 2025
by
chenkai@duiba.com.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkLogin加了个回调
parent
252275fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
34 deletions
+58
-34
.DS_Store
.DS_Store
+0
-0
register.vue
pages/activity/register.vue
+2
-0
user.js
stores/user.js
+38
-30
checkLogin.js
utils/checkLogin.js
+18
-4
No files found.
.DS_Store
View file @
b79ddd57
No preview for this file type
pages/activity/register.vue
View file @
b79ddd57
...
@@ -25,6 +25,8 @@ async function onRegisterConfirm(data) {
...
@@ -25,6 +25,8 @@ async function onRegisterConfirm(data) {
userStore
.
loadUserInfo
(),
userStore
.
loadUserInfo
(),
])
])
//用户信息更新,抛出事件
uni
.
$emit
(
"updateUserInfo"
);
uni
.
navigateBack
({
uni
.
navigateBack
({
delta
:
1
delta
:
1
})
})
...
...
stores/user.js
View file @
b79ddd57
...
@@ -21,31 +21,31 @@ import md from "../md.js";
...
@@ -21,31 +21,31 @@ import md from "../md.js";
const
globalStore
=
useGlobalStore
();
const
globalStore
=
useGlobalStore
();
export
const
useUserStore
=
defineStore
(
"userInfo"
,
{
export
const
useUserStore
=
defineStore
(
"userInfo"
,
{
state
:
()
=>
{
state
:
()
=>
{
return
{
return
{
userInfo
:
null
,
userInfo
:
null
,
babyInfo
:
null
,
babyInfo
:
null
,
memberInfo
:
null
,
memberInfo
:
null
,
babyNickCache
:
[],
babyNickCache
:
[],
cepingjieguoInfo
:
null
,
cepingjieguoInfo
:
null
,
};
};
},
},
getters
:
{
getters
:
{
isLogin
:
(
state
)
=>
{
isLogin
:
(
state
)
=>
{
return
state
.
userInfo
?.
memberId
!==
"not_login"
return
state
.
userInfo
?.
memberId
!==
"not_login"
}
}
},
},
actions
:
{
actions
:
{
/**
/**
* 更新用户信息
* 更新用户信息
* @param {Object} userInfo
* @param {Object} userInfo
*/
*/
setUserInfo
(
userInfo
)
{
setUserInfo
(
userInfo
)
{
this
.
userInfo
=
userInfo
;
this
.
userInfo
=
userInfo
;
},
},
setMemberInfo
(
memberInfo
)
{
setMemberInfo
(
memberInfo
)
{
this
.
memberInfo
=
memberInfo
;
this
.
memberInfo
=
memberInfo
;
},
},
/**
/**
* 更新宝宝信息
* 更新宝宝信息
...
@@ -76,8 +76,7 @@ export const useUserStore = defineStore("userInfo", {
...
@@ -76,8 +76,7 @@ export const useUserStore = defineStore("userInfo", {
* @param {Object} data : {encryptedData, iv, code}
* @param {Object} data : {encryptedData, iv, code}
* @returns
* @returns
*/
*/
async
phoneCallback
(
data
,
onOpenRegisterFn
=
()
=>
{
async
phoneCallback
(
data
,
onOpenRegisterFn
=
()
=>
{},
cb
=
null
,
cb2
=
null
,
invitationInfo
=
null
)
{
},
cb
=
null
,
cb2
=
null
,
invitationInfo
=
null
)
{
uni
.
login
({
uni
.
login
({
provider
:
"weixin"
,
provider
:
"weixin"
,
success
:
async
(
res
)
=>
{
success
:
async
(
res
)
=>
{
...
@@ -85,7 +84,9 @@ export const useUserStore = defineStore("userInfo", {
...
@@ -85,7 +84,9 @@ export const useUserStore = defineStore("userInfo", {
if
(
res
.
errMsg
===
"login:ok"
)
{
if
(
res
.
errMsg
===
"login:ok"
)
{
// 用户手机授权F
// 用户手机授权F
const
{
const
{
data
:
{
babyExistence
}
data
:
{
babyExistence
}
}
=
await
fetchAutoPhone
({
}
=
await
fetchAutoPhone
({
phoneEncryptedData
:
data
.
encryptedData
,
phoneEncryptedData
:
data
.
encryptedData
,
phoneIv
:
data
.
iv
,
phoneIv
:
data
.
iv
,
...
@@ -126,6 +127,7 @@ export const useUserStore = defineStore("userInfo", {
...
@@ -126,6 +127,7 @@ export const useUserStore = defineStore("userInfo", {
// 缓存用户memberId
// 缓存用户memberId
uni
.
setStorageSync
(
'memberId'
,
data
?.
memberId
)
uni
.
setStorageSync
(
'memberId'
,
data
?.
memberId
)
}
}
uni
.
setStorageSync
(
'loginStatus'
,
data
?.
memberId
==
"not_login"
?
0
:
1
)
this
.
userInfo
=
data
;
this
.
userInfo
=
data
;
},
},
...
@@ -171,7 +173,9 @@ export const useUserStore = defineStore("userInfo", {
...
@@ -171,7 +173,9 @@ export const useUserStore = defineStore("userInfo", {
const
RETRY_DELAY
=
1000
;
// 1 second
const
RETRY_DELAY
=
1000
;
// 1 second
try
{
try
{
const
{
data
}
=
await
fetchBabyInfo
();
const
{
data
}
=
await
fetchBabyInfo
();
console
.
log
(
"babyInfo-宝宝信息"
,
data
);
console
.
log
(
"babyInfo-宝宝信息"
,
data
);
if
(
data
?.
memberId
!==
"not_login"
)
{
if
(
data
?.
memberId
!==
"not_login"
)
{
...
@@ -299,7 +303,9 @@ export const useUserStore = defineStore("userInfo", {
...
@@ -299,7 +303,9 @@ export const useUserStore = defineStore("userInfo", {
provider
:
"weixin"
,
provider
:
"weixin"
,
success
:
async
(
res
)
=>
{
success
:
async
(
res
)
=>
{
if
(
res
.
errMsg
===
"login:ok"
)
{
if
(
res
.
errMsg
===
"login:ok"
)
{
const
{
data
}
=
await
autoLoginByCode
(
res
.
code
);
const
{
data
}
=
await
autoLoginByCode
(
res
.
code
);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if
(
data
&&
data
.
cuk
)
{
if
(
data
&&
data
.
cuk
)
{
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
...
@@ -329,7 +335,9 @@ export const useUserStore = defineStore("userInfo", {
...
@@ -329,7 +335,9 @@ export const useUserStore = defineStore("userInfo", {
provider
:
"weixin"
,
provider
:
"weixin"
,
success
:
async
(
res
)
=>
{
success
:
async
(
res
)
=>
{
if
(
res
.
errMsg
===
"login:ok"
)
{
if
(
res
.
errMsg
===
"login:ok"
)
{
const
{
data
}
=
await
autoLoginByCode
(
res
.
code
);
const
{
data
}
=
await
autoLoginByCode
(
res
.
code
);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if
(
data
&&
data
.
cuk
)
{
if
(
data
&&
data
.
cuk
)
{
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
...
...
utils/checkLogin.js
View file @
b79ddd57
import
{
JumpType
,
jump
}
from
"."
;
import
{
JumpType
,
jump
}
from
"."
;
import
{
import
{
useUserStore
useUserStore
}
from
"../stores/user"
;
}
from
"../stores/user"
;
export
function
checkLogin
()
{
export
function
checkLogin
(
back
)
{
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
memberInfo
=
userStore
.
memberInfo
;
const
memberInfo
=
userStore
.
memberInfo
;
if
(
!
memberInfo
?.
value
?.
memberId
||
memberInfo
?.
value
?.
memberId
==
"not_login"
)
{
//未登录
if
(
!
memberInfo
?.
memberId
||
memberInfo
?.
memberId
==
"not_login"
)
{
//未登录
jump
({
jump
({
type
:
JumpType
.
INNER
,
type
:
JumpType
.
INNER
,
url
:
"/pages/activity/register"
,
url
:
"/pages/activity/register"
})
// 监听用户信息更新
uni
.
$once
(
'updateUserInfo'
,
()
=>
{
if
(
back
)
{
back
();
}
})
})
return
}
if
(
back
)
{
back
();
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment