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
81c82aed
Commit
81c82aed
authored
Aug 12, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sywebview
parent
3287c605
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
55 deletions
+61
-55
syWebview.vue
pages/syWebview/syWebview.vue
+61
-55
No files found.
pages/syWebview/syWebview.vue
View file @
81c82aed
...
...
@@ -28,8 +28,7 @@ Webview页面使用说明:
<
template
>
<view
class=
"webview-container"
>
<!-- Webview内容 -->
<web-view
:src=
"webviewUrl"
@
message=
"getMessage"
@
load=
"onWebviewLoad"
@
error=
"onWebviewError"
class=
"webview-content"
></web-view>
<web-view
:src=
"webviewUrl"
@
message=
"getMessage"
class=
"webview-content"
></web-view>
</view>
</
template
>
...
...
@@ -38,6 +37,8 @@ import { ref, onMounted } from 'vue'
import
{
useUserStore
}
from
'@/stores/user.js'
import
{
useGlobalStore
}
from
'../../stores/global'
import
{
fetchSyWebviewJSON
}
from
'../../api/sywebview'
import
{
onLoad
,
onShareAppMessage
,
onShareTimeline
,
onPageScroll
}
from
"@dcloudio/uni-app"
;
// 响应式数据
const
statusBarHeight
=
ref
(
0
)
...
...
@@ -81,30 +82,6 @@ const getMessage = (e) => {
}
// Webview加载完成
const
onWebviewLoad
=
(
e
)
=>
{
console
.
log
(
'Webview加载完成:'
,
e
)
if
(
pageTitle
.
value
===
'加载中...'
)
{
pageTitle
.
value
=
'网页'
}
}
// Webview加载错误
const
onWebviewError
=
(
e
)
=>
{
console
.
error
(
'Webview加载错误:'
,
e
)
uni
.
showToast
({
title
:
'页面加载失败'
,
icon
:
'none'
})
}
// 返回上一页
const
goBack
=
()
=>
{
uni
.
navigateBack
({
delta
:
1
})
}
// 页面加载
onMounted
(
async
()
=>
{
// 获取状态栏高度
...
...
@@ -133,7 +110,6 @@ onMounted(async () => {
// 将 options 的所有参数原样作为查询参数传给 H5,并补齐 cuk
const
params
=
{
...(
pageOptions
.
value
||
{})
}
if
(
cuk
&&
!
params
.
cuk
)
params
.
cuk
=
cuk
// 添加用户信息参数
if
(
openId
&&
!
params
.
openId
)
params
.
openId
=
openId
if
(
unionId
&&
!
params
.
unionId
)
params
.
unionId
=
unionId
...
...
@@ -161,41 +137,71 @@ onMounted(async () => {
})
// 分享功能
defineExpose
({
onShareAppMessage
:
(
options
)
=>
{
console
.
log
(
'分享数据:'
,
share
.
value
)
console
.
log
(
'分享选项:'
,
options
)
if
(
share
.
value
)
{
const
shareurl
=
share
.
value
.
shareUrl
const
title
=
share
.
value
.
shareTitle
const
imageUrl
=
share
.
value
.
shareImageUrl
console
.
log
(
'使用分享数据:'
,
{
title
,
shareurl
,
imageUrl
})
return
{
title
:
title
||
'分享'
,
path
:
shareurl
||
'/pages/index/index'
,
imageUrl
:
imageUrl
||
''
,
success
:
function
(
res
)
{
console
.
log
(
'分享成功:'
,
res
)
},
fail
:
function
(
res
)
{
console
.
log
(
'分享失败:'
,
res
)
},
complete
:
function
(
res
)
{
console
.
log
(
'分享完成:'
,
res
)
}
onShareAppMessage
((
options
)
=>
{
console
.
log
(
'分享数据:'
,
share
.
value
)
console
.
log
(
'分享选项:'
,
options
)
if
(
share
.
value
)
{
const
shareurl
=
share
.
value
.
shareUrl
const
title
=
share
.
value
.
shareTitle
const
imageUrl
=
share
.
value
.
shareImageUrl
console
.
log
(
'使用分享数据:'
,
{
title
,
shareurl
,
imageUrl
})
return
{
title
:
title
,
path
:
shareurl
||
'/pages/index/index'
,
imageUrl
:
imageUrl
||
''
,
success
:
function
(
res
)
{
console
.
log
(
'分享成功:'
,
res
)
},
fail
:
function
(
res
)
{
console
.
log
(
'分享失败:'
,
res
)
},
complete
:
function
(
res
)
{
console
.
log
(
'分享完成:'
,
res
)
}
}
}
// 如果没有分享数据,返回默认分享
return
{
path
:
'/pages/index/index'
}
})
onShareTimeline
((
options
)
=>
{
console
.
log
(
'分享朋友圈数据:'
,
share
.
value
)
console
.
log
(
'分享朋友圈选项:'
,
options
)
if
(
share
.
value
)
{
const
shareurl
=
share
.
value
.
shareUrl
const
title
=
share
.
value
.
shareTitle
const
imageUrl
=
share
.
value
.
shareImageUrl
console
.
log
(
'使用分享数据:'
,
{
title
,
shareurl
,
imageUrl
})
// 如果没有分享数据,返回默认分享
return
{
title
:
'分享'
,
path
:
'/pages/index/index'
title
:
title
||
'分享'
,
path
:
shareurl
||
'/pages/index/index'
,
imageUrl
:
imageUrl
||
''
,
success
:
function
(
res
)
{
console
.
log
(
'分享成功:'
,
res
)
},
fail
:
function
(
res
)
{
console
.
log
(
'分享失败:'
,
res
)
},
complete
:
function
(
res
)
{
console
.
log
(
'分享完成:'
,
res
)
}
}
}
// 如果没有分享数据,返回默认分享
return
{
path
:
'/pages/index/index'
}
})
</
script
>
<
style
lang=
"less"
scoped
>
...
...
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