@xtdev/xt-miniprogram-ui 1.2.87 → 1.2.89
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.
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
</view>
|
|
53
53
|
</view>
|
|
54
54
|
<!-- 相机页面 -->
|
|
55
|
-
<xt-water-camera wx:if="{{showCamera}}" watermarkType="banquet" watermarkData="{{watermarkData}}" bind:confirm="onPhotoConfirm" bind:error="onCameraError" />
|
|
55
|
+
<xt-water-camera wx:if="{{showCamera}}" watermarkType="banquet" watermarkData="{{watermarkData}}" bind:confirm="onPhotoConfirm" bind:error="onCameraError" bind:cancel="onCameraCancel"/>
|
|
56
56
|
|
|
57
57
|
|
|
@@ -25,11 +25,6 @@ Component({
|
|
|
25
25
|
type: Object,
|
|
26
26
|
value: {},
|
|
27
27
|
},
|
|
28
|
-
// 闪光灯模式:auto/on/off/torch
|
|
29
|
-
flash: {
|
|
30
|
-
type: String,
|
|
31
|
-
value: 'off',
|
|
32
|
-
},
|
|
33
28
|
},
|
|
34
29
|
|
|
35
30
|
data: {
|
|
@@ -41,6 +36,8 @@ Component({
|
|
|
41
36
|
isLoading: false,
|
|
42
37
|
systemInfo: null,
|
|
43
38
|
dpr: 2,
|
|
39
|
+
devicePosition: "back", // 摄像头位置 back: 后置 front: 前置
|
|
40
|
+
flashlight: 'off', // 闪光灯 auto/on/off/torch
|
|
44
41
|
},
|
|
45
42
|
|
|
46
43
|
lifetimes: {
|
|
@@ -66,6 +63,29 @@ Component({
|
|
|
66
63
|
}
|
|
67
64
|
});
|
|
68
65
|
},
|
|
66
|
+
/**
|
|
67
|
+
* 翻转摄像头
|
|
68
|
+
*/
|
|
69
|
+
switchCamera() {
|
|
70
|
+
const { devicePosition } = this.data;
|
|
71
|
+
this.setData({
|
|
72
|
+
devicePosition: devicePosition === 'back' ? 'front' : 'back'
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* 开关闪光灯
|
|
77
|
+
*/
|
|
78
|
+
switchFlashLight() {
|
|
79
|
+
let { flashlight } = this.data;
|
|
80
|
+
flashlight = flashlight === 'off' ? 'on' : 'off';
|
|
81
|
+
this.setData({
|
|
82
|
+
flashlight
|
|
83
|
+
});
|
|
84
|
+
wx.showToast({
|
|
85
|
+
title: flashlight === 'off' ? '闪光灯已关闭' : '闪光灯已开启',
|
|
86
|
+
icon: 'none'
|
|
87
|
+
});
|
|
88
|
+
},
|
|
69
89
|
/**
|
|
70
90
|
* 初始化组件
|
|
71
91
|
*/
|
|
@@ -118,7 +138,7 @@ Component({
|
|
|
118
138
|
* 拍照
|
|
119
139
|
*/
|
|
120
140
|
takePhoto() {
|
|
121
|
-
if (this.data.isLoading) return;
|
|
141
|
+
if (this.data.isLoading) {return;}
|
|
122
142
|
|
|
123
143
|
this.setData({ isLoading: true });
|
|
124
144
|
|
|
@@ -188,7 +208,8 @@ Component({
|
|
|
188
208
|
.exec(res => {
|
|
189
209
|
if (!res[0] || !res[0].node) {
|
|
190
210
|
// 使用离屏Canvas
|
|
191
|
-
this.createWithOffscreenCanvas(imagePath, imgInfo).then(resolve)
|
|
211
|
+
this.createWithOffscreenCanvas(imagePath, imgInfo).then(resolve)
|
|
212
|
+
.catch(reject);
|
|
192
213
|
return;
|
|
193
214
|
}
|
|
194
215
|
|
|
@@ -384,9 +405,9 @@ Component({
|
|
|
384
405
|
ctx.fill();
|
|
385
406
|
|
|
386
407
|
// 时间文字
|
|
387
|
-
ctx.fillStyle = '#
|
|
388
|
-
ctx.fillText(currentHours, tagX + tagWidth + tagPaddingH, tagY + tagHeight / 2 +
|
|
389
|
-
ctx.fillText(currentMinutes, tagX + tagWidth + tagPaddingH + 70 * scale, tagY + tagHeight / 2 +
|
|
408
|
+
ctx.fillStyle = '#6722AB';
|
|
409
|
+
ctx.fillText(currentHours, tagX + tagWidth + tagPaddingH, tagY + tagHeight / 2 + 3);
|
|
410
|
+
ctx.fillText(currentMinutes, tagX + tagWidth + tagPaddingH + 70 * scale, tagY + tagHeight / 2 + 3);
|
|
390
411
|
|
|
391
412
|
ctx.font = `bold ${nameFontSize}px "PingFang SC", sans-serif`;
|
|
392
413
|
ctx.fillText(":", tagX + tagWidth + tagPaddingH + 56 * scale, tagY + tagHeight / 2);
|
|
@@ -515,7 +536,7 @@ Component({
|
|
|
515
536
|
*/
|
|
516
537
|
confirmPhoto() {
|
|
517
538
|
const { previewImage } = this.data;
|
|
518
|
-
if (!previewImage) return;
|
|
539
|
+
if (!previewImage) {return;}
|
|
519
540
|
|
|
520
541
|
// 触发事件,将图片路径传递给父组件
|
|
521
542
|
this.triggerEvent('confirm', {
|
|
@@ -541,5 +562,9 @@ Component({
|
|
|
541
562
|
this.clockInterval = null;
|
|
542
563
|
}
|
|
543
564
|
},
|
|
565
|
+
|
|
566
|
+
cancel(){
|
|
567
|
+
this.triggerEvent('cancel');
|
|
568
|
+
},
|
|
544
569
|
},
|
|
545
570
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<view class="watermark-camera-container">
|
|
2
2
|
<!-- 相机区域 -->
|
|
3
3
|
<view class="camera-section" wx:if="{{!previewImage}}">
|
|
4
|
-
<camera device-position="
|
|
4
|
+
<camera device-position="{{devicePosition}}" flash="{{flashlight}}" class="camera" binderror="onCameraError" />
|
|
5
5
|
|
|
6
6
|
<!-- 实时水印预览层 -->
|
|
7
7
|
<view class="watermark-preview-layer">
|
|
8
8
|
<!-- 左上角标签 -->
|
|
9
9
|
<view class="tag-container">
|
|
10
10
|
<view class="tag-label">{{watermarkData.tagText || '拍照记录'}}</view>
|
|
11
|
-
<view class="tag-time">{{
|
|
11
|
+
<view class="tag-time">{{currentHours}}<text class="pingfang">:</text>{{currentMinutes}}</view>
|
|
12
12
|
</view>
|
|
13
13
|
|
|
14
14
|
<!-- 底部信息区 -->
|
|
@@ -55,10 +55,13 @@
|
|
|
55
55
|
|
|
56
56
|
<!-- 拍照按钮 -->
|
|
57
57
|
<view class="shutter-area">
|
|
58
|
+
<image class="shutter-icon" bind:tap="switchFlashLight" src="{{flashlight == 'on'? 'https://img.tanjiu.cn/home/hXyjajQeyx7nF4dSiFrFM2Ws7Hhbw3fj.png': 'https://img.tanjiu.cn/home/ijXc7GwrFSPi5ttEEJzA7n4Hd3zpGDNE.png'}}" mode="aspectFit" binderror="" bindload=""></image>
|
|
58
59
|
<view class="shutter-btn" bindtap="takePhoto">
|
|
59
60
|
<view class="shutter-inner"></view>
|
|
60
61
|
</view>
|
|
62
|
+
<image class="shutter-icon" bind:tap="switchCamera" src="https://img.tanjiu.cn/home/Jmiyy8h2SiZ8YaMWrNTzcHS3C5XGap3c.png" mode="aspectFit" binderror="" bindload=""></image>
|
|
61
63
|
</view>
|
|
64
|
+
<image class="close-btn" bind:tap="cancel" src="https://img.tanjiu.cn/home/YC2FD8x6SB2m6HEfaZCYaFnmn8wzQdEt.png"></image>
|
|
62
65
|
</view>
|
|
63
66
|
|
|
64
67
|
<!-- 预览区域 -->
|
|
@@ -52,17 +52,21 @@
|
|
|
52
52
|
.tag-container .tag-time {
|
|
53
53
|
padding: 12rpx;
|
|
54
54
|
background-color: #fff;
|
|
55
|
-
color: #
|
|
55
|
+
color: #6722AB;
|
|
56
56
|
font-size: 48rpx;
|
|
57
57
|
font-weight: bold;
|
|
58
58
|
font-family: FengTan-Regular;
|
|
59
59
|
border-radius: 0 8rpx 8rpx 0;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
.pingfang{
|
|
63
|
+
font-family: PingFang SC-Regular, PingFang SC !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
62
66
|
.info-container {
|
|
63
67
|
background: linear-gradient(90deg, #000000 0%, rgba(0, 0, 0, 0) 100%);
|
|
64
68
|
opacity: 0.5;
|
|
65
|
-
padding:
|
|
69
|
+
padding: 16rpx;
|
|
66
70
|
margin-left: 16rpx;
|
|
67
71
|
margin-bottom: 16rpx;
|
|
68
72
|
border-radius: 8rpx;
|
|
@@ -119,13 +123,21 @@
|
|
|
119
123
|
margin-right: 8rpx;
|
|
120
124
|
}
|
|
121
125
|
|
|
126
|
+
.close-btn {
|
|
127
|
+
position: absolute;
|
|
128
|
+
top: 40rpx;
|
|
129
|
+
left: 40rpx;
|
|
130
|
+
width: 48rpx;
|
|
131
|
+
height: 48rpx;
|
|
132
|
+
}
|
|
133
|
+
|
|
122
134
|
.shutter-area {
|
|
123
135
|
position: absolute;
|
|
124
136
|
bottom: 40rpx;
|
|
125
137
|
left: 0;
|
|
126
138
|
right: 0;
|
|
127
139
|
display: flex;
|
|
128
|
-
justify-content:
|
|
140
|
+
justify-content: space-evenly;
|
|
129
141
|
align-items: center;
|
|
130
142
|
pointer-events: auto;
|
|
131
143
|
}
|
|
@@ -242,3 +254,8 @@
|
|
|
242
254
|
font-size: 28rpx;
|
|
243
255
|
margin-top: 20rpx;
|
|
244
256
|
}
|
|
257
|
+
|
|
258
|
+
.shutter-icon{
|
|
259
|
+
width: 48rpx;
|
|
260
|
+
height: 48rpx;
|
|
261
|
+
}
|