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
9c7f07b8
Commit
9c7f07b8
authored
Sep 25, 2025
by
lg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: activity/index支持传入url打开
parent
6465f253
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
415 additions
and
368 deletions
+415
-368
index.vue
pages/activity/index.vue
+49
-16
gen-webview-urls.js
scripts/gen-webview-urls.js
+16
-10
user.js
stores/user.js
+350
-342
No files found.
pages/activity/index.vue
View file @
9c7f07b8
...
@@ -7,16 +7,18 @@ import {ref, watch, nextTick} from "vue";
...
@@ -7,16 +7,18 @@ import {ref, watch, nextTick} from "vue";
import
{
onLoad
,
onShow
,
onShareAppMessage
,
onShareTimeline
}
from
"@dcloudio/uni-app"
;
import
{
onLoad
,
onShow
,
onShareAppMessage
,
onShareTimeline
}
from
"@dcloudio/uni-app"
;
import
{
useGlobalStore
}
from
"../../stores/global"
;
import
{
useGlobalStore
}
from
"../../stores/global"
;
import
{
useUserStore
}
from
"../../stores/user"
;
import
{
useUserStore
}
from
"../../stores/user"
;
import
{
jump
,
JumpType
}
from
"../../utils"
;
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
globalStore
=
useGlobalStore
()
const
globalStore
=
useGlobalStore
()
function
getRegistered
()
{
function
getRegistered
()
{
return
userStore
?.
userInfo
?.
memberId
!
=
"not_login"
return
userStore
.
userInfo
?.
memberId
!=
=
"not_login"
}
}
const
pageOptions
=
ref
({})
const
src
=
ref
(
""
);
const
src
=
ref
(
""
);
const
registered
=
ref
(
getRegistered
()
)
const
registered
=
ref
(
false
)
const
urlMap
=
{
const
urlMap
=
{
//'main': 'http://192.168.0.5:8001/#/page',
//'main': 'http://192.168.0.5:8001/#/page',
...
@@ -29,8 +31,8 @@ onShow(() => {
...
@@ -29,8 +31,8 @@ onShow(() => {
registered
.
value
=
getRegistered
()
registered
.
value
=
getRegistered
()
})
})
watch
(()
=>
registered
.
value
,
(
newVal
)
=>
{
watch
(()
=>
registered
.
value
,
(
newVal
,
oldVal
)
=>
{
if
(
newVal
)
{
if
(
newVal
!==
oldVal
)
{
const
oldSrc
=
src
.
value
const
oldSrc
=
src
.
value
src
.
value
=
''
src
.
value
=
''
...
@@ -40,39 +42,70 @@ watch(() => registered.value, (newVal) => {
...
@@ -40,39 +42,70 @@ watch(() => registered.value, (newVal) => {
}
}
})
})
onLoad
((
options
)
=>
{
function
joinUrlAndQs
(
url
,
qs
)
{
console
.
log
(
'页面参数:'
,
options
)
return
qs
?
url
+
(
url
.
includes
(
'?'
)
?
(
url
.
endsWith
(
'?'
)
?
''
:
'&'
)
:
'?'
)
+
qs
:
url
}
wx
.
showShareMenu
(
{
function
initOk
()
{
withShareTicket
:
true
,
console
.
log
(
userStore
.
userInfo
)
menus
:
[
'shareAppMessage'
,
'shareTimeline'
]
}
)
registered
.
value
=
getRegistered
(
)
let
url
=
""
;
let
url
=
""
;
const
options
=
pageOptions
.
value
if
(
options
.
type
)
{
if
(
options
.
type
)
{
const
type
=
options
.
type
;
const
type
=
options
.
type
;
url
=
urlMap
[
type
];
url
=
urlMap
[
type
];
}
else
if
(
options
.
url
)
{
url
=
decodeURIComponent
(
options
.
url
)
}
}
const
params
=
{...(
options
||
{})}
const
params
=
{}
delete
params
.
type
delete
params
.
params
const
{
unionId
,
cuk
}
=
globalStore
const
{
unionId
,
cuk
}
=
globalStore
if
(
unionId
&&
!
params
.
unionId
)
params
.
unionId
=
unionId
if
(
unionId
&&
!
params
.
unionId
)
params
.
unionId
=
unionId
if
(
cuk
&&
!
params
.
cuk
)
params
.
cuk
=
cuk
if
(
cuk
&&
!
params
.
cuk
)
params
.
cuk
=
cuk
const
{
memberId
}
=
userStore
.
userInfo
if
(
memberId
)
params
.
crmId
=
memberId
const
paramStr
=
Object
.
keys
(
params
)
const
paramStr
=
Object
.
keys
(
params
)
.
filter
(
key
=>
params
[
key
]
!==
undefined
&&
params
[
key
]
!==
null
&&
params
[
key
]
!==
''
)
.
filter
(
key
=>
params
[
key
]
!==
undefined
&&
params
[
key
]
!==
null
&&
params
[
key
]
!==
''
)
.
map
(
key
=>
`
${
key
}
=
${
encodeURIComponent
(
params
[
key
])}
`
)
.
map
(
key
=>
`
${
key
}
=
${
encodeURIComponent
(
params
[
key
])}
`
)
.
join
(
'&'
)
.
join
(
'&'
)
url
=
paramStr
url
=
joinUrlAndQs
(
url
,
paramStr
)
?
url
+
(
url
.
includes
(
'?'
)
?
'&'
:
'?'
)
+
paramStr
+
(
options
.
params
?
'&'
+
decodeURIComponent
(
options
.
params
)
:
''
)
if
(
options
.
params
){
:
url
url
=
joinUrlAndQs
(
url
,
decodeURIComponent
(
options
.
params
))
}
src
.
value
=
url
src
.
value
=
url
console
.
log
(
'webview url:'
,
url
)
console
.
log
(
'webview url:'
,
url
)
}
onLoad
(
async
(
options
)
=>
{
pageOptions
.
value
=
options
console
.
log
(
'页面参数:'
,
options
)
wx
.
showShareMenu
({
withShareTicket
:
true
,
menus
:
[
'shareAppMessage'
,
'shareTimeline'
]
})
await
userStore
.
normalAutoLogin
()
await
userStore
.
loadUserInfo
()
if
(
!
registered
.
value
)
{
jump
({
type
:
JumpType
.
INNER
,
url
:
'/pages/activity/register'
,
})
}
else
{
initOk
()
}
});
});
function
onMessage
(
e
)
{
function
onMessage
(
e
)
{
...
...
scripts/gen-webview-urls.js
View file @
9c7f07b8
const
hosts
=
[
const
hosts
=
[
{
value
:
'https://guide-api.feihe.com'
,
alias
:
'生产环境'
},
{
value
:
'https://guide-api.feihe.com'
,
alias
:
'生产环境'
},
{
value
:
'https://guide-api-test.feihe.com'
,
alias
:
'test环境'
},
{
value
:
'https://guide-api-test.feihe.com'
,
alias
:
'test环境'
},
{
value
:
'https://guide-api-uat.feihe.com'
,
alias
:
'uat环境'
},
{
value
:
'https://guide-api-uat.feihe.com'
,
alias
:
'uat环境'
},
]
]
const
pages
=
[
const
pages
=
[
{
value
:
'/mini/#/page/momHome/index'
,
alias
:
'妈妈爱活动'
},
{
value
:
'/mini/#/page/momHome/index'
,
alias
:
'妈妈爱活动'
},
{
value
:
'/mini/#/page/home/index
'
,
alias
:
'路演活动'
},
{
value
:
'/mini/#/page/home/index?page_source=3
'
,
alias
:
'路演活动'
},
]
]
const
mpPage
=
'/pages/webview/webview'
const
mpPage
=
'pages/activity/index'
function
joinUrlAndQs
(
url
,
qs
)
{
return
qs
?
url
+
(
url
.
includes
(
'?'
)
?
(
url
.
endsWith
(
'?'
)
?
''
:
'&'
)
:
'?'
)
+
qs
:
url
}
for
(
const
page
of
pages
)
{
for
(
const
page
of
pages
)
{
for
(
const
host
of
hosts
)
{
for
(
const
host
of
hosts
)
{
const
url
=
`
${
mpPage
}
?url=
${
encodeURIComponent
(
host
.
value
+
page
.
value
)}
`
const
url
=
joinUrlAndQs
(
mpPage
,
`url=
${
encodeURIComponent
(
host
.
value
+
page
.
value
)}
`
)
console
.
log
(
`
${
page
.
alias
}
-
${
host
.
alias
}
:
${
url
}
`
)
console
.
log
(
`
${
page
.
alias
}
-
${
host
.
alias
}
:
${
url
}
`
)
}
}
}
}
stores/user.js
View file @
9c7f07b8
import
{
import
{
defineStore
defineStore
}
from
"pinia"
;
}
from
"pinia"
;
import
{
import
{
autoLoginByCode
,
autoLoginByCode
,
fetchUserInfo
,
fetchUserInfo
,
fetchBabyInfo
,
fetchBabyInfo
,
fetchMemberInfo
,
fetchMemberInfo
,
fetchAutoPhone
,
fetchAutoPhone
,
fetchBabyInfoById
,
fetchBabyInfoById
,
updateBabyInfo
,
updateBabyInfo
,
}
from
"../api/user.js"
;
}
from
"../api/user.js"
;
import
{
import
{
useGlobalStore
useGlobalStore
}
from
"./global.js"
;
}
from
"./global.js"
;
import
{
import
{
useHomeStore
useHomeStore
}
from
"./home.js"
;
}
from
"./home.js"
;
import
md
from
"../md.js"
;
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
,
};
};
},
},
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
;
},
},
/**
/**
* 更新宝宝信息
* 更新宝宝信息
* @param {Object} babyInfo
* @param {Object} babyInfo
*/
*/
setBabyInfo
(
babyInfo
)
{
setBabyInfo
(
babyInfo
)
{
this
.
babyInfo
=
babyInfo
;
this
.
babyInfo
=
babyInfo
;
},
},
async
changeBabySelected
(
babyId
)
{
async
changeBabySelected
(
babyId
)
{
// 更新选中状态
// 更新选中状态
const
{
const
{
data
data
}
=
await
fetchBabyInfoById
(
babyId
);
}
=
await
fetchBabyInfoById
(
babyId
);
console
.
log
(
"babyInfo"
,
data
);
console
.
log
(
"babyInfo"
,
data
);
if
(
data
?.
memberId
!==
"not_login"
)
{
if
(
data
?.
memberId
!==
"not_login"
)
{
this
.
babyInfo
=
data
;
this
.
babyInfo
=
data
;
}
}
},
},
saveBabyInfo
(
babyInfo
)
{
saveBabyInfo
(
babyInfo
)
{
this
.
babyInfo
.
allBabyBaseInfo
.
push
(
babyInfo
);
this
.
babyInfo
.
allBabyBaseInfo
.
push
(
babyInfo
);
},
},
/**
/**
* 用户手机号验证的回调方法,用于获取encryptedData、iv、code,然后调用fetchAutoPhone接口完成手机号授权
* 用户手机号验证的回调方法,用于获取encryptedData、iv、code,然后调用fetchAutoPhone接口完成手机号授权
* @param {Object} data : {encryptedData, iv, code}
* @param {Object} data : {encryptedData, iv, code}
* @returns
* @returns
*/
*/
async
phoneCallback
(
data
,
onOpenRegisterFn
=
()
=>
{
},
cb
=
null
,
cb2
=
null
,
invitationInfo
=
null
)
{
async
phoneCallback
(
data
,
onOpenRegisterFn
=
()
=>
{
uni
.
login
({
},
cb
=
null
,
cb2
=
null
,
invitationInfo
=
null
)
{
provider
:
"weixin"
,
uni
.
login
({
success
:
async
(
res
)
=>
{
provider
:
"weixin"
,
// console.log('wxAutoLogin', res);
success
:
async
(
res
)
=>
{
if
(
res
.
errMsg
===
"login:ok"
)
{
// console.log('wxAutoLogin', res);
// 用户手机授权F
if
(
res
.
errMsg
===
"login:ok"
)
{
const
{
// 用户手机授权F
data
:
{
babyExistence
}
const
{
}
=
await
fetchAutoPhone
({
data
:
{
babyExistence
}
phoneEncryptedData
:
data
.
encryptedData
,
}
=
await
fetchAutoPhone
({
phoneIv
:
data
.
iv
,
phoneEncryptedData
:
data
.
encryptedData
,
code
:
data
.
code
,
phoneIv
:
data
.
iv
,
codeLogin
:
res
.
code
,
code
:
data
.
code
,
...
invitationInfo
,
codeLogin
:
res
.
code
,
});
...
invitationInfo
,
});
!
babyExistence
&&
onOpenRegisterFn
&&
onOpenRegisterFn
();
if
(
!
babyExistence
.
value
&&
cb
)
{
!
babyExistence
&&
onOpenRegisterFn
&&
onOpenRegisterFn
();
cb
();
if
(
!
babyExistence
.
value
&&
cb
)
{
}
cb
();
}
const
homeStore
=
useHomeStore
();
await
homeStore
.
setBabyExistence
(
babyExistence
);
const
homeStore
=
useHomeStore
();
console
.
warn
(
'授权后重新获取用户信息'
)
await
homeStore
.
setBabyExistence
(
babyExistence
);
// 授权注册成功后做一次登录
console
.
warn
(
'授权后重新获取用户信息'
)
this
.
wxAutoLogin
(
cb2
);
// 授权注册成功后做一次登录
}
else
{
this
.
wxAutoLogin
(
cb2
);
uni
.
showToast
({
}
else
{
title
:
res
.
errMsg
,
uni
.
showToast
({
icon
:
"error"
,
title
:
res
.
errMsg
,
});
icon
:
"error"
,
}
});
},
}
});
},
},
});
},
/**
* 获取用户信息
/**
*/
* 获取用户信息
async
loadUserInfo
()
{
*/
const
{
async
loadUserInfo
()
{
data
const
{
}
=
await
fetchUserInfo
();
data
console
.
log
(
"userInfo"
,
data
);
}
=
await
fetchUserInfo
();
if
(
data
?.
memberId
!==
"not_login"
)
{
console
.
log
(
"userInfo"
,
data
);
// 缓存用户memberId
if
(
data
?.
memberId
!==
"not_login"
)
{
uni
.
setStorageSync
(
'memberId'
,
data
?.
memberId
)
// 缓存用户memberId
}
uni
.
setStorageSync
(
'memberId'
,
data
?.
memberId
)
this
.
userInfo
=
data
;
}
},
this
.
userInfo
=
data
;
},
setBabyNickCache
(
id
,
name
)
{
const
findIndex
=
this
.
babyNickCache
.
findIndex
((
item
)
=>
item
.
id
===
id
);
setBabyNickCache
(
id
,
name
)
{
console
.
log
(
"this.babyNickCache"
,
findIndex
);
const
findIndex
=
this
.
babyNickCache
.
findIndex
((
item
)
=>
item
.
id
===
id
);
if
(
findIndex
>
-
1
)
{
console
.
log
(
"this.babyNickCache"
,
findIndex
);
this
.
babyNickCache
[
findIndex
].
name
=
name
;
if
(
findIndex
>
-
1
)
{
}
else
{
this
.
babyNickCache
[
findIndex
].
name
=
name
;
this
.
babyNickCache
.
push
({
}
else
{
id
,
this
.
babyNickCache
.
push
({
name
id
,
});
name
}
});
},
}
},
/**
* 获取宝宝信息
/**
*/
* 获取宝宝信息
// async loadBabyInfo() {
*/
// const { data } = await fetchBabyInfo();
// async loadBabyInfo() {
// console.log("babyInfo", data);
// const { data } = await fetchBabyInfo();
// if (data?.memberId !== "not_login") {
// console.log("babyInfo", data);
// this.babyInfo = data;
// if (data?.memberId !== "not_login") {
// console.log("this.11111", this.babyNickCache, data?.content?.id);
// this.babyInfo = data;
// console.log("this.11111", this.babyNickCache, data?.content?.id);
// const findItem = this.babyNickCache.find(
// (item) => item.id == data?.content?.id
// const findItem = this.babyNickCache.find(
// );
// (item) => item.id == data?.content?.id
// if (data?.content?.id && findItem) {
// );
// this.babyInfo.babyName = findItem.name;
// if (data?.content?.id && findItem) {
// this.babyInfo.babyName = findItem.name;
// this.babyInfo.allBabyBaseInfo.forEach((item) => {
// if (item.id == data?.content?.id) {
// this.babyInfo.allBabyBaseInfo.forEach((item) => {
// item.babyName = findItem.name;
// if (item.id == data?.content?.id) {
// }
// item.babyName = findItem.name;
// });
// }
// }
// });
// }
// }
// },
// }
async
loadBabyInfo
(
retryCount
=
0
)
{
// },
const
MAX_RETRIES
=
3
;
async
loadBabyInfo
(
retryCount
=
0
)
{
const
RETRY_DELAY
=
1000
;
// 1 second
const
MAX_RETRIES
=
3
;
const
RETRY_DELAY
=
1000
;
// 1 second
try
{
const
{
data
}
=
await
fetchBabyInfo
();
try
{
console
.
log
(
"babyInfo-宝宝信息"
,
data
);
const
{
data
}
=
await
fetchBabyInfo
();
console
.
log
(
"babyInfo-宝宝信息"
,
data
);
if
(
data
?.
memberId
!==
"not_login"
)
{
this
.
babyInfo
=
data
;
if
(
data
?.
memberId
!==
"not_login"
)
{
if
(
data
.
allBabyBaseInfo
)
{
this
.
babyInfo
=
data
;
if
(
data
.
allBabyBaseInfo
)
{
if
(
this
.
babyInfo
.
babyAge
==
"0月龄"
)
{
this
.
babyInfo
.
babyAge
=
"1月龄"
;
if
(
this
.
babyInfo
.
babyAge
==
"0月龄"
)
{
}
this
.
babyInfo
.
babyAge
=
"1月龄"
;
}
console
.
log
(
"this.11111"
,
this
.
babyNickCache
,
data
?.
content
?.
id
);
console
.
log
(
"this.11111"
,
this
.
babyNickCache
,
data
?.
content
?.
id
);
const
findItem
=
this
.
babyNickCache
.
find
(
(
item
)
=>
item
.
id
==
data
?.
content
?.
id
const
findItem
=
this
.
babyNickCache
.
find
(
);
(
item
)
=>
item
.
id
==
data
?.
content
?.
id
if
(
data
?.
content
?.
id
&&
findItem
)
{
);
this
.
babyInfo
.
babyName
=
findItem
.
name
;
if
(
data
?.
content
?.
id
&&
findItem
)
{
this
.
babyInfo
.
babyName
=
findItem
.
name
;
this
.
babyInfo
.
allBabyBaseInfo
.
forEach
((
item
)
=>
{
if
(
item
.
id
==
data
?.
content
?.
id
)
{
this
.
babyInfo
.
allBabyBaseInfo
.
forEach
((
item
)
=>
{
item
.
babyName
=
findItem
.
name
;
if
(
item
.
id
==
data
?.
content
?.
id
)
{
}
item
.
babyName
=
findItem
.
name
;
});
}
}
});
return
;
// Success case, exit the function
}
}
else
{
return
;
// Success case, exit the function
console
.
log
(
"this.babyInfo"
,
'重新请求接口'
);
}
else
{
if
(
retryCount
<
MAX_RETRIES
-
1
)
{
console
.
log
(
"this.babyInfo"
,
'重新请求接口'
);
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
RETRY_DELAY
));
if
(
retryCount
<
MAX_RETRIES
-
1
)
{
return
this
.
loadBabyInfo
(
retryCount
+
1
);
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
RETRY_DELAY
));
}
else
{
return
this
.
loadBabyInfo
(
retryCount
+
1
);
console
.
log
(
"Max retries reached, giving up"
);
}
else
{
// Show user notification when max retries reached
console
.
log
(
"Max retries reached, giving up"
);
// uni.showToast({
// Show user notification when max retries reached
// title: "系统繁忙,请稍后再试",
// uni.showToast({
// icon: "none",
// title: "系统繁忙,请稍后再试",
// });
// icon: "none",
}
// });
}
}
}
}
}
catch
(
error
)
{
}
console
.
log
(
"🚀 ~ loadBabyInfo ~ error:"
,
error
);
}
catch
(
error
)
{
if
(
retryCount
>=
MAX_RETRIES
-
1
)
{
console
.
log
(
"🚀 ~ loadBabyInfo ~ error:"
,
error
);
// Show user notification when max retries reached with error
if
(
retryCount
>=
MAX_RETRIES
-
1
)
{
uni
.
showToast
({
// Show user notification when max retries reached with error
title
:
"系统繁忙,请稍后再试"
,
uni
.
showToast
({
icon
:
"none"
,
title
:
"系统繁忙,请稍后再试"
,
});
icon
:
"none"
,
}
});
}
}
},
}
},
/**
* 获取用户积分信息
/**
*/
* 获取用户积分信息
async
loadMemberInfo
()
{
*/
const
{
async
loadMemberInfo
()
{
data
const
{
}
=
await
fetchMemberInfo
();
data
console
.
log
(
"fetchMemberInfo="
,
data
);
}
=
await
fetchMemberInfo
();
this
.
setMemberInfo
(
data
);
console
.
log
(
"fetchMemberInfo="
,
data
);
// this.memberInfo = data;
this
.
setMemberInfo
(
data
);
// if (data?.memberId !== "not_login") {
// this.memberInfo = data;
// this.babyInfo = data;
// if (data?.memberId !== "not_login") {
// }
// this.babyInfo = data;
},
// }
/**
},
* 获取宝宝信息
/**
*/
* 获取宝宝信息
async
loadHomeInfo
()
{
*/
const
homeStore
=
useHomeStore
();
async
loadHomeInfo
()
{
await
homeStore
.
loadHomeInfo
();
const
homeStore
=
useHomeStore
();
},
await
homeStore
.
loadHomeInfo
();
},
/**
* wx.login 获取code后,调用此方法完成登录
/**
* @param {String} code
* wx.login 获取code后,调用此方法完成登录
*/
* @param {String} code
async
autoLoginByCode
(
code
)
{
*/
const
{
async
autoLoginByCode
(
code
)
{
data
const
{
}
=
await
autoLoginByCode
(
code
);
data
console
.
log
(
"autoLoginByCode"
,
data
);
}
=
await
autoLoginByCode
(
code
);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
console
.
log
(
"autoLoginByCode"
,
data
);
if
(
data
&&
data
.
cuk
)
{
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
if
(
data
&&
data
.
cuk
)
{
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
await
this
.
loadUserInfo
();
await
this
.
loadBabyInfo
();
await
this
.
loadUserInfo
();
await
this
.
loadHomeInfo
();
await
this
.
loadBabyInfo
();
}
await
this
.
loadHomeInfo
();
},
}
},
/**
* 用户自动登录
/**
*/
* 用户自动登录
async
wxAutoLogin
(
cb
=
null
)
{
*/
uni
.
login
({
async
wxAutoLogin
(
cb
=
null
)
{
provider
:
"weixin"
,
uni
.
login
({
success
:
async
(
res
)
=>
{
provider
:
"weixin"
,
console
.
log
(
"wxAutoLogin"
,
res
);
success
:
async
(
res
)
=>
{
if
(
res
.
errMsg
===
"login:ok"
)
{
console
.
log
(
"wxAutoLogin"
,
res
);
await
this
.
autoLoginByCode
(
res
.
code
);
if
(
res
.
errMsg
===
"login:ok"
)
{
cb
&&
cb
();
await
this
.
autoLoginByCode
(
res
.
code
);
}
else
{
cb
&&
cb
();
uni
.
showToast
({
}
else
{
title
:
res
.
errMsg
,
uni
.
showToast
({
icon
:
"error"
,
title
:
res
.
errMsg
,
});
icon
:
"error"
,
}
});
}
md
.
sensors
.
init
();
},
md
.
sensors
.
init
();
});
},
},
});
},
/**
*
/**
* @param {sy使用}
*
* @returns
* @param {sy使用}
*/
* @returns
async
syWxAutoLogin
(
cb
=
null
)
{
*/
uni
.
login
({
async
syWxAutoLogin
(
cb
=
null
)
{
provider
:
"weixin"
,
uni
.
login
({
success
:
async
(
res
)
=>
{
provider
:
"weixin"
,
if
(
res
.
errMsg
===
"login:ok"
)
{
success
:
async
(
res
)
=>
{
const
{
data
}
=
await
autoLoginByCode
(
res
.
code
);
if
(
res
.
errMsg
===
"login:ok"
)
{
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
const
{
data
}
=
await
autoLoginByCode
(
res
.
code
);
if
(
data
&&
data
.
cuk
)
{
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
if
(
data
&&
data
.
cuk
)
{
cb
&&
cb
();
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
}
cb
&&
cb
();
}
else
{
}
uni
.
showToast
({
}
else
{
title
:
res
.
errMsg
,
uni
.
showToast
({
icon
:
"error"
,
title
:
res
.
errMsg
,
});
icon
:
"error"
,
}
});
}
md
.
sensors
.
init
();
},
md
.
sensors
.
init
();
});
},
},
});
},
/**
*
/**
* @param {sy使用}
*
* @returns
* @param {sy使用}
*/
* @returns
async
normalAutoLogin
(
cb
=
null
)
{
*/
uni
.
login
({
normalAutoLogin
(
cb
=
null
)
{
provider
:
"weixin"
,
return
new
Promise
((
resolve
,
reject
)
=>
{
success
:
async
(
res
)
=>
{
uni
.
login
({
if
(
res
.
errMsg
===
"login:ok"
)
{
provider
:
"weixin"
,
const
{
data
}
=
await
autoLoginByCode
(
res
.
code
);
success
:
async
(
res
)
=>
{
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if
(
res
.
errMsg
===
"login:ok"
)
{
if
(
data
&&
data
.
cuk
)
{
const
{
data
}
=
await
autoLoginByCode
(
res
.
code
);
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
cb
&&
cb
();
if
(
data
&&
data
.
cuk
)
{
}
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
}
else
{
cb
&&
cb
();
uni
.
showToast
({
resolve
()
title
:
res
.
errMsg
,
}
icon
:
"error"
,
}
else
{
});
uni
.
showToast
({
}
title
:
res
.
errMsg
,
icon
:
"error"
,
md
.
sensors
.
init
();
});
},
reject
(
res
.
errMsg
)
});
}
},
md
.
sensors
.
init
();
async
createBabyInfo
(
babyInfo
)
{
},
console
.
log
(
"createBabyInfo:"
,
babyInfo
);
fail
:
(
err
)
=>
{
const
res
=
await
updateBabyInfo
(
babyInfo
);
reject
(
err
)
if
(
res
.
success
)
{
}
await
this
.
loadBabyInfo
();
});
await
this
.
loadUserInfo
();
})
await
this
.
loadHomeInfo
();
},
return
true
;
}
else
{
async
createBabyInfo
(
babyInfo
)
{
return
false
;
console
.
log
(
"createBabyInfo:"
,
babyInfo
);
}
const
res
=
await
updateBabyInfo
(
babyInfo
);
},
if
(
res
.
success
)
{
},
await
this
.
loadBabyInfo
();
await
this
.
loadUserInfo
();
await
this
.
loadHomeInfo
();
return
true
;
}
else
{
return
false
;
}
},
},
});
});
\ 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