Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CFFP-HB
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chao Sun
CFFP-HB
Commits
679686ef
Commit
679686ef
authored
Jan 15, 2026
by
Sweet Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
暂存
parent
7eaa3816
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
143 additions
and
36 deletions
+143
-36
myPackageA/compare-result/compare-result.vue
+143
-36
No files found.
myPackageA/compare-result/compare-result.vue
View file @
679686ef
...
...
@@ -96,6 +96,33 @@
<text
class=
"empty-text"
>
暂无对比产品数据
</text>
</view>
</view>
<!-- 放在
</view>
最后,
</
template
>
之前 -->
<!-- PDF 查看弹窗 -->
<uni-popup
ref=
"pdfPopupRef"
:mask-click=
"true"
type=
"bottom"
@
change=
"onPopupChange"
>
<view
class=
"pdf-modal-container"
>
<!-- 关闭按钮 -->
<view
class=
"modal-header"
>
<button
class=
"close-btn"
@
click=
"closePdfModal"
>
✕
</button>
</view>
<!-- PDF 查看器 -->
<view
class=
"pdf-viewer-wrapper"
v-if=
"showPdfModal"
>
<PdfViewer
:pdfInfo=
"{ url: currentPdfUrl }"
:autoLoad=
"true"
:lazyLoad=
"true"
:maxRetryCount=
"2"
:loadingStatus=
"true"
style=
"height: 100%; width: 100%;"
/>
</view>
</view>
</uni-popup>
</template>
<
script
setup
>
...
...
@@ -103,6 +130,12 @@ import { ref, computed, onMounted } from 'vue';
import
{
useRouter
,
useRoute
}
from
'vue-router'
;
import
common
from
'@/common/common'
;
import
api
from
'@/api/api'
;
import
{
onBeforeUnmount
}
from
'vue'
;
import
PdfViewer
from
'@/components/pdf-viewer/pdf-viewer.vue'
;
import
uniPopup
from
'@dcloudio/uni-ui/lib/uni-popup/uni-popup.vue'
;
const
pdfPopupRef
=
ref
();
// 路由实例
const
router
=
useRouter
();
const
route
=
useRoute
();
...
...
@@ -172,42 +205,42 @@ const wxShare = (productIds,categoryId)=>{
}
hshare
(
data
,
url
)
}
const
getUrl
=
(
fileUrl
)
=>
{
if
(
!
fileUrl
)
{
uni
.
showToast
({
title
:
'暂无文档'
,
icon
:
'none'
});
return
;
}
// 区分环境:H5 端直接打开 URL,其他端用原下载逻辑
if
(
uni
.
getSystemInfoSync
().
uniPlatform
===
'web'
)
{
// H5 方案:用浏览器新窗口打开 PDF(依赖浏览器原生支持)
const
opened
=
window
.
open
(
fileUrl
,
'_blank'
);
}
else
{
// 非 H5 端(小程序/APP):保留原下载+打开逻辑
uni
.
downloadFile
({
url
:
fileUrl
,
success
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
uni
.
openDocument
({
filePath
:
res
.
tempFilePath
,
showMenu
:
true
,
success
:
()
=>
console
.
log
(
'打开文档成功'
),
fail
:
(
err
)
=>
{
uni
.
showToast
({
title
:
'打开失败,请重试'
,
icon
:
'none'
});
console
.
error
(
'openDocument 失败:'
,
err
);
}
});
}
else
{
uni
.
showToast
({
title
:
'下载失败'
,
icon
:
'none'
});
}
},
fail
:
(
err
)
=>
{
uni
.
showToast
({
title
:
'下载失败,请检查网络'
,
icon
:
'none'
});
console
.
error
(
'downloadFile 失败:'
,
err
);
}
});
}
};
//
const getUrl = (fileUrl) => {
//
if (!fileUrl) {
//
uni.showToast({ title: '暂无文档', icon: 'none' });
//
return;
//
}
//
// 区分环境:H5 端直接打开 URL,其他端用原下载逻辑
//
if (uni.getSystemInfoSync().uniPlatform === 'web') {
//
// H5 方案:用浏览器新窗口打开 PDF(依赖浏览器原生支持)
//
const opened = window.open(fileUrl, '_blank');
//
} else {
//
// 非 H5 端(小程序/APP):保留原下载+打开逻辑
//
uni.downloadFile({
//
url: fileUrl,
//
success: (res) => {
//
if (res.statusCode === 200) {
//
uni.openDocument({
//
filePath: res.tempFilePath,
//
showMenu: true,
//
success: () => console.log('打开文档成功'),
//
fail: (err) => {
//
uni.showToast({ title: '打开失败,请重试', icon: 'none' });
//
console.error('openDocument 失败:', err);
//
}
//
});
//
} else {
//
uni.showToast({ title: '下载失败', icon: 'none' });
//
}
//
},
//
fail: (err) => {
//
uni.showToast({ title: '下载失败,请检查网络', icon: 'none' });
//
console.error('downloadFile 失败:', err);
//
}
//
});
//
}
//
};
// 【核心1:获取第一个产品的分组列表(A/B/C组)】
// 所有产品的分组结构一致,取第一个产品的 basicInfos 作为分组源
...
...
@@ -258,6 +291,48 @@ const navigateToPKPage = () => {
};
const
showPdfModal
=
ref
(
false
);
const
currentPdfUrl
=
ref
(
''
);
// 修改 getUrl 方法
const
getUrl
=
(
fileUrl
)
=>
{
if
(
!
fileUrl
)
{
uni
.
showToast
({
title
:
'暂无文档'
,
icon
:
'none'
});
return
;
}
uni
.
showLoading
({
title
:
'加载PDF中...'
});
// 所有平台统一处理:弹出 PdfViewer
currentPdfUrl
.
value
=
fileUrl
;
showPdfModal
.
value
=
true
;
};
// 关闭弹窗
const
closePdfModal
=
()
=>
{
showPdfModal
.
value
=
false
;
// 延迟关闭 popup,避免 PdfViewer 销毁过快
setTimeout
(()
=>
{
pdfPopupRef
.
value
?.
close
?.();
},
100
);
};
// 监听弹窗状态变化(可选)
const
onPopupChange
=
(
e
)
=>
{
if
(
!
e
.
show
&&
showPdfModal
.
value
)
{
// 用户点击遮罩关闭
showPdfModal
.
value
=
false
;
}
};
// 组件销毁前关闭弹窗(防内存泄漏)
onBeforeUnmount
(()
=>
{
if
(
pdfPopupRef
.
value
)
{
pdfPopupRef
.
value
.
close
();
}
});
// 初始化数据
onMounted
(()
=>
{
...
...
@@ -488,4 +563,35 @@ onMounted(() => {
align-items
:
center
;
justify-content
:
center
;
}
.pdf-modal-container
{
width
:
100vw
;
height
:
90vh
;
/* 占屏 90% */
background
:
#fff
;
border-top-left-radius
:
20
rpx
;
border-top-right-radius
:
20
rpx
;
overflow
:
hidden
;
display
:
flex
;
flex-direction
:
column
;
}
.modal-header
{
padding
:
20
rpx
;
text-align
:
right
;
}
.close-btn
{
width
:
60
rpx
;
height
:
60
rpx
;
font-size
:
36
rpx
;
background
:
#f5f5f5
;
border-radius
:
50%
;
border
:
none
;
color
:
#999
;
}
.pdf-viewer-wrapper
{
flex
:
1
;
width
:
100%
;
overflow
:
hidden
;
}
</
style
>
\ No newline at end of file
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