From 654880e14984639dab39242e5755a9480c84c527 Mon Sep 17 00:00:00 2001
From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com>
Date: Sun, 4 Jan 2026 15:14:41 +0800
Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E6=9C=89=E4=BA=BA=E5=91=98=E8=80=83?=
=?UTF-8?q?=E5=8B=A4=E7=BB=9F=E8=AE=A1=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E8=B0=83=E8=AF=95=E5=AE=8C=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env.development | 2 +-
src/components/DocumentPreview/index.vue | 213 ++++++++++-
src/components/DocumentPreviewDemo/index.vue | 345 ++++++++++++++++++
src/pages/home/index.vue | 6 +
.../own/attendance-punch/confirm/index.vue | 7 +-
src/pages/own/attendance-punch/index.vue | 58 ++-
.../own/attendance-punch/location/index.vue | 1 +
src/pages/own/attendance-statistics/index.vue | 325 ++++++++++++-----
src/pages/work/contract-review/detail.vue | 54 ++-
src/pages/work/contract-review/index.vue | 2 +-
src/pages/work/contract-sign/detail.vue | 56 ++-
src/pages/work/contract-sign/index.vue | 18 +-
.../work/contract/contractDetails/index.vue | 111 ++++--
.../work/contract/contractInfo/index.vue | 57 +--
.../work/contract/contractPreview/index.vue | 173 +++++----
.../entry-management/face-photo/index.vue | 7 +
src/pages/work/entry-management/index.vue | 24 +-
src/pages/work/worker-entry-review/index.vue | 21 +-
.../realName/attendance/attendance-punch.js | 16 +
src/services/realName/contract.js | 8 +
.../realName/own/attendance-statistics.js | 19 +
src/static/pdf-viewer.html | 209 +++++++++++
22 files changed, 1357 insertions(+), 375 deletions(-)
create mode 100644 src/components/DocumentPreviewDemo/index.vue
create mode 100644 src/services/realName/own/attendance-statistics.js
create mode 100644 src/static/pdf-viewer.html
diff --git a/.env.development b/.env.development
index e4d0676..0554304 100644
--- a/.env.development
+++ b/.env.development
@@ -2,7 +2,7 @@
VITE_API_BASE_URL = /api
VITE_API_REAL_NAME = /bmw
VITE_API_LEADER = /leader
-VITE_API_FILE_ASE_URL = http://192.168.0.14:1917/hnAma/
+VITE_API_FILE_ASE_URL = http://192.168.0.38:18080/bnscloud/realnameapp/
# VITE_API_BASE_URL = http://192.168.0.14:1999/hd-real-name
# VITE_API_BASE_URL = http://192.168.0.234:38080/hd-real-name
# VITE_API_BASE_URL = http://192.168.0.234:38080
diff --git a/src/components/DocumentPreview/index.vue b/src/components/DocumentPreview/index.vue
index bc83ed3..d7def40 100644
--- a/src/components/DocumentPreview/index.vue
+++ b/src/components/DocumentPreview/index.vue
@@ -39,6 +39,7 @@
frameborder="0"
@load="handleIframeLoad"
@error="handleError"
+ @loadstart="handleIframeLoadStart"
>
@@ -154,6 +155,8 @@ const emit = defineEmits(['load', 'error', 'retry'])
// 预览URL
const previewUrl = ref('')
+// Blob URL(用于处理X-Frame-Options问题)
+const blobUrl = ref('')
// 加载状态
const loading = ref(false)
// 错误信息
@@ -183,25 +186,121 @@ const detectFileType = (url) => {
/**
* 获取完整的文件URL
+ * 注意:对于包含OSS签名的URL,必须保持原始编码,不做任何处理
*/
const getFullUrl = (url) => {
if (!url) return ''
- // 如果已经是完整URL,直接返回
+ // 如果已经是完整URL,直接返回(保持原始编码)
if (url.startsWith('http://') || url.startsWith('https://')) {
return url
}
- // 拼接基础URL
+ // 拼接基础URL(仅对非完整URL进行拼接)
const base = props.baseURL || import.meta.env.VITE_API_BASE_URL || ''
return base + (url.startsWith('/') ? url : '/' + url)
}
+/**
+ * 检查URL是否包含OSS签名参数
+ */
+const hasOssSignature = (url) => {
+ return url.includes('Expires=') && url.includes('OSSAccessKeyId=') && url.includes('Signature=')
+}
+
+/**
+ * 检查OSS签名URL是否过期
+ */
+const isOssUrlExpired = (url) => {
+ if (!hasOssSignature(url)) {
+ return false
+ }
+
+ try {
+ const expiresMatch = url.match(/Expires=(\d+)/)
+ if (expiresMatch) {
+ const expiresTimestamp = parseInt(expiresMatch[1], 10)
+ const currentTimestamp = Math.floor(Date.now() / 1000)
+ // 如果过期时间小于当前时间,或者剩余时间少于5分钟,认为已过期
+ return expiresTimestamp < currentTimestamp || expiresTimestamp - currentTimestamp < 300
+ }
+ } catch (e) {
+ console.error('检查OSS URL过期时间失败:', e)
+ }
+
+ return false
+}
+
+/**
+ * 检查URL是否是API接口(可能设置了X-Frame-Options)
+ */
+const isApiEndpoint = (url) => {
+ if (!url) return false
+ // 检查是否包含常见的API路径标识
+ return url.includes('/api/') || url.includes('/resource/') || url.includes('/getResourceFile')
+}
+
+/**
+ * 通过fetch下载文件并创建blob URL
+ */
+const createBlobUrl = async (url) => {
+ try {
+ const response = await fetch(url, {
+ method: 'GET',
+ headers: {
+ // 如果需要token,可以从URL中提取或通过其他方式传递
+ },
+ })
+
+ if (!response.ok) {
+ throw new Error(`HTTP error! status: ${response.status}`)
+ }
+
+ const blob = await response.blob()
+ const blobUrlValue = URL.createObjectURL(blob)
+ blobUrl.value = blobUrlValue
+ return blobUrlValue
+ } catch (err) {
+ console.error('创建blob URL失败:', err)
+ throw err
+ }
+}
+
/**
* 获取PDF预览URL
*/
-const getPdfPreviewUrl = (url) => {
- const fullUrl = getFullUrl(url)
+const getPdfPreviewUrl = async (url) => {
+ // 先获取完整URL,但保持原始编码
+ // 对于已经是完整URL的情况,直接使用,不进行任何处理
+ let fullUrl = url
+ if (!url.startsWith('http://') && !url.startsWith('https://')) {
+ // 只有非完整URL才进行拼接
+ const base = props.baseURL || import.meta.env.VITE_API_BASE_URL || ''
+ fullUrl = base + (url.startsWith('/') ? url : '/' + url)
+ }
+
+ // 重要:如果是OSS签名URL,必须保持原始编码,不进行任何URL解析操作
+ // 提前检测并直接返回,避免new URL()等操作导致URL被解码
+ if (hasOssSignature(fullUrl)) {
+ // console.log('检测到OSS签名URL,使用直接预览模式避免签名过期和URL解码问题')
+ console.log('原始URL:', fullUrl)
+ return fullUrl
+ }
+
+ // #ifdef H5
+ // 如果是API接口,可能设置了X-Frame-Options,需要使用blob URL
+ if (isApiEndpoint(fullUrl)) {
+ try {
+ const blobUrlValue = await createBlobUrl(fullUrl)
+ console.log('检测到API接口,使用blob URL避免X-Frame-Options问题')
+ return blobUrlValue
+ } catch (err) {
+ console.error('创建blob URL失败,尝试直接使用原URL:', err)
+ // 如果创建blob URL失败,回退到直接使用原URL
+ return fullUrl
+ }
+ }
+ // #endif
// 使用 pdf.js viewer 方案(适用于微信内置浏览器无法直接预览的场景)
if (props.previewService === 'pdfjs') {
@@ -210,7 +309,7 @@ const getPdfPreviewUrl = (url) => {
// 只有https的外部地址才使用pdfjs viewer
const isLocalOrHttp = fullUrl.startsWith('http://') || fullUrl.startsWith('/')
- // 检查是否是同源地址
+ // 检查是否是同源地址(注意:这里已经排除了OSS签名URL,所以可以安全使用new URL)
let isSameOrigin = false
try {
if (typeof window !== 'undefined' && window.location) {
@@ -241,7 +340,17 @@ const getPdfPreviewUrl = (url) => {
* 获取Word预览URL
*/
const getWordPreviewUrl = (url) => {
- const fullUrl = getFullUrl(url)
+ // 先获取完整URL,但保持原始编码
+ let fullUrl = url
+ if (!url.startsWith('http://') && !url.startsWith('https://')) {
+ const base = props.baseURL || import.meta.env.VITE_API_BASE_URL || ''
+ fullUrl = base + (url.startsWith('/') ? url : '/' + url)
+ }
+
+ // 重要:如果是OSS签名URL,必须保持原始编码,直接返回
+ if (hasOssSignature(fullUrl)) {
+ return fullUrl
+ }
// 方案1: 直接返回URL(可能触发下载)
if (props.previewService === 'direct') {
@@ -264,7 +373,7 @@ const getWordPreviewUrl = (url) => {
/**
* 获取预览URL
*/
-const getPreviewUrl = () => {
+const getPreviewUrl = async () => {
if (!props.fileUrl) {
return ''
}
@@ -272,7 +381,7 @@ const getPreviewUrl = () => {
const fileType = props.fileType === 'auto' ? detectFileType(props.fileUrl) : props.fileType
if (fileType === 'pdf') {
- return getPdfPreviewUrl(props.fileUrl)
+ return await getPdfPreviewUrl(props.fileUrl)
} else if (fileType === 'word') {
return getWordPreviewUrl(props.fileUrl)
}
@@ -283,7 +392,7 @@ const getPreviewUrl = () => {
/**
* 加载文档
*/
-const loadDocument = () => {
+const loadDocument = async () => {
if (!props.fileUrl) {
error.value = '文件地址不能为空'
loading.value = false
@@ -304,8 +413,8 @@ const loadDocument = () => {
return
}
- // 获取预览URL
- previewUrl.value = getPreviewUrl()
+ // 获取预览URL(可能是异步的,如果使用了blob URL)
+ previewUrl.value = await getPreviewUrl()
if (!previewUrl.value) {
error.value = '无法生成预览地址'
@@ -341,17 +450,57 @@ const loadDocument = () => {
}
} catch (err) {
console.error('加载文档失败:', err)
- error.value = '加载失败,请重试'
+ error.value = err.message || '加载失败,请重试'
loading.value = false
}
}
+/**
+ * 处理iframe开始加载
+ */
+const handleIframeLoadStart = (event) => {
+ console.log('iframe开始加载', event)
+ // 可以在这里添加加载开始的处理逻辑
+}
+
/**
* 处理iframe加载完成
*/
const handleIframeLoad = (event) => {
console.log('iframe加载完成', event)
- handleLoad()
+
+ // 延迟检查iframe内容,因为load事件可能在内容完全加载前触发
+ setTimeout(() => {
+ try {
+ const iframe = event.target
+ if (iframe && iframe.contentWindow) {
+ // 尝试检查iframe是否加载成功
+ // 如果iframe内容加载失败,可能会抛出错误
+ const iframeDoc = iframe.contentDocument || iframe.contentWindow.document
+ if (iframeDoc) {
+ // 检查是否有错误信息
+ const body = iframeDoc.body
+ if (body && body.textContent) {
+ const text = body.textContent.toLowerCase()
+ if (
+ text.includes('403') ||
+ text.includes('forbidden') ||
+ text.includes('expired')
+ ) {
+ handleError(event)
+ return
+ }
+ }
+ }
+ }
+ } catch (e) {
+ // 跨域访问iframe内容会报错,这是正常的,说明可能加载成功
+ // 或者确实是跨域问题,但这不是403错误
+ console.log('无法访问iframe内容(可能是跨域):', e.message)
+ }
+
+ handleLoad()
+ }, 500)
}
/**
@@ -378,7 +527,7 @@ const handleLoad = () => {
/**
* 处理加载错误
*/
-const handleError = () => {
+const handleError = (event) => {
// 清除超时定时器
if (loadTimeout) {
clearTimeout(loadTimeout)
@@ -386,11 +535,33 @@ const handleError = () => {
}
loading.value = false
- error.value = '文档加载失败'
+
+ // 检查是否是OSS签名过期导致的403错误
+ const fullUrl = getFullUrl(props.fileUrl)
+ let errorMessage = '文档加载失败'
+
+ // if (hasOssSignature(fullUrl) && isOssUrlExpired(fullUrl)) {
+ // errorMessage = '文档链接已过期,请刷新页面重试'
+ // } else if (event?.target?.src) {
+ // // 检查iframe的错误
+ // try {
+ // const iframe = event.target
+ // if (iframe.contentWindow) {
+ // // 尝试访问iframe内容来判断是否是403错误
+ // console.error('PDF加载失败,可能是签名过期或权限问题')
+ // errorMessage = '文档加载失败,可能是链接已过期'
+ // }
+ // } catch (e) {
+ // // 跨域访问iframe内容会报错,这是正常的
+ // console.error('PDF加载失败:', e)
+ // }
+ // }
+
+ error.value = errorMessage
emit('error', {
fileUrl: props.fileUrl,
fileType: currentFileType.value,
- error: '文档加载失败',
+ error: errorMessage,
})
}
@@ -424,7 +595,8 @@ const handleRetry = () => {
* 下载文档
*/
const handleDownload = () => {
- const fullUrl = getFullUrl(props.fileUrl)
+ // const fullUrl = getFullUrl(props.fileUrl)
+ const fullUrl = props.fileUrl
// #ifdef H5
// H5环境:直接打开新窗口下载
@@ -478,12 +650,17 @@ watch(
},
)
-// 组件卸载时清除定时器
+// 组件卸载时清除定时器和blob URL
onUnmounted(() => {
if (loadTimeout) {
clearTimeout(loadTimeout)
loadTimeout = null
}
+ // 释放blob URL,避免内存泄漏
+ if (blobUrl.value) {
+ URL.revokeObjectURL(blobUrl.value)
+ blobUrl.value = ''
+ }
})
diff --git a/src/components/DocumentPreviewDemo/index.vue b/src/components/DocumentPreviewDemo/index.vue
new file mode 100644
index 0000000..8be5ec9
--- /dev/null
+++ b/src/components/DocumentPreviewDemo/index.vue
@@ -0,0 +1,345 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ loadingText }}
+
+
+
+
+
+
+ {{ error }}
+
+ 重试
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/home/index.vue b/src/pages/home/index.vue
index 20fcd12..98667c7 100644
--- a/src/pages/home/index.vue
+++ b/src/pages/home/index.vue
@@ -273,6 +273,12 @@ const showModule = (label) => {
.find((item) => item.name === label)
}
+const handlePdfDebug = () => {
+ uni.navigateTo({
+ url: '/pages/home/pdf-debug/index',
+ })
+}
+
onLoad(async () => {
checkFromRedirect()
diff --git a/src/pages/own/attendance-punch/confirm/index.vue b/src/pages/own/attendance-punch/confirm/index.vue
index ee0a8c3..31aef19 100644
--- a/src/pages/own/attendance-punch/confirm/index.vue
+++ b/src/pages/own/attendance-punch/confirm/index.vue
@@ -116,6 +116,7 @@ const commonStore = useCommonStore()
const punchType = ref(1) // 打卡类型 1:计日 2:计件 3:窝工
const contractId = ref('') // 合同ID(仅计件打卡)
const gxId = ref('') // 工序桩位ID(仅计件打卡)
+const gxName = ref('') // 工序桩位名称(仅计件打卡)
const longitude = ref('') // 经度
const latitude = ref('') // 纬度
const address = ref('') // 地址
@@ -337,7 +338,7 @@ const handleSubmit = async () => {
address: address.value || '',
// 计件相关
- gxName: '', // 后端暂未提供名称,先留空
+ gxName: '',
gxId: gxId.value || '',
// 其他字段
@@ -380,6 +381,7 @@ const handleBack = () => {
}
onLoad((options) => {
+ console.log(options, 'options参数')
// 获取传递的参数
if (options.punchType) {
punchType.value = parseInt(options.punchType)
@@ -390,6 +392,9 @@ onLoad((options) => {
if (options.gxId) {
gxId.value = options.gxId
}
+ if (options.gxName) {
+ gxName.value = options.gxName
+ }
if (options.longitude) {
longitude.value = options.longitude
}
diff --git a/src/pages/own/attendance-punch/index.vue b/src/pages/own/attendance-punch/index.vue
index 75d83ee..cbea04c 100644
--- a/src/pages/own/attendance-punch/index.vue
+++ b/src/pages/own/attendance-punch/index.vue
@@ -105,7 +105,8 @@
@@ -65,6 +65,7 @@
disabled
v-model="form.partyA"
placeholder="甲方公司名称"
+ disabledColor="#F5F5F5"
/>
-
+
@@ -92,6 +99,7 @@
disabled
v-model="form.partAPhone"
placeholder="联系电话"
+ disabledColor="#F5F5F5"
/>
-
+
-
+
@@ -430,6 +452,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getContentStyle } from '@/utils/safeArea'
import { realNameHttp } from '@/utils/realNameHttp'
+import { useMemberStore } from '@/stores'
import {
getWorkerInfoByIdNumberAPI,
getWorkerPhotoByIdNumberAPI,
@@ -443,6 +466,7 @@ import Signature from '@/components/Signature/index.vue'
import CommonPicker from '@/components/CommonPicker/index.vue'
import DatePicker from '@/components/DatePicker/index.vue'
+const memberStore = useMemberStore()
const iptIdNumber = ref('')
const videoInfo = ref(null)
const shortMessageImp = ref('')
@@ -552,36 +576,39 @@ const handleFaceDelete = () => {
// 附件(全部为pdf)
const attachments = ref([
{
- url: 'http://192.168.0.14:1917/hnAma/gzRealName/contract/pdf/2025/12/22/1766388427803.pdf',
+ url: '',
isSign: false,
fileType: '1',
title: '施工人员健康承诺书',
+ initPath: '',
},
{
- url: 'https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf',
+ url: '',
isSign: false,
fileType: '2',
title: '安全协议书',
+ initPath: '',
},
{
title: '施工人员安全告知书',
fileType: '3',
isSign: false,
- // url: 'http://192.168.0.14:1917/hnAma/gzRealName/contract/pdf/施工人员安全告知书.pdf',
- // url: 'http://192.168.0.14:1917/hnAma/gzRealName/contract/pdf/施工人员安全告知书.pdf',
- url: 'http://192.168.0.38:18080/bnscloud/realnameapp/gzRealName/contract/pdf/施工人员安全告知书.pdf',
+ url: ``,
+ initPath: '',
},
{
- url: 'http://bns-cloud.oss-cn-beijing.aliyuncs.com/upload/app/lsdPhoto/pdf/2025/12/24/01d319cb-a09f-4fe6-a16e-b34491913c94.pdf?Expires=1766631029&OSSAccessKeyId=TMP.3KnER1yK3SmuHqhpR7cyButgj9YipTKQazvma5ESj1VAHwJDZY83yvgyMFjra1SWYEFcbrmrQhRcoSD65kfTzuPQrkGPzY&Signature=qRCf3f4qPiWbmKDZu5%2BdVoL5ZCU%3D',
+ url: '',
isSign: false,
fileType: '5',
title: '签订用工协议承诺书',
+ initPath: '',
},
{
- url: 'https://bns-cloud.oss-cn-beijing.aliyuncs.com/upload/app/lsdPhoto/pdf/2025/12/24/01d319cb-a09f-4fe6-a16e-b34491913c94.pdf?Expires=1766630782&OSSAccessKeyId=TMP.3KnER1yK3SmuHqhpR7cyButgj9YipTKQazvma5ESj1VAHwJDZY83yvgyMFjra1SWYEFcbrmrQhRcoSD65kfTzuPQrkGPzY&Signature=Lg%2FHxLITIMnaQnWfjGOb1h5rcxc%3D',
+ url: '',
isSign: false,
fileType: '4',
title: '安全承诺书',
+ initPath: '',
},
])
@@ -661,7 +688,7 @@ const handlePreview = (item) => {
}
// 兜底:H5 等环境 eventChannel 不可用时,使用全局事件
-const handleSignedFallback = ({ fileType, newFileUrl, startDate, endDate }) => {
+const handleSignedFallback = ({ fileType, newFileUrl, startDate, endDate, initPath }) => {
const target = attachments.value.find((attach) => attach.fileType === fileType)
if (target) {
target.isSign = true
@@ -670,6 +697,7 @@ const handleSignedFallback = ({ fileType, newFileUrl, startDate, endDate }) => {
if (fileType != 3) {
target.url = newFileUrl
+ target.initPath = initPath
}
if (fileType == 2) {
@@ -679,6 +707,19 @@ const handleSignedFallback = ({ fileType, newFileUrl, startDate, endDate }) => {
onMounted(() => {
uni.$on('contract-signed', handleSignedFallback)
+
+ uni.request({
+ url: `${import.meta.env.VITE_API_FILE_ASE_URL}api/resource/getResourceFile?filePath=aqgzs.pdf&token=${memberStore.realNameUserInfo.token}`,
+ method: 'GET',
+ success: (res) => {
+ console.log(res)
+ attachments.value[2].url = res?.data?.base64
+ console.log(attachments.value[2].url)
+ },
+ fail: (err) => {
+ console.log(err)
+ },
+ })
})
onUnmounted(() => {
@@ -780,7 +821,7 @@ const handlePreviewContract = async () => {
partBSign: form.value.signatureUrl,
message,
signingDate: nowDate,
- faceUrl: videoInfo.value?.faceUrl || '',
+ faceUrl: form.value?.faceUrl || '',
messageTime: nowDateTime,
shortMessage,
proId: form.value?.proId,
@@ -823,7 +864,7 @@ const handlePreviewContract = async () => {
}
uni.navigateTo({
- url: `/pages/work/contract/contractPreview/index?contractUrl=${result.obj}&fileType=pdf&personInfo=${encodeURIComponent(JSON.stringify(getFileAddressParams.value))}&otherInfo=${encodeURIComponent(JSON.stringify(otherInfo))}&isContract=true&attachments=${encodeURIComponent(JSON.stringify(attachments.value))}`,
+ url: `/pages/work/contract/contractPreview/index?contractUrl=${result.resMsg}&contractNewUrl=${encodeURIComponent(result.obj)}&fileType=pdf&personInfo=${encodeURIComponent(JSON.stringify(getFileAddressParams.value))}&otherInfo=${encodeURIComponent(JSON.stringify(otherInfo))}&isContract=true&attachments=${encodeURIComponent(JSON.stringify(attachments.value))}`,
})
} catch (error) {
uni.$u.toast(error?.data?.obj || '预览失败')
@@ -902,19 +943,20 @@ const handleGetWorkerInfo = async () => {
getFileAddressParams.value.partBPhone = phone
getFileAddressParams.value.effectDate = form.value.effectDate
- // const file1 = await getFileAddressFun('1') // 施工人员健康承诺书
- // const file2 = await getFileAddressFun('2') // 安全协议书
- // const file4 = await getFileAddressFun('5') // 签订用工协议承诺书
- // const file5 = await getFileAddressFun('4') // 安全承诺书
+ const file1 = await getFileAddressFun('1') // 施工人员健康承诺书
+ const file2 = await getFileAddressFun('2') // 安全协议书
+ const file4 = await getFileAddressFun('5') // 签订用工协议承诺书
+ const file5 = await getFileAddressFun('4') // 安全承诺书
- // const fileList = [file1, file2, file4, file5]
+ const fileList = [file1, file2, file4, file5]
- // attachments.value.forEach((e) => {
- // const file = fileList.find((f) => f.type === e.fileType)
- // if (file) {
- // e.url = file.url
- // }
- // })
+ attachments.value.forEach((e) => {
+ const file = fileList.find((f) => f.type === e.fileType)
+ if (file) {
+ e.url = file.url
+ e.initPath = file.initPath
+ }
+ })
}
const { obj: photoRes } = await getWorkerPhotoByIdNumberAPI({
@@ -922,10 +964,10 @@ const handleGetWorkerInfo = async () => {
})
if (photoRes !== 'is null') {
- const { signaturePhoto, facePhoto } = photoRes
- form.value.signaturePath = signaturePhoto.startsWith('http')
- ? signaturePhoto
- : import.meta.env.VITE_API_FILE_ASE_URL + signaturePhoto
+ const { signaturePhoto, facePhoto, signaturePhotoUrl } = photoRes
+ form.value.signaturePath = signaturePhotoUrl.startsWith('http')
+ ? signaturePhotoUrl
+ : import.meta.env.VITE_API_FILE_ASE_URL + signaturePhotoUrl
form.value.signatureUrl = signaturePhoto
form.value.faceUrl = facePhoto
}
@@ -933,9 +975,10 @@ const handleGetWorkerInfo = async () => {
// 获取附件信息
const getFileAddressFun = async (type) => {
- const { resMsg: res } = await getFileAddressAPI({ ...getFileAddressParams.value, type })
+ const res = await getFileAddressAPI({ ...getFileAddressParams.value, type })
return {
- url: res,
+ url: res?.obj.bast64,
+ initPath: res?.obj.url,
type,
}
}
diff --git a/src/pages/work/contract/contractInfo/index.vue b/src/pages/work/contract/contractInfo/index.vue
index ed57aa2..6136928 100644
--- a/src/pages/work/contract/contractInfo/index.vue
+++ b/src/pages/work/contract/contractInfo/index.vue
@@ -32,7 +32,7 @@
-
+ /> -->
+
+
@@ -80,10 +82,14 @@ import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import NavBarModal from '@/components/NavBarModal/index.vue'
import DocumentPreview from '@/components/DocumentPreview/index.vue'
+import DocumentPreviewDemo from '@/components/DocumentPreviewDemo/index.vue'
import { getContentStyle } from '@/utils/safeArea'
import { realNameHttp } from '@/utils/realNameHttp'
import { initParams } from '@/utils/initParams'
+import { useMemberStore } from '@/stores'
+import { getPreviewContractAddressAPI } from '@/services/realName/contract.js'
+const memberStore = useMemberStore()
const contentStyle = computed(() => {
return getContentStyle({
includeNavBar: true,
@@ -132,44 +138,19 @@ const loadContractDocument = async () => {
loading.value = true
error.value = ''
- // TODO: 等后台接口准备好后,取消注释以下代码
- // if (!contractData.value?.templateValue) {
- // error.value = '缺少合同模板信息'
- // loading.value = false
- // return
- // }
-
- // // 调用接口获取合同文档
- // const res = await realNameHttp({
- // url: `/contract/getDocument?${initParams({
- // templateId: contractData.value.templateValue,
- // })}`,
- // method: 'POST',
- // })
-
- // if (res.res === 1 && res.obj) {
- // const fileUrl = res.obj.documentUrl || res.obj.fileUrl || res.obj.url
- // if (fileUrl) {
- // pdfUrl.value = fileUrl
- // } else {
- // error.value = '未获取到文档地址'
- // }
- // } else {
- // error.value = res.resMsg || '获取合同文档失败'
- // }
-
- // 临时使用公开的测试文档链接
- // 使用一个公开可访问的Word文档示例
- const testDocumentUrl =
- 'https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf'
- // 'https://calibre-ebook.com/downloads/demos/demo.docx'
- // 模拟接口延迟
- await new Promise((resolve) => setTimeout(resolve, 1000))
-
- documentUrl.value = testDocumentUrl
+ uni.request({
+ url: `${import.meta.env.VITE_API_FILE_ASE_URL}api/resource/getResourceFile?filePath=ygxy.pdf&token=${memberStore.realNameUserInfo.token}`,
+ method: 'GET',
+ success: (res) => {
+ console.log(res)
+ documentUrl.value = res?.data?.base64
+ },
+ fail: (err) => {
+ console.log(err)
+ },
+ })
} catch (err) {
console.error('加载合同文档失败:', err)
- error.value = '加载失败,请重试'
} finally {
loading.value = false
}
diff --git a/src/pages/work/contract/contractPreview/index.vue b/src/pages/work/contract/contractPreview/index.vue
index c17fd0e..c7f65ac 100644
--- a/src/pages/work/contract/contractPreview/index.vue
+++ b/src/pages/work/contract/contractPreview/index.vue
@@ -1,26 +1,34 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+ 加载中...
+
+
+
+
+
+
+
+