Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
manulife-weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2026-02-12 19:57:35 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c40c57d58b42056af51a53fed44203f5be7b42bf
c40c57d5
1 parent
43066e2d
fix: 计划书预览成功后再翻状态
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
46 deletions
README.md
src/composables/useFileOperation.js
src/pages/plan/index.vue
README.md
View file @
c40c57d
...
...
@@ -52,6 +52,7 @@ pnpm lint
-
黄色背景表示"生成中"状态
-
绿色背景表示"已完成"状态
-
使用条件类名动态切换样式
-
✅
**查看状态更新**
- 仅在预览成功后标记为已查看,返回列表不刷新位置
-
✅
**提交跳转体验**
- 提交后先关闭并重置弹框,再无固定延迟跳转结果页
-
✅
**返回重置体验**
- 结果页返回后表单不保留旧数据
...
...
src/composables/useFileOperation.js
View file @
c40c57d
...
...
@@ -63,12 +63,14 @@ export function useFileOperation() {
})
try
{
let
openResult
=
false
await
openDocument
({
filePath
:
filePath
,
showMenu
:
true
,
// 显示右上角菜单,用户可以转发、保存等
success
:
()
=>
{
// 记录成功回调
console
.
log
(
'[文件操作] ✅ openDocument success 回调触发 - 文件已打开'
)
openResult
=
true
// 文件打开后,延迟提示用户如果看不到内容该如何操作
// 使用统一的扩展名提取函数
...
...
@@ -94,6 +96,7 @@ export function useFileOperation() {
errMsg
:
err
.
errMsg
,
errorCode
:
err
.
errCode
})
openResult
=
false
// 获取文件扩展名(使用统一的扩展名提取函数)
const
fileExt
=
extractExtensionFromFile
(
item
)
...
...
@@ -169,6 +172,7 @@ export function useFileOperation() {
})
}
})
return
openResult
}
catch
(
error
)
{
// 记录异常(Promise rejection)
console
.
log
(
'[文件操作] ❌ openDocument 异常捕获:'
,
error
)
...
...
@@ -177,6 +181,7 @@ export function useFileOperation() {
icon
:
'none'
,
duration
:
2000
})
return
false
}
}
...
...
@@ -246,32 +251,38 @@ export function useFileOperation() {
// 首次打开 Office 文档,显示提示
console
.
log
(
'[文件操作] 首次打开 Office 文档,显示提示'
)
showModal
({
title
:
'预览提示'
,
content
:
`小程序对
${
fileExt
.
toUpperCase
()}
文档的预览支持有限,如果显示为空白,请点击右上角"..."菜单,选择"发送给朋友"后在电脑或其他应用中打开。\n\n是否继续预览?`
,
confirmText
:
'继续预览'
,
cancelText
:
'取消'
,
success
:
(
modalRes
)
=>
{
console
.
log
(
'[文件操作] 用户选择:'
,
modalRes
.
confirm
?
'继续预览'
:
'取消'
)
if
(
modalRes
.
confirm
)
{
// 记录用户选择,下次不再提示
try
{
Taro
.
setStorageSync
(
dontShowAgainKey
,
true
)
console
.
log
(
'[文件操作] ✅ 已保存"不再提醒"设置'
)
}
catch
(
storageErr
)
{
console
.
log
(
'[文件操作] ❌ 保存设置失败:'
,
storageErr
)
return
await
new
Promise
((
resolve
)
=>
{
showModal
({
title
:
'预览提示'
,
content
:
`小程序对
${
fileExt
.
toUpperCase
()}
文档的预览支持有限,如果显示为空白,请点击右上角"..."菜单,选择"发送给朋友"后在电脑或其他应用中打开。\n\n是否继续预览?`
,
confirmText
:
'继续预览'
,
cancelText
:
'取消'
,
success
:
async
(
modalRes
)
=>
{
console
.
log
(
'[文件操作] 用户选择:'
,
modalRes
.
confirm
?
'继续预览'
:
'取消'
)
if
(
modalRes
.
confirm
)
{
// 记录用户选择,下次不再提示
try
{
Taro
.
setStorageSync
(
dontShowAgainKey
,
true
)
console
.
log
(
'[文件操作] ✅ 已保存"不再提醒"设置'
)
}
catch
(
storageErr
)
{
console
.
log
(
'[文件操作] ❌ 保存设置失败:'
,
storageErr
)
}
const
openResult
=
await
openFile
(
downloadResult
.
tempFilePath
,
item
)
resolve
(
openResult
)
return
}
// 打开文件
openFile
(
downloadResult
.
tempFilePath
,
item
)
resolve
(
false
)
}
}
}
)
})
}
else
{
// 用户已选择"不再提醒"或非 Office 文档,直接打开
console
.
log
(
'[文件操作] 直接打开文件(已选择不再提醒 或 非 Office 文档)'
)
await
openFile
(
downloadResult
.
tempFilePath
,
item
)
const
openResult
=
await
openFile
(
downloadResult
.
tempFilePath
,
item
)
return
openResult
}
}
catch
(
error
)
{
// 确保隐藏加载提示
...
...
@@ -292,6 +303,7 @@ export function useFileOperation() {
icon
:
'none'
,
duration
:
2000
})
return
false
}
}
...
...
@@ -328,7 +340,7 @@ export function useFileOperation() {
icon
:
'none'
,
duration
:
2000
})
return
return
false
}
// 判断是否为图片文件(优先使用 extension 字段)
...
...
@@ -340,6 +352,7 @@ export function useFileOperation() {
urls
:
[
item
.
downloadUrl
],
current
:
item
.
downloadUrl
})
return
true
}
catch
(
error
)
{
console
.
error
(
'[文件操作] 图片预览失败:'
,
error
)
showToast
({
...
...
@@ -347,17 +360,27 @@ export function useFileOperation() {
icon
:
'none'
,
duration
:
2000
})
return
false
}
return
}
// 判断是否为视频文件(优先使用 extension 字段)
if
(
isVideoFile
(
item
))
{
// 视频文件:跳转到视频播放页面
Taro
.
navigateTo
({
url
:
`/pages/video-player/index?url=
${
encodeURIComponent
(
item
.
downloadUrl
)}
&title=
${
encodeURIComponent
(
item
.
title
||
item
.
fileName
)}
`
})
return
try
{
await
Taro
.
navigateTo
({
url
:
`/pages/video-player/index?url=
${
encodeURIComponent
(
item
.
downloadUrl
)}
&title=
${
encodeURIComponent
(
item
.
title
||
item
.
fileName
)}
`
})
return
true
}
catch
(
error
)
{
console
.
error
(
'[文件操作] 视频打开失败:'
,
error
)
showToast
({
title
:
'视频打开失败'
,
icon
:
'none'
,
duration
:
2000
})
return
false
}
}
// 非视频文件:下载并打开
...
...
@@ -368,7 +391,8 @@ export function useFileOperation() {
})
// 下载并打开文件
await
downloadAndOpenFile
(
item
)
const
openResult
=
await
downloadAndOpenFile
(
item
)
return
openResult
}
return
{
...
...
src/pages/plan/index.vue
View file @
c40c57d
...
...
@@ -477,30 +477,30 @@ const onView = async (item) => {
*/
const handleFileView = async (file) => {
try {
// 调用 viewAPI 标记为已查看
const viewRes = await viewAPI({ i: item.id })
if (viewRes.code === 1) {
// 更新本地状态为"已查看"
item.status = 'viewed'
// 显示提示
Taro.showToast({
title: '已标记为查看',
icon: 'success',
duration: 1000
})
const previewSuccess = await viewFile({
downloadUrl: file.file_url,
fileName: file.file_name
})
if (!previewSuccess) {
return
}
if (item.status !== 'viewed') {
const viewRes = await viewAPI({ i: item.id })
if (viewRes.code === 1) {
item.status = 'viewed'
Taro.showToast({
title: '已标记为查看',
icon: 'success',
duration: 1000
})
}
}
} catch (error) {
console.error('标记查看失败:', error)
// 即使标记失败,也继续查看文档
}
// 使用 useFileOperation 查看文档
await viewFile({
downloadUrl: file.file_url,
fileName: file.file_name
})
}
// 如果只有一个文件,直接查看
...
...
Please
register
or
login
to post a comment