stellar-ui-plus 1.23.7 → 1.23.9

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.
@@ -165,4 +165,9 @@ export default {
165
165
  type: Boolean,
166
166
  default: () => false,
167
167
  },
168
+ /** 划线价格是否添加符号 */
169
+ showOriginalUnit: {
170
+ type: Boolean,
171
+ default: () => false
172
+ }
168
173
  };
@@ -185,6 +185,12 @@
185
185
  "description": "建议右侧申请输入框只读(mode='more'时有效)",
186
186
  "type": "boolean"
187
187
  },
188
+ {
189
+ "name": "showOriginalUnit",
190
+ "description": "划线价格是否显示¥符号",
191
+ "type": "boolean",
192
+ "version": "1.23.8"
193
+ },
188
194
 
189
195
  {
190
196
  "name": "[event]change",
@@ -151,7 +151,7 @@ const clickSuggest = (type: 'method' | 'back' | 'item' | 'right', item?: { label
151
151
  showSuggestList.value = !showSuggestList.value;
152
152
  }
153
153
  if (type === 'back' && applyForNumberHistory.value.length > 0) {
154
- backText.value = applyForNumberHistory.value.pop();
154
+ backText.value = applyForNumberHistory.value.length > 1 ? applyForNumberHistory.value.pop() : applyForNumberHistory.value[0];
155
155
  suggesData.value.applyForNumber = backText.value;
156
156
  }
157
157
  emits('click-suggest', type, item);
@@ -219,7 +219,7 @@ const cmpMore = computed(() => props.mode === 'more');
219
219
  line-price-color="#666666"
220
220
  :marginLeft="cmpMore ? 16 : 10"
221
221
  :fontSize="cmpMore ? 20 : 24"
222
- :showUnit="false"
222
+ :showUnit="showOriginalUnit"
223
223
  />
224
224
  </view>
225
225
  </block>
@@ -54,7 +54,7 @@ const initOptions = (values = selectedValue.value) => {
54
54
 
55
55
  const viewloading = ref(false);
56
56
 
57
- const initSelectIndex = (values = selectedValue.value) => {
57
+ const initSelectIndex = (values = selectedValue.value, callback?: () => void) => {
58
58
  viewloading.value = true;
59
59
  nextTick(() => {
60
60
  const indexs: number[] = [];
@@ -71,6 +71,7 @@ const initSelectIndex = (values = selectedValue.value) => {
71
71
  emits('change', selectedValue.value);
72
72
  emits('update:modelValue', selectedValue.value);
73
73
  viewloading.value = false;
74
+ if (callback) callback();
74
75
  });
75
76
  };
76
77
 
@@ -80,7 +81,10 @@ const onChange = (e: any) => {
80
81
  changeTimeout = setTimeout(() => {
81
82
  const indexs: number[] = e.detail.value;
82
83
  const newValues = indexs.map((i, index) => dataOptions.value[index][i].value);
83
- initSelectIndex(newValues);
84
+ initSelectIndex(newValues, () => {
85
+ initOptions();
86
+ initSelectIndex();
87
+ });
84
88
  }, 100);
85
89
  };
86
90
 
@@ -1,37 +1,39 @@
1
- .ste-step-row {
2
- display: block;
1
+ .ste-step {
2
+ flex: 1;
3
+ font-size: 0;
4
+ text-align: center;
5
+ &.ste-step-row {
6
+ display: block;
3
7
 
4
- &.reverse {
5
- .ste-step-line {
6
- left: -50% !important;
7
- right: 50% !important;
8
+ &.reverse {
9
+ .ste-step-head .ste-step-line {
10
+ left: -50% !important;
11
+ right: 50% !important;
12
+ }
8
13
  }
9
14
  }
10
- }
11
15
 
12
- .ste-step-column {
13
- display: flex;
16
+ &.ste-step-column {
17
+ display: flex;
14
18
 
15
- &.reverse {
16
- .ste-step-line {
17
- top: -100% !important;
19
+ &.reverse {
20
+ .ste-step-head .ste-step-line {
21
+ top: -100% !important;
22
+ }
18
23
  }
19
- }
20
24
 
21
- .ste-step-line {
22
- height: calc(4rpx + 100%) !important;
23
- width: 2rpx !important;
24
- }
25
+ .ste-step-head .ste-step-line {
26
+ height: calc(4rpx + 100%) !important;
27
+ width: 2rpx !important;
28
+ border-top: none;
29
+ border-left-width: 2rpx;
30
+ }
25
31
 
26
- .ste-step-content {
27
- padding-left: 6% !important;
28
- text-align: left !important;
32
+ .ste-step-content {
33
+ padding-left: 6% !important;
34
+ text-align: left !important;
35
+ }
29
36
  }
30
- }
31
- .ste-step {
32
- flex: 1;
33
- font-size: 0;
34
- text-align: center;
35
37
 
36
38
  .head-is-dot {
37
39
  top: 12rpx;
@@ -62,16 +64,16 @@
62
64
  position: relative;
63
65
 
64
66
  .ste-step-line {
65
- // background: var(---line-color);
66
67
  display: inline-block;
67
68
  position: absolute;
68
69
  height: 2rpx;
69
70
  left: 50%;
70
71
  right: -50%;
71
72
  top: 20rpx;
73
+ border-width: 0;
72
74
  border-top-width: 2rpx;
73
- border-top-color: var(---line-color);
74
- border-top-style: solid;
75
+ border-color: var(---line-color);
76
+ border-style: solid;
75
77
  box-sizing: border-box;
76
78
  }
77
79
  .ste-step-icon.is-icon {
@@ -1,13 +1,19 @@
1
1
  <template>
2
- <view :style="styles" :class="fullPage ? 'ste-watermark-root full-page' : 'ste-watermark-root'" />
2
+ <view :style="styles" :class="fullPage ? 'ste-watermark-root full-page' : 'ste-watermark-root'">
3
+ <!-- #ifdef APP -->
4
+ <canvas :id="canvasId" :canvas-id="canvasId" style="width: 100%; height: 100%; opacity: 0"></canvas>
5
+ <!-- #endif -->
6
+ </view>
3
7
  </template>
4
8
 
5
9
  <script setup lang="ts">
6
- import { computed, reactive, watch } from 'vue';
10
+ import { computed, nextTick, reactive, watch } from 'vue';
7
11
  import { watermarkProps, defaultWatermarkFont } from './props';
8
12
 
9
13
  import utils from '../../utils/utils';
10
14
 
15
+ const canvasId = `ste-watermark-canvas-${Math.floor(Math.random() * 10000).toString(36)}`;
16
+
11
17
  const componentName = `ste-watermark`;
12
18
  defineOptions({
13
19
  name: componentName,
@@ -27,14 +33,84 @@ const { fontStyle, fontWeight, color, fontSize, fontFamily, textAlign } = {
27
33
  ...defaultWatermarkFont,
28
34
  ...props.font,
29
35
  };
36
+ let timeout: any;
37
+ function debounce<T extends Function>(fn: T, time: number = 100): void {
38
+ clearTimeout(timeout);
39
+ if (!fn) return;
40
+ timeout = setTimeout(() => {
41
+ fn();
42
+ }, time);
43
+ }
44
+
45
+ const dealWithImage = (ctx: any, img: HTMLImageElement, ratio: number, canvas: HTMLCanvasElement, markWidth: number, markHeight: number) => {
46
+ ctx.translate(markWidth / 2, markHeight / 2);
47
+ ctx.rotate((Math.PI / 180) * Number(rotate));
48
+ img.crossOrigin = 'anonymous';
49
+ img.referrerPolicy = 'no-referrer';
50
+ img.src = image!; // 要加载的图片 url, 可以是base64
51
+ img.onload = () => {
52
+ ctx.drawImage(img, (-imageWidth * ratio) / 2, (-imageHeight * ratio) / 2, imageWidth * ratio, imageHeight * ratio);
53
+ ctx.restore();
54
+ state.base64Url = canvas.toDataURL();
55
+ };
56
+ };
57
+ const dealWithText = (ctx: any, ratio: number, canvas: HTMLCanvasElement, markWidth: number, markHeight: number) => {
58
+ ctx.textBaseline = 'middle';
59
+ ctx.textAlign = 'center';
60
+ // 文字绕中间旋转
61
+ ctx.translate(markWidth / 2, markHeight / 2);
62
+ ctx.rotate((Math.PI / 180) * Number(rotate));
63
+ const markSize = Number(fontSize) * ratio;
64
+ ctx.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
65
+ ctx.fillStyle = color;
66
+ ctx.textAlign = textAlign;
67
+ if (Array.isArray(content)) {
68
+ content?.forEach((item, index) => {
69
+ ctx.fillText(item, 0, (index - 1) * markSize);
70
+ });
71
+ } else {
72
+ ctx.fillText(content, 0, 0);
73
+ }
74
+ ctx.restore();
75
+
76
+ state.base64Url = canvas.toDataURL();
77
+ };
78
+ // #ifdef H5
79
+ const initH5 = () => {
80
+ const ratio = utils.System.getWindowInfo().pixelRatio;
81
+ const canvasWidth = `${(gapX + width) * ratio}px`;
82
+ const canvasHeight = `${(gapY + height) * ratio}px`;
83
+ const markWidth = width * ratio;
84
+ const markHeight = height * ratio;
85
+
86
+ const canvas = document.createElement('canvas');
87
+ const ctx = canvas.getContext('2d');
88
+ canvas.setAttribute('width', canvasWidth);
89
+ canvas.setAttribute('height', canvasHeight);
90
+
91
+ if (ctx) {
92
+ if (image) {
93
+ const img = new Image();
94
+ dealWithImage(ctx, img, ratio, canvas, markWidth, markHeight);
95
+ } else if (content) {
96
+ dealWithText(ctx, ratio, canvas, markWidth, markHeight);
97
+ }
98
+ } else {
99
+ throw new Error('当前环境不支持Canvas');
100
+ }
101
+ };
102
+ debounce(initH5);
103
+ // #endif
30
104
 
31
- const init = async () => {
105
+ // #ifdef MP
106
+ const initMP = async () => {
32
107
  let ratio = utils.System.getWindowInfo().pixelRatio;
33
108
 
34
109
  const canvasWidth = `${(gapX + width) * ratio}`;
35
110
  const canvasHeight = `${(gapY + height) * ratio}`;
36
111
  const markWidth = width * ratio;
37
112
  const markHeight = height * ratio;
113
+
38
114
  const canvas: any = uni.createOffscreenCanvas({
39
115
  type: '2d',
40
116
  width: Number(canvasWidth),
@@ -55,79 +131,99 @@ const init = async () => {
55
131
  throw new Error('当前环境不支持Canvas');
56
132
  }
57
133
  };
58
- const initH5 = () => {
59
- const canvas = document.createElement('canvas');
134
+ debounce(initMP);
135
+ // #endif
136
+ // #ifdef APP-PLUS
137
+ // #ifdef APP-PLUS
138
+ const initAPP = () => {
60
139
  const ratio = utils.System.getWindowInfo().pixelRatio;
61
-
62
- const ctx = canvas.getContext('2d');
63
- const canvasWidth = `${(gapX + width) * ratio}px`;
64
- const canvasHeight = `${(gapY + height) * ratio}px`;
140
+ const canvasWidth = (gapX + width) * ratio;
141
+ const canvasHeight = (gapY + height) * ratio;
65
142
  const markWidth = width * ratio;
66
143
  const markHeight = height * ratio;
67
- canvas.setAttribute('width', canvasWidth);
68
- canvas.setAttribute('height', canvasHeight);
144
+
145
+ // 创建 Canvas 上下文
146
+ const ctx: any = uni.createCanvasContext(canvasId);
69
147
 
70
148
  if (ctx) {
149
+ // 完全重置画布
150
+ ctx.clearRect(0, 0, canvasWidth * 2, canvasHeight * 2);
151
+
152
+ // 填充透明背景确保清空
153
+ ctx.setFillStyle('rgba(255, 255, 255, 0)');
154
+ ctx.fillRect(0, 0, canvasWidth * 2, canvasHeight * 2);
155
+
156
+ // 开始新的绘制路径
157
+ ctx.beginPath();
158
+
71
159
  if (image) {
72
- const img = new Image();
73
- dealWithImage(ctx, img, ratio, canvas, markWidth, markHeight);
160
+ // 处理图片水印
161
+ ctx.save();
162
+ ctx.translate(markWidth / 2, markHeight / 2);
163
+ ctx.rotate((Math.PI / 180) * Number(rotate));
164
+
165
+ // 绘制图片
166
+ ctx.drawImage(image, (-imageWidth * ratio) / 2, (-imageHeight * ratio) / 2, imageWidth * ratio, imageHeight * ratio);
167
+ ctx.restore();
74
168
  } else if (content) {
75
- dealWithText(ctx, ratio, canvas, markWidth, markHeight);
169
+ // 处理文字水印
170
+ ctx.save();
171
+ ctx.setTextBaseline('middle');
172
+ ctx.setTextAlign('center');
173
+
174
+ // 文字绕中间旋转
175
+ ctx.translate(markWidth / 2, markHeight / 2);
176
+ ctx.rotate((Math.PI / 180) * Number(rotate));
177
+
178
+ const markSize = Number(fontSize) * ratio;
179
+ ctx.setFontSize(markSize); // 使用专用方法设置字体大小
180
+ if (color) ctx.setFillStyle(color);
181
+ if (textAlign) ctx.setTextAlign(textAlign as any);
182
+
183
+ if (Array.isArray(content)) {
184
+ content.forEach((item: any, index) => {
185
+ ctx.fillText(item, 0, (index - 1) * markSize);
186
+ });
187
+ } else {
188
+ ctx.fillText(content, 0, 0);
189
+ }
190
+ ctx.restore();
76
191
  }
77
- } else {
78
- throw new Error('当前环境不支持Canvas');
79
- }
80
- };
81
- const dealWithImage = (ctx: any, img: HTMLImageElement, ratio: number, canvas: HTMLCanvasElement, markWidth: number, markHeight: number) => {
82
- ctx.translate(markWidth / 2, markHeight / 2);
83
- ctx.rotate((Math.PI / 180) * Number(rotate));
84
- img.crossOrigin = 'anonymous';
85
- img.referrerPolicy = 'no-referrer';
86
- img.src = image!; // 要加载的图片 url, 可以是base64
87
- img.onload = () => {
88
- ctx.drawImage(img, (-imageWidth * ratio) / 2, (-imageHeight * ratio) / 2, imageWidth * ratio, imageHeight * ratio);
89
- ctx.restore();
90
- state.base64Url = canvas.toDataURL();
91
- };
92
- };
93
- const dealWithText = (ctx: any, ratio: number, canvas: HTMLCanvasElement, markWidth: number, markHeight: number) => {
94
- ctx.textBaseline = 'middle';
95
- ctx.textAlign = 'center';
96
- // 文字绕中间旋转
97
- ctx.translate(markWidth / 2, markHeight / 2);
98
- ctx.rotate((Math.PI / 180) * Number(rotate));
99
- const markSize = Number(fontSize) * ratio;
100
- ctx.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
101
- ctx.fillStyle = color;
102
- ctx.textAlign = textAlign;
103
- if (Array.isArray(content)) {
104
- content?.forEach((item, index) => {
105
- ctx.fillText(item, 0, (index - 1) * markSize);
192
+
193
+ // 导出为 base64 图片
194
+ ctx.draw(true, () => {
195
+ // 使用 true 参数清空画布后再绘制
196
+ uni.canvasToTempFilePath({
197
+ canvasId: canvasId,
198
+ success: res => {
199
+ state.base64Url = res.tempFilePath;
200
+ },
201
+ fail: err => {
202
+ console.error('导出图片失败:', err);
203
+ },
204
+ });
106
205
  });
107
206
  } else {
108
- ctx.fillText(content, 0, 0);
207
+ throw new Error('当前环境不支持Canvas');
109
208
  }
110
- ctx.restore();
111
-
112
- state.base64Url = canvas.toDataURL();
113
209
  };
114
- // #ifdef H5
115
- initH5();
116
210
  // #endif
117
-
118
- // #ifndef H5
119
- init();
211
+ debounce(initAPP);
120
212
  // #endif
121
213
 
122
214
  watch(
123
215
  () => props,
124
216
  () => {
125
217
  // #ifdef H5
126
- initH5();
218
+ debounce(initH5);
219
+ // #endif
220
+
221
+ // #ifdef MP
222
+ debounce(initMP);
127
223
  // #endif
128
224
 
129
- // #ifndef H5
130
- init();
225
+ // #ifdef APP-PLUS
226
+ debounce(initAPP);
131
227
  // #endif
132
228
  }
133
229
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellar-ui-plus",
3
- "version": "1.23.7",
3
+ "version": "1.23.9",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",