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
0f00f711
Commit
0f00f711
authored
Aug 08, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sy webview
parent
940def5a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
15 deletions
+36
-15
syWebview.vue
pages/syWebview/syWebview.vue
+21
-8
global.js
stores/global.js
+14
-6
user.js
stores/user.js
+1
-1
No files found.
pages/syWebview/syWebview.vue
View file @
0f00f711
...
...
@@ -60,26 +60,39 @@ export default {
// 固定写死的 URL(不从 options 读取 baseUrl)
const
baseUrl
=
'https://25niansuyuan.feihe.com/projects/Firmus/dev/index'
;
const
store
=
useGlobalStore
();
const
cuk
=
store
.
cuk
||
uni
.
getStorageSync
(
'cuk'
);
// 可选:设置页面标题(不从 params 移除,仍然透传到 H5)
if
(
options
&&
options
.
title
)
{
try
{
this
.
pageTitle
=
decodeURIComponent
(
options
.
title
);
}
catch
(
_
)
{
this
.
pageTitle
=
options
.
title
;
}
}
const
cuk
=
store
.
cuk
;
const
openId
=
store
.
openId
;
const
unionId
=
store
.
unionId
;
// 将 options 的所有参数原样作为查询参数传给 H5,并补齐 cuk
const
params
=
{
...(
options
||
{})
};
if
(
cuk
&&
!
params
.
cuk
)
params
.
cuk
=
cuk
;
// 添加用户信息参数
if
(
openId
&&
!
params
.
openId
)
params
.
openId
=
openId
;
if
(
unionId
&&
!
params
.
unionId
)
params
.
unionId
=
unionId
;
const
paramStr
=
Object
.
keys
(
params
)
.
map
(
key
=>
`
${
encodeURIComponent
(
key
)}
=
${
encodeURIComponent
(
params
[
key
])}
`
)
.
filter
(
key
=>
params
[
key
]
!==
undefined
&&
params
[
key
]
!==
null
&&
params
[
key
]
!==
''
)
.
map
(
key
=>
`
${
key
}
=
${
encodeURIComponent
(
params
[
key
])}
`
)
.
join
(
'&'
);
// p 渠道参数
// openId 用户openid
// unionId 用户unionid
// cuk
// shareToken 分享人token
// pt 分享海报人token
// 示例:
// https://25niansuyuan.feihe.com/projects/Firmus/dev/index?p=xmh&openId=用户openid&unionId=用户unionid&&pt=yzhd123&shareToken=yzhd123&cuk=12121
this
.
webviewUrl
=
paramStr
?
baseUrl
+
(
baseUrl
.
includes
(
'?'
)
?
'&'
:
'?'
)
+
paramStr
:
baseUrl
;
console
.
log
(
'Webview页面加载,URL:'
,
this
.
webviewUrl
);
console
.
log
(
'Webview页面加载,URL:'
,
this
.
webviewUrl
,
paramStr
,
cuk
,
openId
,
unionId
);
},
onShareAppMessage
(
options
)
{
// 分享功能
...
...
stores/global.js
View file @
0f00f711
...
...
@@ -3,14 +3,18 @@ import {
}
from
'pinia'
;
const
cuk
=
uni
.
getStorageSync
(
'cuk'
)
const
openId
=
uni
.
getStorageSync
(
'openId'
)
const
unionId
=
uni
.
getStorageSync
(
'unionId'
)
export
const
useGlobalStore
=
defineStore
(
'global'
,
{
state
:
()
=>
{
return
{
cuk
:
cuk
,
// 用户登录后获取的凭证,调用接口时headers中携带
curTabIndex
:
0
,
// 当前Tab索引
isWxFriendCircle
:
false
,
isShowLoading
:
false
isWxFriendCircle
:
false
,
isShowLoading
:
false
,
openId
:
openId
,
unionId
:
unionId
};
},
actions
:
{
...
...
@@ -18,8 +22,12 @@ export const useGlobalStore = defineStore('global', {
* 设置用户cuk
* @param {Object} cuk
*/
setCuk
(
cuk
)
{
setCuk
(
cuk
,
openId
,
unionId
)
{
this
.
cuk
=
cuk
;
this
.
openId
=
openId
;
this
.
unionId
=
unionId
;
uni
.
setStorageSync
(
'openId'
,
openId
);
uni
.
setStorageSync
(
'unionId'
,
unionId
);
uni
.
setStorageSync
(
'cuk'
,
cuk
);
},
/**
...
...
@@ -36,9 +44,9 @@ export const useGlobalStore = defineStore('global', {
*/
setIsWxFriendCircle
(
v
){
this
.
isWxFriendCircle
=
v
},
setIsShowLoading
(
v
){
},
setIsShowLoading
(
v
){
this
.
isShowLoading
=
v
}
},
...
...
stores/user.js
View file @
0f00f711
...
...
@@ -173,7 +173,7 @@ export const useUserStore = defineStore("userInfo", {
console
.
log
(
"autoLoginByCode"
,
data
);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if
(
data
&&
data
.
cuk
)
{
globalStore
.
setCuk
(
data
.
cuk
);
globalStore
.
setCuk
(
data
.
cuk
,
data
.
openId
,
data
.
unionId
);
await
this
.
loadUserInfo
();
await
this
.
loadBabyInfo
();
...
...
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