diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts
index 2bcd443a..d3573b28 100644
--- a/docs/.vitepress/config.mts
+++ b/docs/.vitepress/config.mts
@@ -337,7 +337,12 @@ export default defineConfig({
}, {
link: "/component/password-input",
text: "PasswordInput 密码输入框"
- }]
+ },
+ , {
+ link: "/component/signature",
+ text: "Signature 签名"
+ }
+ ]
}, {
text: "反馈",
collapsed: false,
diff --git a/docs/component/signature.md b/docs/component/signature.md
new file mode 100644
index 00000000..fece7562
--- /dev/null
+++ b/docs/component/signature.md
@@ -0,0 +1,87 @@
+# Signature 组件
+`Signature`组件是一个用于生成手写签名的 Vue 组件。它提供了多种自定义选项,包括签名笔的颜色、宽度以及自定义操作按钮
+## 基础用法
+```html
+
+
+```
+
+```typescript
+const img = ref({
+ width: 0,
+ height: 0,
+ src: ''
+})
+function confirm(result: FileType) {
+ img.value.src = result.tempFilePath
+ img.value.height = result.height
+ img.value.width = result.width
+}
+```
+## 自定义颜色
+`pen-color`设置签名笔的颜色,默认为`黑色`
+```html
+
+```
+
+
+## 自定义宽度
+`line-width`设置签名笔的宽度,默认为`2`。
+```html
+
+```
+
+## 自定义按钮
+通过`footer`插槽可以自定义按钮
+```html
+
+
+ 开始签名
+ 清除
+ 确认
+
+
+```
+```typescript
+const disabled = ref(true)
+
+function changeDisabled() {
+ disabled.value = false
+}
+```
+## Attributes
+| 参数 | 说明 | 类型 | 可选值 | 默认值| 最低版本 |
+|-----|------|-----|-------|-------|--------|
+| penColor | 签名笔颜色 | String | -- | #000000 | -- |
+| lineWidth | 签名笔宽度 | Number | -- | 2 | -- |
+| height | 画布的高度 | Number | -- | 200 | -- |
+| width | 画布的宽度 | Number | -- | 300 | -- |
+| clearText | 清空按钮的文本 | String |-- | 清空 | -- |
+| confirmText | 确认按钮的文本 | String | -- | 确认 | -- |
+| fileType | 目标文件的类型,[wx.canvasToTempFilePath属性介绍](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html#%E5%8F%82%E6%95%B0) | String | -- | png | -- |
+| quality | 目标文件的类型,[wx.canvasToTempFilePath属性介绍](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html#%E5%8F%82%E6%95%B0) | Number | -- | 1 |-- |
+| exportScale | 导出图片的缩放比例 | Number | -- | 1 |-- |
+| disabled | 是否禁用签名板 | Boolean | -- | false | -- |
+
+## Slot
+
+| name | 说明 |参数 | 最低版本 |
+| ------- | ------------------------ |--- | -------- |
+| footer | 自定义footer | `{ clear, confirm }` |- |
+
+## Events
+
+| 事件名称 | 说明 | 参数 | 最低版本 |
+|---------|-----|-----|---------|
+| confirm | 点击确认按钮时触发 | `{tempFilePath, width, height}` 分别为生成文件的临时路径 (本地路径)、生成图片宽、生成图片高| - |
+| clear | 点击清空按钮时触发 | - | - |
+| touchstart | 按下时触发 | `event`| - |
+| touchend | 按下结束时触发 | `event` | - |
+
+## Methods
+对外暴露函数
+
+| 事件名称 | 说明 | 参数 | 最低版本 |
+|--------|------|-----|---------|
+| confirm | 点击确认按钮时触发 | `{tempFilePath, width, height}` 分别为生成文件的临时路径 (本地路径)、生成图片宽、生成图片高| - |
+| clear | 点击清空按钮时触发 | - | - |
diff --git a/src/pages.json b/src/pages.json
index fb4b38d9..879967a4 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -27,7 +27,6 @@
"mp-alipay": {
"allowsBounceVertical": "NO"
},
-
"navigationBarTitleText": "Icon 图标"
}
},
@@ -802,6 +801,16 @@
"navigationBarTitleText": "PasswordInput 密码输入框"
}
},
+ {
+ "path": "pages/signature/Index",
+ "name": "signature",
+ "style": {
+ "mp-alipay": {
+ "allowsBounceVertical": "NO"
+ },
+ "navigationBarTitleText": "Signature 签名"
+ }
+ },
{
"path": "pages/backtop/Index",
"name": "backtop",
@@ -858,7 +867,6 @@
"backgroundColorTop": "@bgColorTop",
"backgroundColorBottom": "@bgColorBottom",
"navigationStyle": "default"
-
// "navigationBarTextStyle": "black",
// "navigationBarBackgroundColor": "#FFF",
// "backgroundColor": "#F8F8F8"
diff --git a/src/pages/index/Index.vue b/src/pages/index/Index.vue
index b16d9967..bd5f8712 100644
--- a/src/pages/index/Index.vue
+++ b/src/pages/index/Index.vue
@@ -218,6 +218,10 @@ const list = ref([
{
id: 'passwordInput',
name: 'PasswordInput 密码输入框'
+ },
+ {
+ id: 'signature',
+ name: 'Signature 签名'
}
]
},
@@ -427,37 +431,45 @@ onShareTimeline(() => {
.kind-list__item {
background: $-dark-background2;
}
+
.title {
color: $-dark-color;
}
+
:deep(.wd-cell__label) {
color: $-dark-color3 !important;
}
+
.kind-list__img {
filter: invert(100%);
}
}
+
.page__hd {
padding: 40px 40px 30px;
margin-bottom: 30px;
background: #fff;
}
+
.page__title {
text-align: left;
font-size: 20px;
font-weight: 400;
color: #0083ff;
}
+
.page__desc {
margin-top: 20px;
color: #999;
text-align: left;
font-size: 12px;
}
+
.page__bd {
padding: 0 15px 30px 20px;
user-select: none;
}
+
.logo {
display: inline-block;
margin-right: 14px;
@@ -468,10 +480,12 @@ onShareTimeline(() => {
background-size: cover;
vertical-align: middle;
}
+
.inline {
display: inline-block;
vertical-align: middle;
}
+
.version {
font-size: 14px;
}
@@ -479,20 +493,24 @@ onShareTimeline(() => {
.wd-cell_access {
padding: 15px 20px;
}
+
.wd-cell__ft {
padding-right: 16px;
position: relative;
}
+
.wd-cells {
position: relative;
margin-top: 0;
opacity: 0;
transform: translateY(-50%);
transition: 0.3s;
+
:deep(.wd-cell__label) {
color: rgba(0, 0, 0, 0.65);
}
}
+
.wd-cells_show {
opacity: 1;
transform: translateY(0);
@@ -502,6 +520,7 @@ onShareTimeline(() => {
border-radius: 30px;
background: #fff;
overflow: hidden;
+
&:not(:last-child) {
margin-bottom: 20px;
}
@@ -521,6 +540,7 @@ onShareTimeline(() => {
height: 0;
overflow: hidden;
}
+
.kind-list__item-bd_show {
height: auto;
}
@@ -528,13 +548,16 @@ onShareTimeline(() => {
.wd-flex {
display: flex;
}
+
.wd-flex__item {
flex: 1;
}
+
.title {
font-size: 14px;
color: rgba(0, 0, 0, 0.85);
}
+
.page-name {
font-size: 12px;
color: rgba(0, 0, 0, 0.65);
diff --git a/src/pages/signature/Index.vue b/src/pages/signature/Index.vue
new file mode 100644
index 00000000..429c0c8a
--- /dev/null
+++ b/src/pages/signature/Index.vue
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 开始签名
+ 清除
+ 确认
+
+
+
+
+
+
diff --git a/src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss b/src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss
index f7016a32..79dec126 100644
--- a/src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss
+++ b/src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss
@@ -953,3 +953,8 @@ $-floating-panel-bar-height: var(--wot-floating-panel-bar-height, 3px) !default;
$-floating-panel-bar-bg: var(--wot-floating-panel-bar-bg, $-color-gray-5) !default; // bar 背景色
$-floating-panel-bar-radius: var(--wot-floating-panel-bar-radius, 4px) !default; // bar 圆角
$-floating-panel-content-bg: var(--wot-floating-panel-content-bg, $-color-white) !default; // 内容背景色
+
+/* signature */
+$-signature-bg: var(--wot-signature-bg, $-color-white) !default; // 背景色
+$-signature-radius: var(--wot-signature-radius, 4px) !default; // 圆角
+$-signature-border: var(--wot-signature-border, 1px solid $-color-gray-5) !default; // 边框圆角
diff --git a/src/uni_modules/wot-design-uni/components/wd-signature/index.scss b/src/uni_modules/wot-design-uni/components/wd-signature/index.scss
new file mode 100644
index 00000000..f452a644
--- /dev/null
+++ b/src/uni_modules/wot-design-uni/components/wd-signature/index.scss
@@ -0,0 +1,23 @@
+@import '../common/abstracts/variable';
+@import '../common/abstracts/mixin';
+
+@include b(signature) {
+ @include e(context){
+ justify-content: center;
+ align-items: center;
+ display: flex;
+ overflow: hidden;
+ background: $-signature-bg;
+ border-radius:$-signature-radius;
+ border:$-signature-border;
+ }
+ @include e(footer)
+ {
+ margin-top: 4px;
+ justify-content: flex-end;
+ display: flex;
+ & .wd-button + .wd-button{
+ margin-left: 4px;
+ }
+ }
+}
diff --git a/src/uni_modules/wot-design-uni/components/wd-signature/types.ts b/src/uni_modules/wot-design-uni/components/wd-signature/types.ts
new file mode 100644
index 00000000..67820fed
--- /dev/null
+++ b/src/uni_modules/wot-design-uni/components/wd-signature/types.ts
@@ -0,0 +1,65 @@
+/*
+ * @Author: 810505339
+ * @Date: 2025-01-10 20:03:57
+ * @LastEditors: 810505339
+ * @LastEditTime: 2025-01-11 23:03:44
+ * @FilePath: \wot-design-uni\src\uni_modules\wot-design-uni\components\wd-signature\types.ts
+ * 记得注释
+ */
+import type { ExtractPropTypes, Prop, PropType } from 'vue'
+import { baseProps, makeBooleanProp, makeNumberProp, makeRequiredProp } from '../common/props'
+
+export const signatureProps = {
+ ...baseProps,
+ penColor: {
+ type: String,
+ default: '#000'
+ },
+ lineWidth: {
+ type: Number,
+ default: 3
+ },
+ height: {
+ type: Number,
+ default: 200
+ },
+ width: {
+ type: Number,
+ default: 300
+ },
+ clearText: {
+ type: String,
+ default: '清空'
+ },
+ confirmText: {
+ type: String,
+ default: '确认'
+ },
+ fileType: {
+ type: String,
+ default: 'png'
+ },
+ quality: {
+ type: Number,
+ default: 1
+ },
+ exportScale: {
+ type: Number,
+ default: 1
+ },
+ disabled: {
+ type: Boolean,
+ default: false
+ }
+}
+export type FileType = {
+ tempFilePath: string
+ width: number
+ height: number
+}
+export type SignatureExpose = {
+ /** 点击清除按钮清除签名 */
+ clear: () => void
+ /** 点击确定按钮 */
+ confirm: (result: FileType) => void
+}
diff --git a/src/uni_modules/wot-design-uni/components/wd-signature/wd-signature.vue b/src/uni_modules/wot-design-uni/components/wd-signature/wd-signature.vue
new file mode 100644
index 00000000..9445e7c7
--- /dev/null
+++ b/src/uni_modules/wot-design-uni/components/wd-signature/wd-signature.vue
@@ -0,0 +1,239 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/uni_modules/wot-design-uni/global.d.ts b/src/uni_modules/wot-design-uni/global.d.ts
index 291096d7..632bcdf4 100644
--- a/src/uni_modules/wot-design-uni/global.d.ts
+++ b/src/uni_modules/wot-design-uni/global.d.ts
@@ -1,3 +1,11 @@
+/*
+ * @Author: 810505339
+ * @Date: 2025-01-11 23:03:12
+ * @LastEditors: 810505339
+ * @LastEditTime: 2025-01-11 23:03:24
+ * @FilePath: \wot-design-uni\src\uni_modules\wot-design-uni\global.d.ts
+ * 记得注释
+ */
declare module 'vue' {
// Helper for Volar
export interface GlobalComponents {
@@ -92,6 +100,7 @@ declare module 'vue' {
WdText: typeof import('./components/wd-text/wd-text.vue')['default']
WdCountTo: typeof import('./components/wd-count-to/wd-count-to.vue')['default']
WdFloatingPanel: typeof import('./components/wd-floating-panel/wd-floating-panel.vue')['default']
+ WdSignature: typeof import('./components/wd-signature/wd-signature.vue')['default']
}
}