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
488c97d8
Commit
488c97d8
authored
Aug 19, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user
parent
53739a2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
70 deletions
+68
-70
user.js
stores/user.js
+68
-70
No files found.
stores/user.js
View file @
488c97d8
...
...
@@ -21,7 +21,7 @@ export const useUserStore = defineStore("userInfo", {
babyInfo
:
null
,
memberInfo
:
null
,
babyNickCache
:
[],
cepingjieguoInfo
:
null
,
cepingjieguoInfo
:
null
,
};
},
actions
:
{
...
...
@@ -63,7 +63,7 @@ export const useUserStore = defineStore("userInfo", {
* @param {Object} data : {encryptedData, iv, code}
* @returns
*/
async
phoneCallback
(
data
,
onOpenRegisterFn
=
()
=>
{})
{
async
phoneCallback
(
data
,
onOpenRegisterFn
=
()
=>
{
})
{
uni
.
login
({
provider
:
"weixin"
,
success
:
async
(
res
)
=>
{
...
...
@@ -140,65 +140,65 @@ export const useUserStore = defineStore("userInfo", {
// }
// }
// },
async
loadBabyInfo
(
retryCount
=
0
)
{
const
MAX_RETRIES
=
3
;
const
RETRY_DELAY
=
1000
;
// 1 second
try
{
const
{
data
}
=
await
fetchBabyInfo
();
console
.
log
(
"babyInfo-宝宝信息"
,
data
);
if
(
data
?.
memberId
!==
"not_login"
)
{
async
loadBabyInfo
(
retryCount
=
0
)
{
const
MAX_RETRIES
=
3
;
const
RETRY_DELAY
=
1000
;
// 1 second
try
{
const
{
data
}
=
await
fetchBabyInfo
();
console
.
log
(
"babyInfo-宝宝信息"
,
data
);
if
(
data
?.
memberId
!==
"not_login"
)
{
this
.
babyInfo
=
data
;
if
(
data
.
allBabyBaseInfo
)
{
if
(
data
.
allBabyBaseInfo
)
{
if
(
this
.
babyInfo
.
babyAge
==
"0月龄"
)
{
this
.
babyInfo
.
babyAge
=
"1月龄"
;
}
console
.
log
(
"this.11111"
,
this
.
babyNickCache
,
data
?.
content
?.
id
);
const
findItem
=
this
.
babyNickCache
.
find
(
(
item
)
=>
item
.
id
==
data
?.
content
?.
id
);
if
(
data
?.
content
?.
id
&&
findItem
)
{
this
.
babyInfo
.
babyName
=
findItem
.
name
;
this
.
babyInfo
.
allBabyBaseInfo
.
forEach
((
item
)
=>
{
if
(
item
.
id
==
data
?.
content
?.
id
)
{
item
.
babyName
=
findItem
.
name
;
}
});
}
return
;
// Success case, exit the function
}
else
{
console
.
log
(
"this.babyInfo"
,
'重新请求接口'
);
if
(
retryCount
<
MAX_RETRIES
-
1
)
{
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
RETRY_DELAY
));
return
this
.
loadBabyInfo
(
retryCount
+
1
);
}
else
{
console
.
log
(
"Max retries reached, giving up"
);
// Show user notification when max retries reached
// uni.showToast({
// title: "系统繁忙,请稍后再试",
// icon: "none",
// });
}
}
}
}
catch
(
error
)
{
console
.
log
(
"🚀 ~ loadBabyInfo ~ error:"
,
error
);
if
(
retryCount
>=
MAX_RETRIES
-
1
)
{
// Show user notification when max retries reached with error
uni
.
showToast
({
title
:
"系统繁忙,请稍后再试"
,
icon
:
"none"
,
});
}
}
},
console
.
log
(
"this.11111"
,
this
.
babyNickCache
,
data
?.
content
?.
id
);
const
findItem
=
this
.
babyNickCache
.
find
(
(
item
)
=>
item
.
id
==
data
?.
content
?.
id
);
if
(
data
?.
content
?.
id
&&
findItem
)
{
this
.
babyInfo
.
babyName
=
findItem
.
name
;
this
.
babyInfo
.
allBabyBaseInfo
.
forEach
((
item
)
=>
{
if
(
item
.
id
==
data
?.
content
?.
id
)
{
item
.
babyName
=
findItem
.
name
;
}
});
}
return
;
// Success case, exit the function
}
else
{
console
.
log
(
"this.babyInfo"
,
'重新请求接口'
);
if
(
retryCount
<
MAX_RETRIES
-
1
)
{
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
RETRY_DELAY
));
return
this
.
loadBabyInfo
(
retryCount
+
1
);
}
else
{
console
.
log
(
"Max retries reached, giving up"
);
// Show user notification when max retries reached
// uni.showToast({
// title: "系统繁忙,请稍后再试",
// icon: "none",
// });
}
}
}
}
catch
(
error
)
{
console
.
log
(
"🚀 ~ loadBabyInfo ~ error:"
,
error
);
if
(
retryCount
>=
MAX_RETRIES
-
1
)
{
// Show user notification when max retries reached with error
uni
.
showToast
({
title
:
"系统繁忙,请稍后再试"
,
icon
:
"none"
,
});
}
}
},
/**
* 获取用户积分信息
*/
...
...
@@ -228,7 +228,7 @@ export const useUserStore = defineStore("userInfo", {
console
.
log
(
"autoLoginByCode"
,
data
);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if
(
data
&&
data
.
cuk
)
{
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
await
this
.
loadUserInfo
();
await
this
.
loadBabyInfo
();
...
...
@@ -236,10 +236,10 @@ export const useUserStore = defineStore("userInfo", {
}
},
/**
* 用户自动登录
*/
async
wxAutoLogin
(
cb
=
null
)
{
/**
* 用户自动登录
*/
async
wxAutoLogin
(
cb
=
null
)
{
uni
.
login
({
provider
:
"weixin"
,
success
:
async
(
res
)
=>
{
...
...
@@ -264,19 +264,17 @@ export const useUserStore = defineStore("userInfo", {
* @param {sy使用}
* @returns
*/
async
syWxAutoLogin
(
cb
=
null
)
{
async
syWxAutoLogin
(
cb
=
null
)
{
uni
.
login
({
provider
:
"weixin"
,
success
:
async
(
res
)
=>
{
console
.
log
(
"wxAutoLogin"
,
res
);
if
(
res
.
errMsg
===
"login:ok"
)
{
const
{
data
}
=
await
autoLoginByCode
(
code
);
console
.
log
(
"autoLoginByCode"
,
data
);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if
(
data
&&
data
.
cuk
)
{
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
cb
&&
cb
();
}
const
{
data
}
=
await
autoLoginByCode
(
res
.
code
);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if
(
data
&&
data
.
cuk
)
{
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
cb
&&
cb
();
}
}
else
{
uni
.
showToast
({
title
:
res
.
errMsg
,
...
...
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