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
c577b1bb
Commit
c577b1bb
authored
Sep 17, 2025
by
lg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: 增加webview页面的分享功能
parent
001ceddf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
6 deletions
+91
-6
webview.vue
pages/webview/webview.vue
+82
-5
Integral.vue
views/Integral.vue
+9
-1
No files found.
pages/webview/webview.vue
View file @
c577b1bb
<
template
>
<web-view
:src=
"src"
/>
<web-view
:src=
"src"
@
message=
"onMessage"
/>
</
template
>
<
script
setup
>
import
{
ref
}
from
"vue"
;
import
{
onLoad
}
from
"@dcloudio/uni-app"
;
import
{
ref
}
from
"vue"
;
import
{
onLoad
,
onShareAppMessage
,
onShareTimeline
,
onPageScroll
}
from
"@dcloudio/uni-app"
;
import
{
useGlobalStore
}
from
"../../stores/global"
;
let
src
=
ref
(
""
);
const
globalStore
=
useGlobalStore
()
const
src
=
ref
(
""
);
const
PRIVACY_URL
=
"https://secret.feihe.com/secret.html"
;
const
MEMBER_URL
=
"https://secret.feihe.com/index.html"
;
...
...
@@ -16,7 +19,16 @@ const urlMap = {
MEMBER_URL
,
};
const
shareData
=
ref
(
null
)
onLoad
((
options
)
=>
{
console
.
log
(
'页面参数:'
,
options
)
wx
.
showShareMenu
({
withShareTicket
:
true
,
menus
:
[
'shareAppMessage'
,
'shareTimeline'
]
})
let
url
=
""
;
if
(
options
.
type
)
{
...
...
@@ -26,6 +38,71 @@ onLoad((options) => {
url
=
decodeURIComponent
(
options
.
url
)
||
""
;
}
src
.
value
=
url
;
const
params
=
{...(
options
||
{})}
const
{
unionId
}
=
globalStore
if
(
unionId
&&
!
params
.
unionId
)
params
.
unionId
=
unionId
const
paramStr
=
Object
.
keys
(
params
)
.
filter
(
key
=>
params
[
key
]
!==
undefined
&&
params
[
key
]
!==
null
&&
params
[
key
]
!==
''
)
.
map
(
key
=>
`
${
key
}
=
${
encodeURIComponent
(
params
[
key
])}
`
)
.
join
(
'&'
)
url
=
paramStr
?
url
+
(
url
.
includes
(
'?'
)
?
'&'
:
'?'
)
+
paramStr
:
url
src
.
value
=
url
console
.
log
(
'webview url:'
,
url
)
});
function
onMessage
(
e
)
{
const
data
=
e
.
detail
.
data
const
lastData
=
data
[
data
.
length
-
1
]
console
.
log
(
'webview 消息接收:'
,
lastData
)
switch
(
lastData
.
type
){
case
'share'
:
shareData
.
value
=
lastData
.
payload
break
;
}
}
function
shareHook
()
{
if
(
shareData
.
value
)
{
const
{
url
,
title
,
imageUrl
=
''
}
=
shareData
.
value
console
.
log
(
'使用分享数据:'
,
shareData
.
value
)
return
{
title
,
path
:
url
||
'/pages/index/index'
,
imageUrl
,
success
:
function
(
res
)
{
console
.
log
(
'分享成功:'
,
res
)
//星妈会埋点方法,用户分享成功后触发事件
},
fail
:
function
(
res
)
{
console
.
log
(
'分享失败:'
,
res
)
},
complete
:
function
(
res
)
{
console
.
log
(
'分享完成:'
,
res
)
}
}
}
// 如果没有分享数据,返回默认分享
return
{
path
:
'/pages/index/index'
}
}
onShareAppMessage
((
options
)
=>
{
console
.
log
(
'分享给朋友数据:'
,
shareData
.
value
)
return
shareHook
()
})
onShareTimeline
((
options
)
=>
{
console
.
log
(
'分享到朋友圈数据:'
,
shareData
.
value
)
return
shareHook
()
})
</
script
>
\ No newline at end of file
views/Integral.vue
View file @
c577b1bb
...
...
@@ -425,7 +425,11 @@
<!-- 会员活动 -->
<view class="
vip
-
active
-
area
">
<text class="
vip
-
title
" :style="
{
color
:
itemIndex
===
4
?
'#fff0df'
:
'#1d1e25'
}
">会员活动</text>
<text
class="
vip
-
title
"
:style="
{
color
:
itemIndex
===
4
?
'#fff0df'
:
'#1d1e25'
}
"
@click="
clickTest
"
>会员活动</text>
<swiper
class="
vip
-
active
-
swiper
"
:indicator-dots="
vipActive
.
length
>
1
"
...
...
@@ -637,6 +641,10 @@ import MonthGift from '../components/pointRightsCom/monthGift.vue';
import YearGift from '../components/pointRightsCom/yearGift.vue';
import ShengriliTipPanel from '../components/quanyi/shengriliTipPanel.vue';
function clickTest(){
navigateTo('/pages/webview/webview?url=' + encodeURIComponent('http://localhost:8001/#/page?id=49'))
}
// 进度条图片加载错误处理
const onProgressBarError = (e) => {
console.error('进度条图片加载失败:', e)
...
...
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