@xtdev/xt-miniprogram-ui 1.2.85 → 1.2.87
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.
|
@@ -230,6 +230,10 @@ Component({
|
|
|
230
230
|
console.log('onStartTakePhoto', e);
|
|
231
231
|
const _this = this;
|
|
232
232
|
const { customUpload, uploadApi, max, sourceType, fileList, fileType, tempFileList, version } = this.properties;
|
|
233
|
+
if (customUpload) {
|
|
234
|
+
_this.triggerEvent('upload', {});
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
233
237
|
if (version === 'v2') {
|
|
234
238
|
_this.properties.getWatermarkData().then(watermarkData => {
|
|
235
239
|
_this.setData({
|
|
@@ -239,10 +243,6 @@ Component({
|
|
|
239
243
|
})
|
|
240
244
|
return false;
|
|
241
245
|
}
|
|
242
|
-
if (customUpload) {
|
|
243
|
-
_this.triggerEvent('upload', {});
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
246
|
if (!uploadApi || !uploadApi.url) {
|
|
247
247
|
wx.showToast({
|
|
248
248
|
title: '请传入上传接口',
|
|
@@ -33,7 +33,9 @@ Component({
|
|
|
33
33
|
},
|
|
34
34
|
|
|
35
35
|
data: {
|
|
36
|
-
currentTime:
|
|
36
|
+
currentTime: "", // 当前时间
|
|
37
|
+
currentHours: '', // 当前时间 HH
|
|
38
|
+
currentMinutes: '', // 当前时间 mm
|
|
37
39
|
currentDateTime: '', // 完整日期时间
|
|
38
40
|
previewImage: '', // 预览图片路径
|
|
39
41
|
isLoading: false,
|
|
@@ -43,6 +45,7 @@ Component({
|
|
|
43
45
|
|
|
44
46
|
lifetimes: {
|
|
45
47
|
attached() {
|
|
48
|
+
this.initFont();
|
|
46
49
|
this.initComponent();
|
|
47
50
|
},
|
|
48
51
|
detached() {
|
|
@@ -51,6 +54,18 @@ Component({
|
|
|
51
54
|
},
|
|
52
55
|
|
|
53
56
|
methods: {
|
|
57
|
+
initFont() {
|
|
58
|
+
wx.loadFontFace({
|
|
59
|
+
family: 'FengTan-Regular', // 注意:这里的名称要和下面使用时完全一致
|
|
60
|
+
source: 'url("https://img.tanjiu.cn/home/C706753403526887.ttf")',
|
|
61
|
+
success: () => {
|
|
62
|
+
console.log('字体加载成功');
|
|
63
|
+
},
|
|
64
|
+
fail: (err) => {
|
|
65
|
+
console.error('字体加载失败', err);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
},
|
|
54
69
|
/**
|
|
55
70
|
* 初始化组件
|
|
56
71
|
*/
|
|
@@ -89,6 +104,8 @@ Component({
|
|
|
89
104
|
|
|
90
105
|
this.setData({
|
|
91
106
|
currentTime: `${hours}:${minutes}`,
|
|
107
|
+
currentHours: hours,
|
|
108
|
+
currentMinutes: minutes,
|
|
92
109
|
currentDateTime: `${year}年${month}月${day}日${hours}:${minutes}`,
|
|
93
110
|
});
|
|
94
111
|
};
|
|
@@ -284,19 +301,19 @@ Component({
|
|
|
284
301
|
const shortSide = Math.min(width, height);
|
|
285
302
|
const scale = shortSide / 750; // 以750rpx为基准计算缩放比
|
|
286
303
|
|
|
287
|
-
const { watermarkData,
|
|
304
|
+
const { watermarkData, currentHours, currentMinutes, currentDateTime } = this.data;
|
|
288
305
|
const tagText = watermarkData.tagText || '拍照记录';
|
|
289
306
|
const tagColor = '#7b2d8e'; // 固定紫色
|
|
290
307
|
|
|
291
308
|
// ============ 尺寸参数(与CSS保持一致)============
|
|
292
309
|
const radius = 8 * scale;
|
|
293
310
|
const tagPaddingV = 12 * scale; // 标签垂直padding
|
|
294
|
-
const tagPaddingH =
|
|
311
|
+
const tagPaddingH = 12 * scale; // 标签水平padding
|
|
295
312
|
const tagFontSize = 40 * scale; // 标签字体大小
|
|
296
|
-
const timeFontSize =
|
|
313
|
+
const timeFontSize = 48 * scale; // 时间字体大小
|
|
297
314
|
|
|
298
|
-
const infoPaddingV =
|
|
299
|
-
const infoPaddingH =
|
|
315
|
+
const infoPaddingV = 16 * scale; // 信息区垂直padding
|
|
316
|
+
const infoPaddingH = 16 * scale; // 信息区水平padding
|
|
300
317
|
const infoX = 16 * scale; // 距离左边16rpx
|
|
301
318
|
|
|
302
319
|
// 文字尺寸
|
|
@@ -306,7 +323,7 @@ Component({
|
|
|
306
323
|
|
|
307
324
|
// 警告标签尺寸
|
|
308
325
|
const warningFontSize = 20 * scale;
|
|
309
|
-
const warningPaddingH =
|
|
326
|
+
const warningPaddingH = 8 * scale;
|
|
310
327
|
const warningPaddingV = 4 * scale;
|
|
311
328
|
const warningRadius = 4 * scale;
|
|
312
329
|
const warningMarginRight = 8 * scale;
|
|
@@ -345,7 +362,7 @@ Component({
|
|
|
345
362
|
const tagHeight = tagFontSize + tagPaddingV * 2;
|
|
346
363
|
|
|
347
364
|
const tagX = infoX; // 与info-container左对齐
|
|
348
|
-
const tagY = infoY - tagHeight -
|
|
365
|
+
const tagY = infoY - tagHeight - 12 * scale; // 在info-container上方16rpx
|
|
349
366
|
|
|
350
367
|
// 标签背景(左上和左下圆角)
|
|
351
368
|
ctx.fillStyle = tagColor;
|
|
@@ -358,8 +375,8 @@ Component({
|
|
|
358
375
|
ctx.fillText(tagText, tagX + tagPaddingH, tagY + tagHeight / 2);
|
|
359
376
|
|
|
360
377
|
// 时间背景(右上和右下圆角)
|
|
361
|
-
ctx.font = `bold ${timeFontSize}px "
|
|
362
|
-
const timeTextWidth = ctx.measureText(
|
|
378
|
+
ctx.font = `bold ${timeFontSize}px "FengTan-Regular"`;
|
|
379
|
+
const timeTextWidth = ctx.measureText("00:00").width;
|
|
363
380
|
const timeWidth = timeTextWidth + tagPaddingH * 2;
|
|
364
381
|
|
|
365
382
|
ctx.fillStyle = '#ffffff';
|
|
@@ -367,8 +384,13 @@ Component({
|
|
|
367
384
|
ctx.fill();
|
|
368
385
|
|
|
369
386
|
// 时间文字
|
|
370
|
-
ctx.fillStyle = '#
|
|
371
|
-
ctx.fillText(
|
|
387
|
+
ctx.fillStyle = '#000000';
|
|
388
|
+
ctx.fillText(currentHours, tagX + tagWidth + tagPaddingH, tagY + tagHeight / 2 + 2);
|
|
389
|
+
ctx.fillText(currentMinutes, tagX + tagWidth + tagPaddingH + 70 * scale, tagY + tagHeight / 2 + 2);
|
|
390
|
+
|
|
391
|
+
ctx.font = `bold ${nameFontSize}px "PingFang SC", sans-serif`;
|
|
392
|
+
ctx.fillText(":", tagX + tagWidth + tagPaddingH + 56 * scale, tagY + tagHeight / 2);
|
|
393
|
+
|
|
372
394
|
|
|
373
395
|
// ============ 绘制信息区背景 ============
|
|
374
396
|
// 渐变背景(从左到右,90deg)
|
|
@@ -393,7 +415,7 @@ Component({
|
|
|
393
415
|
|
|
394
416
|
// 业务信息行
|
|
395
417
|
if (watermarkData.businessInfo) {
|
|
396
|
-
ctx.font =
|
|
418
|
+
ctx.font = `bold ${businessFontSize}px "PingFang SC", sans-serif`;
|
|
397
419
|
ctx.fillStyle = '#ffffff';
|
|
398
420
|
ctx.fillText(watermarkData.businessInfo, textX, currentY);
|
|
399
421
|
|
|
@@ -408,7 +430,7 @@ Component({
|
|
|
408
430
|
|
|
409
431
|
// 店铺名称
|
|
410
432
|
if (watermarkData.shopName) {
|
|
411
|
-
ctx.font =
|
|
433
|
+
ctx.font = `bold ${businessFontSize}px "PingFang SC", sans-serif`;
|
|
412
434
|
ctx.fillStyle = '#ffffff';
|
|
413
435
|
ctx.fillText(watermarkData.shopName, textX, currentY);
|
|
414
436
|
currentY += businessFontSize + infoRowMargin;
|
|
@@ -418,13 +440,13 @@ Component({
|
|
|
418
440
|
let dateTimeX = textX;
|
|
419
441
|
if (watermarkData.timeWarning) {
|
|
420
442
|
// 绘制时间异常标签
|
|
421
|
-
ctx.font =
|
|
443
|
+
ctx.font = `bold ${warningFontSize}px "PingFang SC", sans-serif`;
|
|
422
444
|
const warningText = '时间异常';
|
|
423
445
|
const warningTextWidth = ctx.measureText(warningText).width;
|
|
424
446
|
const warningTagWidth = warningTextWidth + warningPaddingH * 2;
|
|
425
447
|
const warningTagHeight = warningFontSize + warningPaddingV * 2;
|
|
426
448
|
|
|
427
|
-
ctx.fillStyle = '#
|
|
449
|
+
ctx.fillStyle = '#DB1C1C';
|
|
428
450
|
this.drawRoundRect(ctx, textX, currentY, warningTagWidth, warningTagHeight, warningRadius);
|
|
429
451
|
ctx.fill();
|
|
430
452
|
|
|
@@ -435,7 +457,7 @@ Component({
|
|
|
435
457
|
|
|
436
458
|
dateTimeX = textX + warningTagWidth + warningMarginRight;
|
|
437
459
|
}
|
|
438
|
-
ctx.font =
|
|
460
|
+
ctx.font = `bold ${infoFontSize}px "PingFang SC", sans-serif`;
|
|
439
461
|
ctx.fillStyle = '#ffffff';
|
|
440
462
|
ctx.fillText(currentDateTime, dateTimeX, currentY);
|
|
441
463
|
currentY += infoFontSize + infoRowMargin;
|
|
@@ -444,13 +466,13 @@ Component({
|
|
|
444
466
|
let addressX = textX;
|
|
445
467
|
if (watermarkData.locationWarning) {
|
|
446
468
|
// 绘制位置异常标签
|
|
447
|
-
ctx.font =
|
|
469
|
+
ctx.font = `bold ${warningFontSize}px "PingFang SC", sans-serif`;
|
|
448
470
|
const warningText = '位置异常';
|
|
449
471
|
const warningTextWidth = ctx.measureText(warningText).width;
|
|
450
472
|
const warningTagWidth = warningTextWidth + warningPaddingH * 2;
|
|
451
473
|
const warningTagHeight = warningFontSize + warningPaddingV * 2;
|
|
452
474
|
|
|
453
|
-
ctx.fillStyle = '#
|
|
475
|
+
ctx.fillStyle = '#DB1C1C';
|
|
454
476
|
this.drawRoundRect(ctx, textX, currentY, warningTagWidth, warningTagHeight, warningRadius);
|
|
455
477
|
ctx.fill();
|
|
456
478
|
|
|
@@ -462,7 +484,7 @@ Component({
|
|
|
462
484
|
addressX = textX + warningTagWidth + warningMarginRight;
|
|
463
485
|
}
|
|
464
486
|
const address = watermarkData.address;
|
|
465
|
-
ctx.font =
|
|
487
|
+
ctx.font = `bold ${infoFontSize}px "PingFang SC", sans-serif`;
|
|
466
488
|
ctx.fillStyle = '#ffffff';
|
|
467
489
|
ctx.fillText(address, addressX, currentY);
|
|
468
490
|
currentY += infoFontSize + infoRowMargin;
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
.tag-container .tag-label {
|
|
44
|
-
padding: 12rpx
|
|
44
|
+
padding: 16rpx 12rpx;
|
|
45
45
|
background-color: #7b2d8e;
|
|
46
46
|
color: #fff;
|
|
47
47
|
font-size: 40rpx;
|
|
@@ -50,11 +50,12 @@
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
.tag-container .tag-time {
|
|
53
|
-
padding: 12rpx
|
|
53
|
+
padding: 12rpx;
|
|
54
54
|
background-color: #fff;
|
|
55
55
|
color: #333;
|
|
56
|
-
font-size:
|
|
56
|
+
font-size: 48rpx;
|
|
57
57
|
font-weight: bold;
|
|
58
|
+
font-family: FengTan-Regular;
|
|
58
59
|
border-radius: 0 8rpx 8rpx 0;
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -109,8 +110,9 @@
|
|
|
109
110
|
|
|
110
111
|
.warning-tag {
|
|
111
112
|
display: inline-block;
|
|
112
|
-
background-color: #
|
|
113
|
+
background-color: #DB1C1C;
|
|
113
114
|
color: #fff;
|
|
115
|
+
font-weight: 800;
|
|
114
116
|
font-size: 20rpx;
|
|
115
117
|
padding: 4rpx 12rpx;
|
|
116
118
|
border-radius: 4rpx;
|
|
@@ -199,8 +201,8 @@
|
|
|
199
201
|
position: fixed;
|
|
200
202
|
left: -9999rpx;
|
|
201
203
|
top: -9999rpx;
|
|
202
|
-
width:
|
|
203
|
-
height:
|
|
204
|
+
width: 1px;
|
|
205
|
+
height: 1px;
|
|
204
206
|
}
|
|
205
207
|
|
|
206
208
|
.loading-overlay {
|