From 46a34253aba99e1e4e9842c74387fc0ff8455062 Mon Sep 17 00:00:00 2001
From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com>
Date: Tue, 16 Dec 2025 16:45:26 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Signature/index.vue | 65 ++-
.../work/contract/contractDetails/index.vue | 497 +++++++++++++++---
.../work/contract/contractInfo/index.vue | 9 +-
.../work/contract/contractPreview/index.vue | 342 +++++++++++-
src/pages/work/contract/uploadVideo/index.vue | 6 +-
.../work/contract/videoConfirm/index.vue | 48 +-
src/services/realName/contract.js | 16 +
src/utils/httpFactory.js | 6 +-
vite.config.js | 3 +-
9 files changed, 888 insertions(+), 104 deletions(-)
diff --git a/src/components/Signature/index.vue b/src/components/Signature/index.vue
index 41718f9..824f417 100644
--- a/src/components/Signature/index.vue
+++ b/src/components/Signature/index.vue
@@ -2,10 +2,10 @@
-
+
- 签名区域
+ 签名区域
+ >
+
@@ -33,7 +34,7 @@ const props = defineProps({
},
height: {
type: Number,
- default: 240,
+ default: 280,
},
lineWidth: {
type: Number,
@@ -50,14 +51,21 @@ const emit = defineEmits(['save', 'clear'])
const ctx = ref(null)
const isDrawing = ref(false)
const lastPoint = ref({ x: 0, y: 0 })
+// 是否已经有笔迹,用于判断空白签名
+const hasDrawn = ref(false)
-onMounted(() => {
- const instance = getCurrentInstance()
- ctx.value = uni.createCanvasContext(props.canvasId, instance)
+const setupCtx = () => {
+ if (!ctx.value) return
ctx.value.setStrokeStyle(props.strokeColor)
ctx.value.setLineWidth(props.lineWidth)
ctx.value.setLineCap('round')
ctx.value.setLineJoin('round')
+}
+
+onMounted(() => {
+ const instance = getCurrentInstance()
+ ctx.value = uni.createCanvasContext(props.canvasId, instance)
+ setupCtx()
ctx.value.draw()
})
@@ -94,6 +102,8 @@ const handleMove = (e) => {
ctx.value.stroke()
ctx.value.draw(true)
+ // 只要产生过一次笔迹,就认为有签名
+ hasDrawn.value = true
lastPoint.value = p
}
@@ -114,7 +124,11 @@ const getPoint = (e) => {
const handleClear = () => {
ctx.value.clearRect(0, 0, 1000, 600)
- ctx.value.draw()
+ // draw(false) 会重置样式,需重新设置颜色等
+ ctx.value.draw(false, () => {
+ setupCtx()
+ })
+ hasDrawn.value = false
emit('clear')
}
@@ -134,6 +148,33 @@ const handleSave = () => {
instance,
)
}
+
+const exportSignature = () => {
+ // 空白画布,不导出图片,直接提示
+ if (!hasDrawn.value) {
+ uni.$u.toast('请先完成签名')
+ return Promise.reject(new Error('EMPTY_SIGNATURE'))
+ }
+
+ const instance = getCurrentInstance()
+ return new Promise((resolve, reject) => {
+ uni.canvasToTempFilePath(
+ {
+ canvasId: props.canvasId,
+ success: (res) => resolve(res.tempFilePath),
+ fail: (err) => {
+ uni.$u.toast('导出签名失败')
+ reject(err)
+ },
+ },
+ instance,
+ )
+ })
+}
+
+defineExpose({
+ exportSignature,
+})
-
diff --git a/src/pages/work/contract/uploadVideo/index.vue b/src/pages/work/contract/uploadVideo/index.vue
index e00c3ea..063884c 100644
--- a/src/pages/work/contract/uploadVideo/index.vue
+++ b/src/pages/work/contract/uploadVideo/index.vue
@@ -139,13 +139,13 @@ const checkVideoSize = (size) => {
*/
const checkVideoDuration = (duration) => {
// 限制最大60秒
- const maxDuration = 60
+ const maxDuration = 20
if (duration > maxDuration) {
uni.$u.toast(`视频时长过长,请选择不超过${maxDuration}秒的视频`)
return false
}
- if (duration < 1) {
- uni.$u.toast('视频时长过短,请选择至少1秒的视频')
+ if (duration < 2) {
+ uni.$u.toast('视频时长过短,请选择至少2秒的视频')
return false
}
return true
diff --git a/src/pages/work/contract/videoConfirm/index.vue b/src/pages/work/contract/videoConfirm/index.vue
index c66efe8..6ab2399 100644
--- a/src/pages/work/contract/videoConfirm/index.vue
+++ b/src/pages/work/contract/videoConfirm/index.vue
@@ -72,8 +72,9 @@