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
6f78e9e3
Commit
6f78e9e3
authored
Aug 15, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
third
parent
58113636
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
501 deletions
+0
-501
thirdJumpDemo.vue
pages/thirdJumpDemo/thirdJumpDemo.vue
+0
-385
thirdJump.js
utils/thirdJump.js
+0
-116
No files found.
pages/thirdJumpDemo/thirdJumpDemo.vue
deleted
100644 → 0
View file @
58113636
<
template
>
<view
class=
"demo-page"
>
<view
class=
"header"
>
<text
class=
"title"
>
第三方跳转演示
</text>
</view>
<view
class=
"form-container"
>
<view
class=
"form-item"
>
<text
class=
"label"
>
目标小程序AppID:
</text>
<input
v-model=
"formData.appId"
class=
"input"
placeholder=
"请输入目标小程序的AppID"
/>
</view>
<view
class=
"form-item"
>
<text
class=
"label"
>
跳转路径:
</text>
<input
v-model=
"formData.path"
class=
"input"
placeholder=
"可选,跳转的具体页面路径"
/>
</view>
<view
class=
"form-item"
>
<text
class=
"label"
>
应用名称:
</text>
<input
v-model=
"formData.appName"
class=
"input"
placeholder=
"可选,目标应用名称"
/>
</view>
<view
class=
"form-item"
>
<text
class=
"label"
>
环境版本:
</text>
<picker
:value=
"envVersionIndex"
:range=
"envVersions"
@
change=
"onEnvVersionChange"
class=
"picker"
>
<view
class=
"picker-text"
>
{{
envVersions
[
envVersionIndex
]
}}
</view>
</picker>
</view>
</view>
<view
class=
"button-container"
>
<button
class=
"jump-btn primary"
@
click=
"jumpWithMiddlePage"
>
通过中间页跳转
</button>
<button
class=
"jump-btn secondary"
@
click=
"directJump"
>
直接跳转
</button>
</view>
<view
class=
"info-container"
>
<view
class=
"info-item"
>
<text
class=
"info-label"
>
当前平台:
</text>
<text
class=
"info-value"
>
{{
platform
}}
</text>
</view>
<view
class=
"info-item"
>
<text
class=
"info-label"
>
支持跳转:
</text>
<text
class=
"info-value"
:class=
"
{ 'supported': canJump, 'not-supported': !canJump }">
{{
canJump
?
'是'
:
'否'
}}
</text>
</view>
</view>
<view
class=
"log-container"
>
<text
class=
"log-title"
>
操作日志:
</text>
<scroll-view
class=
"log-content"
scroll-y
>
<view
v-for=
"(log, index) in logs"
:key=
"index"
class=
"log-item"
>
<text
class=
"log-time"
>
{{
log
.
time
}}
</text>
<text
class=
"log-message"
>
{{
log
.
message
}}
</text>
</view>
</scroll-view>
</view>
</view>
</
template
>
<
script
setup
>
import
{
ref
,
onMounted
}
from
'vue'
import
{
jumpToThirdParty
,
directJump
,
canJumpToMiniProgram
,
getJumpStatus
}
from
'../../utils/thirdJump.js'
// 响应式数据
const
formData
=
ref
({
appId
:
'wx1234567890abcdef'
,
// 示例AppID
path
:
'pages/index/index'
,
appName
:
'示例小程序'
,
extraData
:
{}
})
const
envVersions
=
[
'release'
,
'trial'
,
'develop'
]
const
envVersionIndex
=
ref
(
0
)
const
platform
=
ref
(
''
)
const
canJump
=
ref
(
false
)
const
logs
=
ref
([])
// 页面加载
onMounted
(()
=>
{
checkPlatform
()
checkJumpSupport
()
addLog
(
'页面加载完成'
)
})
// 检查平台
const
checkPlatform
=
()
=>
{
// #ifdef MP-WEIXIN
platform
.
value
=
'微信小程序'
// #endif
// #ifdef MP-ALIPAY
platform
.
value
=
'支付宝小程序'
// #endif
// #ifdef MP-BAIDU
platform
.
value
=
'百度小程序'
// #endif
// #ifdef MP-TOUTIAO
platform
.
value
=
'头条小程序'
// #endif
// #ifdef H5
platform
.
value
=
'H5'
// #endif
// #ifdef APP-PLUS
platform
.
value
=
'App'
// #endif
}
// 检查跳转支持
const
checkJumpSupport
=
async
()
=>
{
canJump
.
value
=
canJumpToMiniProgram
()
if
(
canJump
.
value
)
{
try
{
const
status
=
await
getJumpStatus
(
formData
.
value
.
appId
)
addLog
(
`跳转状态检查:
${
status
.
message
}
`
)
}
catch
(
error
)
{
addLog
(
`跳转状态检查失败:
${
error
.
message
}
`
)
}
}
else
{
addLog
(
'当前平台不支持跳转小程序'
)
}
}
// 环境版本选择
const
onEnvVersionChange
=
(
e
)
=>
{
envVersionIndex
.
value
=
e
.
detail
.
value
formData
.
value
.
envVersion
=
envVersions
[
envVersionIndex
.
value
]
addLog
(
`环境版本切换为:
${
formData
.
value
.
envVersion
}
`
)
}
// 通过中间页跳转
const
jumpWithMiddlePage
=
()
=>
{
if
(
!
formData
.
value
.
appId
)
{
uni
.
showToast
({
title
:
'请输入AppID'
,
icon
:
'none'
})
return
}
addLog
(
'开始通过中间页跳转'
)
jumpToThirdParty
({
...
formData
.
value
,
envVersion
:
formData
.
value
.
envVersion
})
}
// 直接跳转
const
directJump
=
()
=>
{
if
(
!
formData
.
value
.
appId
)
{
uni
.
showToast
({
title
:
'请输入AppID'
,
icon
:
'none'
})
return
}
if
(
!
canJump
.
value
)
{
uni
.
showToast
({
title
:
'当前平台不支持跳转'
,
icon
:
'none'
})
return
}
addLog
(
'开始直接跳转'
)
directJump
({
...
formData
.
value
,
envVersion
:
formData
.
value
.
envVersion
})
}
// 添加日志
const
addLog
=
(
message
)
=>
{
const
now
=
new
Date
()
const
time
=
`
${
now
.
getHours
().
toString
().
padStart
(
2
,
'0'
)}
:
${
now
.
getMinutes
().
toString
().
padStart
(
2
,
'0'
)}
:
${
now
.
getSeconds
().
toString
().
padStart
(
2
,
'0'
)}
`
logs
.
value
.
unshift
({
time
,
message
})
// 限制日志数量
if
(
logs
.
value
.
length
>
50
)
{
logs
.
value
=
logs
.
value
.
slice
(
0
,
50
)
}
}
</
script
>
<
style
lang=
"less"
scoped
>
.demo-page {
min-height: 100vh;
background: #f5f5f5;
padding: 40rpx;
}
.header {
text-align: center;
margin-bottom: 60rpx;
.title {
font-size: 48rpx;
font-weight: bold;
color: #333;
}
}
.form-container {
background: white;
border-radius: 20rpx;
padding: 40rpx;
margin-bottom: 40rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
}
.form-item {
margin-bottom: 40rpx;
&:last-child {
margin-bottom: 0;
}
}
.label {
display: block;
font-size: 28rpx;
color: #333;
margin-bottom: 20rpx;
font-weight: 500;
}
.input {
width: 100%;
height: 80rpx;
border: 2rpx solid #e0e0e0;
border-radius: 10rpx;
padding: 0 20rpx;
font-size: 28rpx;
box-sizing: border-box;
&:focus {
border-color: #007aff;
}
}
.picker {
width: 100%;
height: 80rpx;
border: 2rpx solid #e0e0e0;
border-radius: 10rpx;
display: flex;
align-items: center;
padding: 0 20rpx;
box-sizing: border-box;
}
.picker-text {
font-size: 28rpx;
color: #333;
}
.button-container {
display: flex;
gap: 20rpx;
margin-bottom: 40rpx;
}
.jump-btn {
flex: 1;
height: 88rpx;
border-radius: 44rpx;
font-size: 32rpx;
border: none;
&.primary {
background: #007aff;
color: white;
}
&.secondary {
background: #f0f0f0;
color: #333;
}
}
.info-container {
background: white;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 40rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
}
.info-item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
&:last-child {
margin-bottom: 0;
}
}
.info-label {
font-size: 28rpx;
color: #666;
}
.info-value {
font-size: 28rpx;
color: #333;
font-weight: 500;
&.supported {
color: #4CAF50;
}
&.not-supported {
color: #f44336;
}
}
.log-container {
background: white;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
}
.log-title {
display: block;
font-size: 28rpx;
color: #333;
margin-bottom: 20rpx;
font-weight: 500;
}
.log-content {
height: 300rpx;
}
.log-item {
display: flex;
margin-bottom: 15rpx;
&:last-child {
margin-bottom: 0;
}
}
.log-time {
font-size: 24rpx;
color: #999;
margin-right: 20rpx;
min-width: 80rpx;
}
.log-message {
font-size: 24rpx;
color: #333;
flex: 1;
}
</
style
>
utils/thirdJump.js
deleted
100644 → 0
View file @
58113636
/**
* 第三方跳转工具函数
*/
/**
* 跳转到第三方小程序
* @param {Object} params 跳转参数
* @param {string} params.appId 目标小程序appId
* @param {string} params.path 跳转路径
* @param {Object} params.extraData 额外数据
* @param {string} params.envVersion 环境版本
* @param {string} params.appName 应用名称
*/
export
function
jumpToThirdParty
(
params
)
{
const
{
appId
,
path
=
''
,
extraData
=
{},
envVersion
=
'release'
,
appName
=
'目标应用'
}
=
params
if
(
!
appId
)
{
console
.
error
(
'缺少必要参数:appId'
)
return
}
// 构建跳转参数
const
jumpParams
=
{
appId
,
path
,
extraData
:
encodeURIComponent
(
JSON
.
stringify
(
extraData
)),
envVersion
,
appName
}
// 跳转到中间页
uni
.
navigateTo
({
url
:
`/pages/thirdJumpMiddlePage/thirdJumpMiddlePage?
${
Object
.
keys
(
jumpParams
)
.
map
(
key
=>
`
${
key
}
=
${
jumpParams
[
key
]}
`
)
.
join
(
'&'
)}
`
})
}
/**
* 直接跳转(不经过中间页)
* @param {Object} params 跳转参数
*/
export
function
directJump
(
params
)
{
const
{
appId
,
path
=
''
,
extraData
=
{},
envVersion
=
'release'
}
=
params
if
(
!
appId
)
{
console
.
error
(
'缺少必要参数:appId'
)
return
}
uni
.
navigateToMiniProgram
({
appId
,
path
,
extraData
,
envVersion
,
success
:
(
res
)
=>
{
console
.
log
(
'跳转成功:'
,
res
)
},
fail
:
(
err
)
=>
{
console
.
error
(
'跳转失败:'
,
err
)
// 跳转失败时,可以跳转到中间页进行重试
jumpToThirdParty
(
params
)
}
})
}
/**
* 检查是否支持跳转
* @returns {boolean}
*/
export
function
canJumpToMiniProgram
()
{
// #ifdef MP-WEIXIN
return
true
// #endif
// #ifndef MP-WEIXIN
return
false
// #endif
}
/**
* 获取跳转状态
* @param {string} appId 目标小程序appId
* @returns {Promise}
*/
export
function
getJumpStatus
(
appId
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// #ifdef MP-WEIXIN
uni
.
getSetting
({
success
:
(
res
)
=>
{
if
(
res
.
authSetting
[
'scope.userInfo'
])
{
resolve
({
canJump
:
true
,
message
:
'可以跳转'
})
}
else
{
resolve
({
canJump
:
false
,
message
:
'需要授权'
})
}
},
fail
:
reject
})
// #endif
// #ifndef MP-WEIXIN
resolve
({
canJump
:
false
,
message
:
'当前平台不支持跳转'
})
// #endif
})
}
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