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
7875fee0
Commit
7875fee0
authored
Nov 03, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed
parent
12e0aa33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
10 deletions
+64
-10
webview.vue
pages/gameWebview/webview.vue
+64
-10
No files found.
pages/gameWebview/webview.vue
View file @
7875fee0
...
...
@@ -86,20 +86,28 @@ const getMessage = (e) => {
// 初始化 webview URL
const
initWebviewUrl
=
async
()
=>
{
// 使用固定的基础URL,从 options 中获取或使用默认值
const
options
=
pageOptions
.
value
let
baseUrl
=
options
.
url
||
options
.
baseUrl
||
'https://momclub-test.feihe.com/h5/game/index.html'
// 如果 baseUrl 已经包含协议,直接使用;否则添加协议
if
(
!
baseUrl
.
startsWith
(
'http://'
)
&&
!
baseUrl
.
startsWith
(
'https://'
))
{
baseUrl
=
'https://'
+
baseUrl
}
let
baseUrl
=
webviewUrl
.
value
const
cuk
=
globalStore
.
cuk
const
openId
=
globalStore
.
openId
const
unionId
=
globalStore
.
unionId
const
options
=
pageOptions
.
value
// scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene
const
scene
=
options
.
scene
?
decodeURIComponent
(
decodeURIComponent
(
options
.
scene
))
:
null
const
cleanOptions
=
{
...
options
}
delete
cleanOptions
.
scene
delete
cleanOptions
.
url
delete
cleanOptions
.
baseUrl
console
.
warn
(
"scene"
,
scene
)
console
.
warn
(
"cleanOptions"
,
cleanOptions
)
// 将 options 的所有参数原样作为查询参数传给 H5,并补齐 cuk
const
params
=
{
...
cleanOptions
}
...
...
@@ -107,9 +115,43 @@ const initWebviewUrl = async () => {
// 添加用户信息参数
if
(
openId
&&
!
params
.
openId
)
params
.
openId
=
openId
if
(
unionId
&&
!
params
.
unionId
)
params
.
unionId
=
unionId
// 获取会员信息(优先从 memberInfo 获取,如果没有则从 userInfo 获取)
const
memberInfo
=
userStore
.
memberInfo
||
userStore
.
userInfo
// 添加 memberId(如果已注册)
if
(
userStore
.
userInfo
?.
memberId
&&
userStore
.
userInfo
.
memberId
!==
"not_login"
)
{
params
.
crmId
=
userStore
.
userInfo
.
memberId
if
(
memberInfo
?.
memberId
&&
memberInfo
.
memberId
!==
"not_login"
)
{
params
.
crmId
=
memberInfo
.
memberId
// 添加会员ID
params
.
memberId
=
memberInfo
.
memberId
// 添加是否登录(1表示已登录,0表示未登录)
params
.
programLogin
=
'1'
// 添加会员等级(从 gradeList 中根据 grade 获取 gradeName)
if
(
memberInfo
.
grade
!==
undefined
&&
memberInfo
.
grade
!==
null
)
{
// 优先从 gradeList 中查找对应的 gradeName
if
(
memberInfo
.
gradeList
&&
Array
.
isArray
(
memberInfo
.
gradeList
))
{
const
currentGrade
=
String
(
memberInfo
.
grade
)
const
gradeItem
=
memberInfo
.
gradeList
.
find
(
item
=>
String
(
item
.
grade
)
===
currentGrade
)
if
(
gradeItem
&&
gradeItem
.
gradeName
)
{
params
.
memberType
=
gradeItem
.
gradeName
}
else
if
(
memberInfo
.
gradeName
)
{
// 如果 gradeList 中找不到,使用 gradeName
params
.
memberType
=
memberInfo
.
gradeName
}
else
{
// 如果都没有,使用 grade 值
params
.
memberType
=
currentGrade
}
}
else
if
(
memberInfo
.
gradeName
)
{
// 如果没有 gradeList,使用 gradeName
params
.
memberType
=
memberInfo
.
gradeName
}
else
{
// 如果都没有,使用 grade 值
params
.
memberType
=
String
(
memberInfo
.
grade
)
}
}
}
else
{
// 未登录状态
params
.
programLogin
=
'0'
}
const
paramStr
=
Object
.
keys
(
params
)
...
...
@@ -127,19 +169,29 @@ const initWebviewUrl = async () => {
// 示例:
// https://25niansuyuan.feihe.com/projects/Firmus/dev/index?p=xmh&openId=用户openid&unionId=用户unionid&&pt=yzhd123&shareToken=yzhd123&cuk=12121
// 处理 scene 参数
if
(
scene
)
{
// 如果 scene 以 ? 开头,直接拼接
if
(
scene
[
0
]
===
'?'
)
{
baseUrl
+=
scene
}
else
{
baseUrl
+=
`?
${
scene
}
`
// 如果 scene 不以 ? 开头,需要判断 baseUrl 是否已有参数
baseUrl
+=
baseUrl
.
includes
(
'?'
)
?
`&
${
scene
}
`
:
`?
${
scene
}
`
}
}
webviewUrl
.
value
=
paramStr
?
baseUrl
+
(
baseUrl
.
includes
(
'?'
)
?
'&'
:
'?'
)
+
paramStr
:
baseUrl
// 拼接其他参数
if
(
paramStr
)
{
// 判断 baseUrl 是否已包含查询参数
const
separator
=
baseUrl
.
includes
(
'?'
)
?
'&'
:
'?'
webviewUrl
.
value
=
baseUrl
+
separator
+
paramStr
}
else
{
webviewUrl
.
value
=
baseUrl
}
console
.
log
(
'Webview页面加载,URL:'
,
webviewUrl
.
value
,
paramStr
)
console
.
log
(
'Webview页面加载,URL:'
,
webviewUrl
.
value
)
console
.
log
(
'参数字符串:'
,
paramStr
)
console
.
log
(
'基础URL:'
,
baseUrl
)
}
// 监听注册状态变化,初始化 webview URL
...
...
@@ -158,6 +210,8 @@ onShow(async () => {
await
ensureAutoLogin
()
await
userStore
.
loadUserInfo
()
// 加载会员信息以获取 grade 等详细信息
await
userStore
.
loadMemberInfo
()
registered
.
value
=
getRegistered
()
...
...
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