@didaoktv/didaoui-uniapp 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -7
- package/components/dd-action-sheet/dd-action-sheet.vue +3 -3
- package/components/dd-album/album.js +19 -0
- package/components/dd-album/dd-album.vue +345 -0
- package/components/dd-album/props.js +89 -0
- package/components/dd-avatar/avatar.js +19 -0
- package/components/dd-avatar/dd-avatar.vue +172 -160
- package/components/dd-avatar/props.js +84 -0
- package/components/dd-avatar-group/avatarGroup.js +14 -0
- package/components/dd-avatar-group/dd-avatar-group.vue +110 -0
- package/components/dd-avatar-group/props.js +57 -0
- package/components/dd-badge/dd-badge.vue +2 -2
- package/components/dd-barcode/dd-barcode.vue +1030 -0
- package/components/dd-bill-detail/dd-bill-detail.vue +265 -0
- package/components/dd-button/dd-button.vue +17 -17
- package/components/dd-calendar/dd-calendar.vue +357 -0
- package/components/dd-canvas/dd-canvas.vue +1088 -0
- package/components/dd-capsule-button/dd-capsule-button.vue +6 -6
- package/components/dd-car-keyboard/carKeyboard.js +6 -0
- package/components/dd-car-keyboard/dd-car-keyboard.vue +315 -0
- package/components/dd-car-keyboard/props.js +19 -0
- package/components/dd-cascader/dd-cascader.vue +405 -0
- package/components/dd-cell/dd-cell.vue +50 -23
- package/components/dd-cell-group/dd-cell-group.vue +32 -25
- package/components/dd-champion-card/dd-champion-card.vue +4 -4
- package/components/dd-checkbox/dd-checkbox.vue +30 -39
- package/components/dd-checkbox-group/dd-checkbox-group.vue +67 -0
- package/components/dd-copy/dd-copy.vue +74 -0
- package/components/dd-coupon/dd-coupon.vue +368 -0
- package/components/dd-cropper/dd-cropper.vue +1297 -0
- package/components/dd-dialog/dd-dialog.vue +1 -1
- package/components/dd-divider/dd-divider.vue +3 -3
- package/components/dd-dropdown-item/dd-dropdown-item.vue +5 -5
- package/components/dd-empty-state/dd-empty-state.vue +1 -1
- package/components/dd-field/dd-field.vue +531 -106
- package/components/dd-form/dd-form.vue +116 -0
- package/components/dd-form/rules.ts +84 -0
- package/components/dd-goods-sku/dd-goods-sku.vue +434 -0
- package/components/dd-icon/dd-icon.vue +2 -2
- package/components/dd-image/dd-image.vue +4 -4
- package/components/dd-input/dd-input.vue +5 -5
- package/components/dd-keyboard/dd-keyboard.vue +178 -0
- package/components/dd-keyboard/keyboard.js +22 -0
- package/components/dd-keyboard/props.js +89 -0
- package/components/dd-link/dd-link.vue +87 -0
- package/components/dd-link/link.js +18 -0
- package/components/dd-link/props.js +44 -0
- package/components/dd-list-cell/dd-list-cell.vue +4 -4
- package/components/dd-loading/dd-loading.vue +1 -1
- package/components/dd-loadmore/dd-loadmore.vue +2 -2
- package/components/dd-markdown/dd-markdown.vue +344 -0
- package/components/dd-markdown/marked.esm.mjs +7 -0
- package/components/dd-mini-program-navbar/dd-mini-program-navbar.vue +9 -9
- package/components/dd-navigation/dd-navigation.vue +5 -5
- package/components/dd-number-keyboard/dd-number-keyboard.vue +200 -0
- package/components/dd-number-keyboard/numberKeyboard.js +8 -0
- package/components/dd-number-keyboard/props.js +24 -0
- package/components/dd-parse/dd-parse.vue +534 -0
- package/components/dd-parse/node/handler.wxs +26 -0
- package/components/dd-parse/node/node.vue +603 -0
- package/components/dd-parse/parse.js +13 -0
- package/components/dd-parse/parser.js +1400 -0
- package/components/dd-parse/props.js +57 -0
- package/components/dd-popover/dd-popover.vue +10 -10
- package/components/dd-popover-item/dd-popover-item.vue +3 -3
- package/components/dd-popup/dd-popup.vue +5 -5
- package/components/dd-poster/dd-poster.vue +695 -0
- package/components/dd-progress/dd-progress.vue +3 -3
- package/components/dd-pull-refresh/dd-pull-refresh.vue +3 -3
- package/components/dd-qrcode/dd-qrcode.vue +509 -0
- package/components/dd-qrcode/qrcode.js +1283 -0
- package/components/dd-radio/dd-radio.vue +19 -20
- package/components/dd-radio-group/dd-radio-group.vue +53 -0
- package/components/dd-rate/dd-rate.vue +1 -1
- package/components/dd-room-card/dd-room-card.vue +3 -3
- package/components/dd-search-bar/dd-search-bar.vue +8 -8
- package/components/dd-segmented-tab/dd-segmented-tab.vue +6 -6
- package/components/dd-signature/dd-signature.vue +513 -0
- package/components/dd-skeleton/dd-skeleton.vue +1 -1
- package/components/dd-slider/dd-slider.vue +4 -4
- package/components/dd-stat-card/dd-stat-card.vue +5 -5
- package/components/dd-step/dd-step.vue +11 -11
- package/components/dd-stepper/dd-stepper.vue +6 -6
- package/components/dd-swipe-action/dd-swipe-action.vue +1 -1
- package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -1
- package/components/dd-tabbar-item/dd-tabbar-item.vue +8 -8
- package/components/dd-tag/dd-tag.vue +17 -1
- package/components/dd-text/dd-text.vue +250 -0
- package/components/dd-text/props.js +120 -0
- package/components/dd-text/text.js +30 -0
- package/components/dd-text/value.js +87 -0
- package/components/dd-toast/dd-toast.vue +2 -2
- package/components/dd-upload/dd-upload.vue +4 -4
- package/components/dd-workorder-card/dd-workorder-card.vue +237 -0
- package/index.ts +50 -9
- package/libs/config/color.js +16 -0
- package/libs/config/config.js +25 -0
- package/libs/config/props.js +185 -0
- package/libs/config/zIndex.js +20 -0
- package/libs/function/digit.js +167 -0
- package/libs/function/index.js +932 -0
- package/libs/function/test.js +327 -0
- package/libs/i18n/index.d.ts +2 -0
- package/libs/i18n/index.js +89 -0
- package/libs/i18n/locales/zh-Hans.js +86 -0
- package/libs/mixin/button.js +18 -0
- package/libs/mixin/mixin.js +44 -0
- package/libs/mixin/mpMixin.js +13 -0
- package/libs/mixin/openType.js +27 -0
- package/libs/utils.ts +462 -0
- package/libs/vue.js +3 -0
- package/package.json +1 -1
- package/scss/_dd-shared.scss +40 -0
- package/scss/_variables.scss +4 -1
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="dd-signature">
|
|
3
|
+
<view class="dd-signature__canvas-wrap" :style="{background: resolvedBgColor}">
|
|
4
|
+
<dd-canvas
|
|
5
|
+
ref="signatureCanvas"
|
|
6
|
+
:canvas-id="canvasId"
|
|
7
|
+
:width="canvasWidth"
|
|
8
|
+
:height="canvasHeight"
|
|
9
|
+
:bg-color="resolvedBgColor"
|
|
10
|
+
@touchstart="touchStart"
|
|
11
|
+
@touchmove="touchMove"
|
|
12
|
+
@touchend="touchEnd"
|
|
13
|
+
:disable-scroll="true"
|
|
14
|
+
class="dd-signature__canvas"
|
|
15
|
+
:style="{
|
|
16
|
+
width: canvasWidth + 'px',
|
|
17
|
+
height: canvasHeight + 'px',
|
|
18
|
+
}">
|
|
19
|
+
</dd-canvas>
|
|
20
|
+
</view>
|
|
21
|
+
|
|
22
|
+
<view v-if="showToolbar" class="dd-signature__toolbar">
|
|
23
|
+
<view class="dd-signature__toolbar-icons">
|
|
24
|
+
<view class="dd-signature__toolbar-icon" @click="undo">
|
|
25
|
+
<dd-icon name="arrow-left" size="22" :color="pathStack.length === 0 ? iconDisabledColor : iconDefaultColor"></dd-icon>
|
|
26
|
+
</view>
|
|
27
|
+
<view class="dd-signature__toolbar-icon" @click="clear">
|
|
28
|
+
<dd-icon name="delete" size="25" :color="iconDefaultColor"></dd-icon>
|
|
29
|
+
</view>
|
|
30
|
+
<view class="dd-signature__toolbar-icon" @click="toggleBrushSettings">
|
|
31
|
+
<dd-icon name="brush-o" size="25" :color="iconDefaultColor"></dd-icon>
|
|
32
|
+
</view>
|
|
33
|
+
<view class="dd-signature__toolbar-icon" @click="toggleColorSettings">
|
|
34
|
+
<dd-icon name="flower-o" size="24" :color="iconDefaultColor"></dd-icon>
|
|
35
|
+
</view>
|
|
36
|
+
<view class="dd-signature__toolbar-icon" @click="exportSignature">
|
|
37
|
+
<dd-icon name="checked" size="25" :color="isEmpty ? iconDisabledColor : iconDefaultColor"></dd-icon>
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
|
|
41
|
+
<!-- 笔画设置 -->
|
|
42
|
+
<view v-if="showBrushSettings" class="dd-signature__brush-settings">
|
|
43
|
+
<view class="dd-signature__progress">
|
|
44
|
+
<text class="dd-signature__progress-label">{{ t("dd.signature.penSize") }}:</text>
|
|
45
|
+
<dd-slider
|
|
46
|
+
v-model="lineWidth"
|
|
47
|
+
:min="1"
|
|
48
|
+
:max="20"
|
|
49
|
+
:step="1"
|
|
50
|
+
></dd-slider>
|
|
51
|
+
</view>
|
|
52
|
+
</view>
|
|
53
|
+
|
|
54
|
+
<!-- 颜色设置 -->
|
|
55
|
+
<view v-if="showColorSettings" class="dd-signature__color-settings">
|
|
56
|
+
<view class="dd-signature__color-picker">
|
|
57
|
+
<text class="dd-signature__color-label">{{ t("dd.signature.penColor") }}:</text>
|
|
58
|
+
<view class="dd-signature__colors">
|
|
59
|
+
<view
|
|
60
|
+
v-for="(color, index) in presetColors"
|
|
61
|
+
:key="index"
|
|
62
|
+
class="dd-signature__color-item"
|
|
63
|
+
:class="{'dd-signature__color-item--active': lineColor === color}"
|
|
64
|
+
:style="{ backgroundColor: color }"
|
|
65
|
+
@click="selectColor(color)"
|
|
66
|
+
></view>
|
|
67
|
+
</view>
|
|
68
|
+
</view>
|
|
69
|
+
</view>
|
|
70
|
+
</view>
|
|
71
|
+
</view>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
import { t } from '../../libs/i18n'
|
|
76
|
+
export default {
|
|
77
|
+
name: 'dd-signature',
|
|
78
|
+
props: {
|
|
79
|
+
// 画布宽度
|
|
80
|
+
width: {
|
|
81
|
+
type: [String, Number],
|
|
82
|
+
default: 300
|
|
83
|
+
},
|
|
84
|
+
// 画布高度
|
|
85
|
+
height: {
|
|
86
|
+
type: [String, Number],
|
|
87
|
+
default: 200
|
|
88
|
+
},
|
|
89
|
+
// 背景颜色
|
|
90
|
+
bgColor: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: '#ffffff'
|
|
93
|
+
},
|
|
94
|
+
// 默认笔画颜色
|
|
95
|
+
color: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: '#000000'
|
|
98
|
+
},
|
|
99
|
+
// 默认笔画粗细
|
|
100
|
+
thickness: {
|
|
101
|
+
type: [String, Number],
|
|
102
|
+
default: 3
|
|
103
|
+
},
|
|
104
|
+
// 是否显示工具栏
|
|
105
|
+
showToolbar: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
default: true
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
data() {
|
|
111
|
+
return {
|
|
112
|
+
canvasId: 'dd-signature-' + Math.random().toString(36).substr(2, 9),
|
|
113
|
+
canvasWidth: 300,
|
|
114
|
+
canvasHeight: 200,
|
|
115
|
+
lineColor: '',
|
|
116
|
+
lineWidth: 3,
|
|
117
|
+
isDrawing: false,
|
|
118
|
+
pathStack: [], // 存储绘制路径用于回退
|
|
119
|
+
currentPath: [], // 当前绘制路径
|
|
120
|
+
isEmpty: true,
|
|
121
|
+
presetColors: [
|
|
122
|
+
'#000000', // 黑色
|
|
123
|
+
'#ff0000', // 红色
|
|
124
|
+
'#00ff00', // 绿色
|
|
125
|
+
'#0000ff', // 蓝色
|
|
126
|
+
'#ffff00', // 黄色
|
|
127
|
+
'#00ffff', // 青色
|
|
128
|
+
'#ff00ff', // 紫色
|
|
129
|
+
'#ffffff' // 白色
|
|
130
|
+
],
|
|
131
|
+
showBrushSettings: false,
|
|
132
|
+
showColorSettings: false,
|
|
133
|
+
lastPoint: null, // 保存上一个点的坐标
|
|
134
|
+
canvasInstance: null // 缓存canvas实例
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
computed: {
|
|
138
|
+
// ponytail: 剥离运行时主题;签名画布默认保持白底(导出图片需白底)
|
|
139
|
+
resolvedBgColor() {
|
|
140
|
+
return this.bgColor
|
|
141
|
+
},
|
|
142
|
+
iconDefaultColor() {
|
|
143
|
+
return '#999999'
|
|
144
|
+
},
|
|
145
|
+
iconDisabledColor() {
|
|
146
|
+
return '#5c5c5c'
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
mounted() {
|
|
150
|
+
// 初始化时获取canvas实例
|
|
151
|
+
this.$nextTick(() => {
|
|
152
|
+
this.getCanvasInstance();
|
|
153
|
+
this.clearCanvas();
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
watch: {
|
|
157
|
+
width: {
|
|
158
|
+
handler(newVal) {
|
|
159
|
+
this.canvasWidth = Number(newVal)
|
|
160
|
+
},
|
|
161
|
+
immediate: true
|
|
162
|
+
},
|
|
163
|
+
height: {
|
|
164
|
+
handler(newVal) {
|
|
165
|
+
this.canvasHeight = Number(newVal)
|
|
166
|
+
},
|
|
167
|
+
immediate: true
|
|
168
|
+
},
|
|
169
|
+
color: {
|
|
170
|
+
handler(newVal) {
|
|
171
|
+
this.lineColor = this.resolveStrokeColor(newVal)
|
|
172
|
+
},
|
|
173
|
+
immediate: true
|
|
174
|
+
},
|
|
175
|
+
thickness: {
|
|
176
|
+
handler(newVal) {
|
|
177
|
+
this.lineWidth = Number(newVal)
|
|
178
|
+
},
|
|
179
|
+
immediate: true
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
methods: {
|
|
183
|
+
t,
|
|
184
|
+
resolveStrokeColor(color) {
|
|
185
|
+
return color
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
// 获取签名画布实例
|
|
189
|
+
getCanvasInstance() {
|
|
190
|
+
if (this.canvasInstance) {
|
|
191
|
+
return this.canvasInstance;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const canvasRef = this.$refs.signatureCanvas;
|
|
195
|
+
if (canvasRef) {
|
|
196
|
+
this.canvasInstance = canvasRef;
|
|
197
|
+
return canvasRef;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
touchStart(e) {
|
|
203
|
+
if (!this.canvasInstance || !this.canvasInstance.ctx) {
|
|
204
|
+
this.getCanvasInstance();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (!this.canvasInstance || !this.canvasInstance.ctx) return;
|
|
208
|
+
|
|
209
|
+
this.isDrawing = true;
|
|
210
|
+
this.isEmpty = false;
|
|
211
|
+
this.currentPath = [];
|
|
212
|
+
|
|
213
|
+
const { x, y } = this.getCanvasPoint(e);
|
|
214
|
+
|
|
215
|
+
// 设置线条样式
|
|
216
|
+
this.canvasInstance.setLineStyle(this.lineColor, this.lineWidth);
|
|
217
|
+
|
|
218
|
+
// 开始路径
|
|
219
|
+
this.canvasInstance.beginPath();
|
|
220
|
+
this.canvasInstance.moveTo(x, y);
|
|
221
|
+
|
|
222
|
+
// 记录起始点
|
|
223
|
+
this.currentPath.push({
|
|
224
|
+
x,
|
|
225
|
+
y,
|
|
226
|
+
type: 'start',
|
|
227
|
+
color: this.lineColor,
|
|
228
|
+
width: this.lineWidth
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// 保存上一个点
|
|
232
|
+
this.lastPoint = { x, y };
|
|
233
|
+
|
|
234
|
+
// 阻止默认事件以提高性能
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
},
|
|
237
|
+
|
|
238
|
+
touchMove(e) {
|
|
239
|
+
if (!this.isDrawing || !this.canvasInstance || !this.canvasInstance.ctx) return;
|
|
240
|
+
|
|
241
|
+
// 阻止默认事件以提高性能
|
|
242
|
+
e.preventDefault();
|
|
243
|
+
|
|
244
|
+
const { x, y } = this.getCanvasPoint(e);
|
|
245
|
+
|
|
246
|
+
// 从上一个点画线到当前点
|
|
247
|
+
this.canvasInstance.lineTo(x, y);
|
|
248
|
+
this.canvasInstance.stroke(); // 实时绘制当前线段
|
|
249
|
+
this.currentPath.push({
|
|
250
|
+
x,
|
|
251
|
+
y,
|
|
252
|
+
type: 'move'
|
|
253
|
+
});
|
|
254
|
+
this.canvasInstance.draw(false);
|
|
255
|
+
|
|
256
|
+
// 更新上一个点
|
|
257
|
+
this.lastPoint = { x, y };
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
touchEnd(e) {
|
|
261
|
+
if (!this.isDrawing || !this.canvasInstance || !this.canvasInstance.ctx) return;
|
|
262
|
+
|
|
263
|
+
this.isDrawing = false;
|
|
264
|
+
this.canvasInstance.closePath();
|
|
265
|
+
this.lastPoint = null;
|
|
266
|
+
|
|
267
|
+
// 将当前路径加入栈中用于回退
|
|
268
|
+
if (this.currentPath.length > 0) {
|
|
269
|
+
this.pathStack.push([...this.currentPath]);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// 最后统一执行一次绘制
|
|
273
|
+
this.canvasInstance.draw(true);
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
// 同步获取canvas坐标点(兼容处理)
|
|
277
|
+
getCanvasPoint(e) {
|
|
278
|
+
let touch;
|
|
279
|
+
// #ifdef MP-WEIXIN
|
|
280
|
+
touch = e.touches && e.touches[0] ? e.touches[0] : e.mp.touches[0];
|
|
281
|
+
// #endif
|
|
282
|
+
// #ifndef MP-WEIXIN
|
|
283
|
+
touch = e.touches[0];
|
|
284
|
+
// #endif
|
|
285
|
+
|
|
286
|
+
// 计算相对于canvas的坐标
|
|
287
|
+
// 由于无法直接获取canvas位置,这里简化处理
|
|
288
|
+
// 实际应用中可能需要通过uni.createSelectorQuery获取canvas位置
|
|
289
|
+
return {
|
|
290
|
+
x: touch.x,
|
|
291
|
+
y: touch.y
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
// 选择颜色
|
|
296
|
+
selectColor(color) {
|
|
297
|
+
this.lineColor = color
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
// 回退操作
|
|
301
|
+
undo() {
|
|
302
|
+
if (this.pathStack.length === 0) return
|
|
303
|
+
|
|
304
|
+
// 弹出最后一个路径
|
|
305
|
+
this.pathStack.pop()
|
|
306
|
+
|
|
307
|
+
// 重新绘制
|
|
308
|
+
this.redraw()
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
// 重新绘制所有路径
|
|
312
|
+
redraw() {
|
|
313
|
+
if (!this.canvasInstance) {
|
|
314
|
+
this.getCanvasInstance();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (!this.canvasInstance) return;
|
|
318
|
+
|
|
319
|
+
// 先清空画布
|
|
320
|
+
this.canvasInstance.clearCanvas();
|
|
321
|
+
|
|
322
|
+
if (this.pathStack.length === 0) {
|
|
323
|
+
this.isEmpty = true;
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
this.isEmpty = false;
|
|
328
|
+
|
|
329
|
+
// 逐个绘制路径
|
|
330
|
+
this.pathStack.forEach(path => {
|
|
331
|
+
if (path.length === 0) return;
|
|
332
|
+
|
|
333
|
+
this.canvasInstance.beginPath();
|
|
334
|
+
|
|
335
|
+
let lastPoint = null;
|
|
336
|
+
path.forEach((point, index) => {
|
|
337
|
+
if (index === 0 && point.type === 'start') {
|
|
338
|
+
// 设置线条样式
|
|
339
|
+
this.canvasInstance.setLineStyle(point.color, point.width);
|
|
340
|
+
this.canvasInstance.moveTo(point.x, point.y);
|
|
341
|
+
lastPoint = { x: point.x, y: point.y };
|
|
342
|
+
} else if (point.type === 'move') {
|
|
343
|
+
this.canvasInstance.lineTo(point.x, point.y);
|
|
344
|
+
lastPoint = { x: point.x, y: point.y };
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
this.canvasInstance.stroke();
|
|
348
|
+
this.canvasInstance.draw(true);
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
|
|
352
|
+
// 清空画布内容
|
|
353
|
+
clearCanvas() {
|
|
354
|
+
if (!this.canvasInstance) {
|
|
355
|
+
this.getCanvasInstance();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (!this.canvasInstance) return;
|
|
359
|
+
|
|
360
|
+
this.canvasInstance.clearCanvas();
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
// 对外暴露的清空方法(供工具栏与ref调用)
|
|
364
|
+
clear() {
|
|
365
|
+
this.pathStack = []
|
|
366
|
+
this.currentPath = []
|
|
367
|
+
this.lastPoint = null
|
|
368
|
+
this.isDrawing = false
|
|
369
|
+
this.isEmpty = true
|
|
370
|
+
this.clearCanvas()
|
|
371
|
+
this.$emit('clear')
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
// 导出签名图片
|
|
375
|
+
async exportSignature() {
|
|
376
|
+
if (this.isEmpty) {
|
|
377
|
+
console.warn('签名为空,无法导出');
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (!this.canvasInstance) {
|
|
382
|
+
this.getCanvasInstance();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (!this.canvasInstance) {
|
|
386
|
+
console.error('无法获取画布实例');
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
try {
|
|
391
|
+
// 先重绘整个签名内容
|
|
392
|
+
this.redraw();
|
|
393
|
+
|
|
394
|
+
// 导出图片
|
|
395
|
+
const imagePath = await this.canvasInstance.exportImage('png', 1);
|
|
396
|
+
this.$emit('confirm', imagePath);
|
|
397
|
+
} catch (error) {
|
|
398
|
+
console.error('导出签名图片失败:', error);
|
|
399
|
+
this.$emit('error', error);
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
// 切换笔画设置显示
|
|
404
|
+
toggleBrushSettings() {
|
|
405
|
+
this.showBrushSettings = !this.showBrushSettings;
|
|
406
|
+
if (this.showBrushSettings) {
|
|
407
|
+
this.showColorSettings = false;
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
|
|
411
|
+
// 切换颜色设置显示
|
|
412
|
+
toggleColorSettings() {
|
|
413
|
+
this.showColorSettings = !this.showColorSettings;
|
|
414
|
+
if (this.showColorSettings) {
|
|
415
|
+
this.showBrushSettings = false;
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
</script>
|
|
421
|
+
|
|
422
|
+
<style lang="scss" scoped>
|
|
423
|
+
@import '../../scss/variables';
|
|
424
|
+
@import '../../scss/mixins';
|
|
425
|
+
.dd-signature {
|
|
426
|
+
display: flex;
|
|
427
|
+
flex-direction: column;
|
|
428
|
+
|
|
429
|
+
&__canvas-wrap {
|
|
430
|
+
border: 1px solid $dd-border-default;
|
|
431
|
+
border-radius: 4px;
|
|
432
|
+
overflow: hidden;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
&__canvas {
|
|
436
|
+
width: 100%;
|
|
437
|
+
height: 100%;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
&__toolbar {
|
|
441
|
+
margin-top: 5px;
|
|
442
|
+
background-color: $dd-bg-elevated;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
&__toolbar-icons {
|
|
446
|
+
display: flex;
|
|
447
|
+
justify-content: space-between;
|
|
448
|
+
align-items: center;
|
|
449
|
+
padding: 1px 0;
|
|
450
|
+
// border: 1px solid #e0e0e0;
|
|
451
|
+
border-radius: 4px;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
&__toolbar-icon {
|
|
455
|
+
padding: 5px;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
&__brush-settings,
|
|
459
|
+
&__color-settings {
|
|
460
|
+
margin-top: 15px;
|
|
461
|
+
padding: 1px;
|
|
462
|
+
// border: 1px solid #e0e0e0;
|
|
463
|
+
border-radius: 4px;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
&__progress {
|
|
467
|
+
&-label {
|
|
468
|
+
display: block;
|
|
469
|
+
margin-bottom: 10px;
|
|
470
|
+
font-size: 14px;
|
|
471
|
+
color: $dd-text-tertiary;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
&__color-picker {
|
|
476
|
+
margin-bottom: 10px;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
&__color-label {
|
|
480
|
+
display: block;
|
|
481
|
+
margin-bottom: 10px;
|
|
482
|
+
font-size: 14px;
|
|
483
|
+
color: $dd-text-tertiary;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
&__colors {
|
|
487
|
+
display: flex;
|
|
488
|
+
flex-direction: row;
|
|
489
|
+
flex-wrap: wrap;
|
|
490
|
+
gap: 10px;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
&__color-item {
|
|
494
|
+
width: 30px;
|
|
495
|
+
height: 30px;
|
|
496
|
+
border-radius: 50%;
|
|
497
|
+
border: 2px solid $dd-border-default;
|
|
498
|
+
cursor: pointer;
|
|
499
|
+
|
|
500
|
+
&--active {
|
|
501
|
+
border-color: $dd-primary-400;
|
|
502
|
+
transform: scale(1.1);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
&__actions {
|
|
507
|
+
display: flex;
|
|
508
|
+
flex-direction: row;
|
|
509
|
+
gap: 10px;
|
|
510
|
+
justify-content: center;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
</style>
|
|
@@ -178,7 +178,7 @@ function onMouseDown(e: any) {
|
|
|
178
178
|
top: 50%;
|
|
179
179
|
width: 32rpx;
|
|
180
180
|
height: 32rpx;
|
|
181
|
-
background:
|
|
181
|
+
background: $dd-color-white;
|
|
182
182
|
border: 4rpx solid $dd-primary-400;
|
|
183
183
|
border-radius: 50%;
|
|
184
184
|
box-shadow: $dd-shadow-glow-gold-lg;
|
|
@@ -192,10 +192,10 @@ function onMouseDown(e: any) {
|
|
|
192
192
|
|
|
193
193
|
&__tooltip {
|
|
194
194
|
position: absolute;
|
|
195
|
-
bottom: calc(100% +
|
|
195
|
+
bottom: calc(100% + $dd-space-2);
|
|
196
196
|
left: 50%;
|
|
197
197
|
transform: translateX(-50%);
|
|
198
|
-
padding: 6rpx
|
|
198
|
+
padding: 6rpx $dd-space-2;
|
|
199
199
|
@include dd-glass;
|
|
200
200
|
border-radius: $dd-radius-sm;
|
|
201
201
|
white-space: nowrap;
|
|
@@ -213,7 +213,7 @@ function onMouseDown(e: any) {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
&__tooltip-text {
|
|
216
|
-
font-size:
|
|
216
|
+
font-size: $dd-font-size-caption;
|
|
217
217
|
font-weight: 600;
|
|
218
218
|
color: $dd-primary-300;
|
|
219
219
|
line-height: 1.2;
|
|
@@ -88,27 +88,27 @@ function onClick(e: Event) {
|
|
|
88
88
|
&__value-row {
|
|
89
89
|
display: flex;
|
|
90
90
|
align-items: baseline;
|
|
91
|
-
gap:
|
|
91
|
+
gap: $dd-space-1;
|
|
92
92
|
margin-top: $dd-space-1;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
&__prefix {
|
|
96
96
|
font-size: $dd-font-size-h3;
|
|
97
97
|
font-weight: 700;
|
|
98
|
-
color:
|
|
98
|
+
color: $dd-color-white;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
&__value {
|
|
102
102
|
font-size: $dd-font-size-h1;
|
|
103
103
|
font-weight: 800;
|
|
104
|
-
color:
|
|
104
|
+
color: $dd-color-white;
|
|
105
105
|
line-height: 1.2;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
&__trend {
|
|
109
109
|
display: inline-flex;
|
|
110
110
|
align-items: baseline;
|
|
111
|
-
gap:
|
|
111
|
+
gap: $dd-space-1;
|
|
112
112
|
font-size: $dd-font-size-caption;
|
|
113
113
|
font-weight: 600;
|
|
114
114
|
margin-left: $dd-space-1;
|
|
@@ -119,7 +119,7 @@ function onClick(e: Event) {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
&--up {
|
|
122
|
-
color:
|
|
122
|
+
color: $dd-color-white;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
&--down {
|
|
@@ -105,13 +105,13 @@ const lineStyle = computed(() => ({
|
|
|
105
105
|
&__head {
|
|
106
106
|
position: relative;
|
|
107
107
|
width: 100%;
|
|
108
|
-
height:
|
|
108
|
+
height: $dd-size-icon-md;
|
|
109
109
|
display: flex;
|
|
110
110
|
align-items: center;
|
|
111
111
|
justify-content: center;
|
|
112
112
|
|
|
113
113
|
&--vertical {
|
|
114
|
-
width:
|
|
114
|
+
width: $dd-size-icon-md;
|
|
115
115
|
height: auto;
|
|
116
116
|
flex-direction: column;
|
|
117
117
|
align-self: stretch;
|
|
@@ -137,15 +137,15 @@ const lineStyle = computed(() => ({
|
|
|
137
137
|
width: 1px;
|
|
138
138
|
flex: 1;
|
|
139
139
|
min-height: 32rpx;
|
|
140
|
-
margin:
|
|
140
|
+
margin: $dd-space-1 0;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
&__circle {
|
|
145
145
|
position: relative;
|
|
146
146
|
z-index: 1;
|
|
147
|
-
width:
|
|
148
|
-
height:
|
|
147
|
+
width: $dd-size-icon-md;
|
|
148
|
+
height: $dd-size-icon-md;
|
|
149
149
|
border-radius: $dd-radius-full;
|
|
150
150
|
@include dd-flex-center;
|
|
151
151
|
flex-shrink: 0;
|
|
@@ -153,20 +153,20 @@ const lineStyle = computed(() => ({
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
&__circle-text {
|
|
156
|
-
font-size:
|
|
156
|
+
font-size: $dd-font-size-caption;
|
|
157
157
|
font-weight: 700;
|
|
158
158
|
line-height: 1;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
&__content {
|
|
162
162
|
text-align: center;
|
|
163
|
-
margin-top:
|
|
163
|
+
margin-top: $dd-space-1;
|
|
164
164
|
|
|
165
165
|
&--vertical {
|
|
166
166
|
text-align: left;
|
|
167
167
|
flex: 1;
|
|
168
|
-
padding-bottom:
|
|
169
|
-
padding-left:
|
|
168
|
+
padding-bottom: $dd-space-4;
|
|
169
|
+
padding-left: $dd-space-1;
|
|
170
170
|
margin-top: 0;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -179,8 +179,8 @@ const lineStyle = computed(() => ({
|
|
|
179
179
|
|
|
180
180
|
&__desc {
|
|
181
181
|
display: block;
|
|
182
|
-
margin-top:
|
|
183
|
-
font-size:
|
|
182
|
+
margin-top: $dd-space-1;
|
|
183
|
+
font-size: $dd-font-size-caption;
|
|
184
184
|
color: $dd-text-tertiary;
|
|
185
185
|
line-height: 1.4;
|
|
186
186
|
}
|
|
@@ -91,8 +91,8 @@ function onPlus() {
|
|
|
91
91
|
display: inline-flex;
|
|
92
92
|
align-items: center;
|
|
93
93
|
justify-content: center;
|
|
94
|
-
gap:
|
|
95
|
-
padding:
|
|
94
|
+
gap: $dd-space-1;
|
|
95
|
+
padding: $dd-space-1;
|
|
96
96
|
background: $dd-neutral-800;
|
|
97
97
|
border: 1px solid $dd-neutral-700;
|
|
98
98
|
border-radius: $dd-radius-full;
|
|
@@ -146,11 +146,11 @@ function onPlus() {
|
|
|
146
146
|
height: 56rpx;
|
|
147
147
|
}
|
|
148
148
|
.dd-stepper__icon {
|
|
149
|
-
font-size:
|
|
149
|
+
font-size: $dd-font-size-h4;
|
|
150
150
|
}
|
|
151
151
|
.dd-stepper__value {
|
|
152
152
|
min-width: 80rpx;
|
|
153
|
-
font-size:
|
|
153
|
+
font-size: $dd-font-size-h4;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
@@ -164,8 +164,8 @@ function onPlus() {
|
|
|
164
164
|
font-size: 26rpx;
|
|
165
165
|
}
|
|
166
166
|
.dd-stepper__value {
|
|
167
|
-
min-width:
|
|
168
|
-
font-size:
|
|
167
|
+
min-width: $dd-space-6;
|
|
168
|
+
font-size: $dd-font-size-body;
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
</style>
|