@tplc/wot 0.1.31 → 0.1.37

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.
@@ -1,1050 +1,18 @@
1
1
  <template>
2
- <view
3
- class="uqrcode"
4
- :class="[{ 'uqrcode-hide': hide }, customClass]"
5
- :style="{ width: `${templateOptions.width}px`, height: `${templateOptions.height}px` }"
6
- >
7
- <view class="uqrcode-canvas-wrapper">
8
- <!-- 画布 -->
9
- <!-- #ifndef APP-NVUE -->
10
- <canvas
11
- class="uqrcode-canvas"
12
- :id="canvasId"
13
- :canvas-id="canvasId"
14
- :type="canvasType"
15
- :style="{
16
- width: `${templateOptions.canvasWidth}px`,
17
- height: `${templateOptions.canvasHeight}px`,
18
- transform: templateOptions.canvasTransform,
19
- }"
20
- v-if="templateOptions.canvasDisplay"
21
- @click="onClick"
22
- ></canvas>
23
- <!-- #endif -->
24
-
25
- <!-- nvue用gcanvas -->
26
- <!-- #ifdef APP-NVUE -->
27
- <gcanvas
28
- class="uqrcode-canvas"
29
- ref="gcanvas"
30
- :style="{
31
- width: `${templateOptions.canvasWidth}px`,
32
- height: `${templateOptions.canvasHeight}px`,
33
- }"
34
- v-if="templateOptions.canvasDisplay"
35
- @click="onClick"
36
- ></gcanvas>
37
- <!-- #endif -->
38
- </view>
39
-
40
- <!-- 加载效果 -->
41
- <view class="uqrcode-makeing" v-if="loading === undefined ? makeing : loading">
42
- <slot name="loading">
43
- <image
44
- class="uqrcode-makeing-image"
45
- :style="{
46
- width: `${templateOptions.size / 4}px`,
47
- height: `${templateOptions.size / 4}px`,
48
- }"
49
- src="data:image/gif;base64,R0lGODlhAAEAAfIEAOHh4SSsWuDg4N3d3f///wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/wtYTVAgRGF0YVhNUDw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sb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G46ibv5sGJQeN6IijM6oGUhpkHMdSe6CGgJrUq0Drd7wegppWbDdlpIFl/KiWBtrY5ll9VZaXGFz5aJdqPZu1b1Z25a86petUJV1kxUeKXhr4niLYaaZTFmKP03RjlbePDkzIc8nOIt+3Ae0idGonUrE7HNj6tc6WlMy7Qe2bcvLSNG2c7v3gt1tgKPw7Vv4GOMgiBeX3Qj5B+W9nWOR7gi6bepOsFu/zpyR9u2vsX/srhn8aPE47x00f578Z/eh2bdfPRv+afmi0fed1BQ/VzH/3/lXmX6E0eeSgAPaV0eACP6XBXaRRSjhhBRWaOGFGGao4YYcdujhhyCGKOKIJJZo4okopqjiimQB4OKLMMYo44w01mjjjTMSKMCOPPbo449ABinkkDgWaeSROOpI5JJMNonkk1BGqaSTVFYZ5ZVY3jillVx2meWXSG7p5Zhkgmmmi2KWqeaZbBqZ5ppwtilnjG/GaeecbNZ55554Yqknn4D2eeSfgRYqaI2EGqrooS8muiijkDr6KKSCSjoppXNaeimmeSq46aec2qgpqKH66SmpqJYKwKipqjroqa3yKVWSsP64oaknSVmrj7deOauWu/bYq665QgmhhrgCRexl/1UOayxFy+bGpbNP/ipqsDxSGya0zxropLavFlsttjuC6ya343rbpLlFWosouQKwS6u426rLpLzA0hsus1Tie62+59q7pL/vAtwuvATT6K7CCCPrK7r18vutw9Hm9LDARCacI8T7SmulxjIuvDHGQ4JMJ8cBS7wuxa6GjPK9LLcMo8i2xiwzmi8PbPPNNPO6s8w9C/tzy0FnO7SrRZd7tKpJx7t0qU2bzGjUT4fadKxYn2xw1lwfvHXXYDP8ddhkN5pz2WhfjTbQZ68dttpuM9123De7PDbddZvJatZUk4x3xbsk6/Hfa/atMuGCWww4f4gXPrfYhzferbKTDy554hmBXxz55R0rXvlgnGvO1OJphS665+luTncCADs="
50
- ></image>
51
- </slot>
52
- </view>
53
-
54
- <!-- 错误处理 -->
55
- <view class="uqrcode-error" v-if="isError" @click="onClick">
56
- <slot name="error" :error="error">
57
- <text class="uqrcode-error-message">{{ error.errMsg }}</text>
58
- </slot>
59
- </view>
60
-
61
- <!-- H5保存提示 -->
62
- <!-- #ifdef H5 -->
63
- <view class="uqrcode-h5-save" v-if="isH5Save">
64
- <slot name="h5save" :tempFilePath="tempFilePath">
65
- <image class="uqrcode-h5-save-image" :src="tempFilePath"></image>
66
- <text class="uqrcode-h5-save-text">
67
- {{ h5SaveIsDownload ? '若保存失败,' : '' }}请长按二维码进行保存
68
- </text>
69
- </slot>
70
- <view class="uqrcode-h5-save-close" @click.stop="isH5Save = false">
71
- <view class="uqrcode-h5-save-close-before"></view>
72
- <view class="uqrcode-h5-save-close-after"></view>
73
- </view>
74
- </view>
75
- <!-- #endif -->
2
+ <view :class="customClass">
3
+ <Uqrcode v-bind="$props" />
76
4
  </view>
77
5
  </template>
78
- <script lang="ts">
79
- export default {
6
+ <script lang="ts" setup>
7
+ import Uqrcode from './uqrcode.vue'
8
+ import { qrCodeProps } from './types'
9
+ defineOptions({
80
10
  name: 'wd-qr-code',
81
11
  options: {
82
12
  virtualHost: true,
83
13
  addGlobalClass: true,
84
14
  styleIsolation: 'shared',
85
15
  },
86
- }
87
- </script>
88
- <script lang="ts" setup>
89
- // #ifdef VUE3
90
- import { getCurrentInstance, nextTick, onMounted, ref, toRaw, watch } from 'vue'
91
- // #endif
92
- import { qrCodeProps } from './types'
93
- /* 引入uQRCode核心js */
94
- import UQRCode from './js_sdk/uqrcode/uqrcode'
95
- /* 引入nvue所需模块 */
96
- // #ifdef APP-NVUE
97
- // @ts-ignore
98
- import { enable, WeexBridge } from './js_sdk/gcanvas'
99
- // @ts-ignore
100
- const modal = weex.requireModule('modal')
101
- // #endif
102
- /* 引入队列 */
103
- // @ts-ignore
104
- import { queueDraw, queueLoadImage } from './common/queue'
105
- /* 引入缓存图片 */
106
- // @ts-ignore
107
- import { cacheImageList } from './common/cache'
108
- let instance: any = null
109
- const emits = defineEmits(['click', 'error', 'make', 'draw', 'save', 'complete', 'change'])
110
- const props = defineProps(qrCodeProps)
111
- const canvas = ref()
112
- const canvasType = ref()
113
- const canvasContext = ref()
114
- const makeDelegate = ref()
115
- const drawDelegate = ref()
116
- const toTempFilePathDelegate = ref()
117
- const makeExecuted = ref(false)
118
- const makeing = ref(false)
119
- const drawing = ref(false)
120
- const isError = ref(false)
121
- const error = ref()
122
- const isH5Save = ref(false)
123
- const tempFilePath = ref('')
124
- const gcanvas = ref()
125
- const templateOptions = ref({
126
- size: 0,
127
- width: 0, // 组件宽度
128
- height: 0,
129
- canvasWidth: 0, // canvas宽度
130
- canvasHeight: 0,
131
- canvasTransform: '',
132
- canvasDisplay: false,
133
- })
134
- const uqrcodeOptions = ref({ data: '' } as any)
135
- const plugins = ref([] as any[])
136
- const makeingPattern = ref([
137
- [
138
- [true, true, true, false, false, false, false, true, true, true],
139
- [true, true, true, false, false, false, false, true, true, true],
140
- [true, true, true, false, false, false, false, true, true, true],
141
- [true, true, true, false, false, false, false, true, true, true],
142
- [true, true, true, false, false, false, false, true, true, true],
143
- [true, true, true, false, false, false, false, true, true, true],
144
- [true, true, true, false, false, false, false, true, true, true],
145
- [true, true, true, true, true, true, true, true, true, true],
146
- [true, true, true, true, true, true, true, true, true, true],
147
- [true, true, true, true, true, true, true, true, true, true],
148
- ],
149
- [
150
- [true, true, true, true, true, true, true, true, true, true],
151
- [true, true, true, true, true, true, true, true, true, true],
152
- [true, true, true, true, true, true, true, true, true, true],
153
- [true, true, true, false, false, false, false, true, true, true],
154
- [true, true, true, false, false, false, false, true, true, true],
155
- [true, true, true, false, false, false, false, true, true, true],
156
- [true, true, true, false, false, false, false, false, false, false],
157
- [true, true, true, true, true, true, false, true, true, true],
158
- [true, true, true, true, true, true, false, true, true, true],
159
- [true, true, true, true, true, true, false, true, true, true],
160
- ],
161
- [
162
- [true, true, true, true, true, true, true, true, true, true],
163
- [true, true, true, true, true, true, true, true, true, true],
164
- [true, true, true, true, true, true, true, true, true, true],
165
- [true, true, true, false, false, false, false, true, true, true],
166
- [true, true, true, false, false, false, false, true, true, true],
167
- [true, true, true, true, true, true, true, false, false, false],
168
- [true, true, true, true, true, true, true, false, false, false],
169
- [true, true, true, true, true, true, true, false, false, false],
170
- [true, true, true, false, false, false, false, true, true, true],
171
- [true, true, true, false, false, false, false, true, true, true],
172
- ],
173
- [
174
- [true, true, true, true, true, true, true, true, true, true],
175
- [true, true, true, true, true, true, true, true, true, true],
176
- [true, true, true, true, true, true, true, true, true, true],
177
- [true, true, true, false, false, false, false, false, false, false],
178
- [true, true, true, false, false, false, false, false, false, false],
179
- [true, true, true, false, false, false, false, false, false, false],
180
- [true, true, true, false, false, false, false, false, false, false],
181
- [true, true, true, true, true, true, true, true, true, true],
182
- [true, true, true, true, true, true, true, true, true, true],
183
- [true, true, true, true, true, true, true, true, true, true],
184
- ],
185
- ])
186
- watch(
187
- () => props.type,
188
- (val) => {
189
- const types = ['2d']
190
- if (types.includes(val)) {
191
- canvasType.value = val
192
- } else {
193
- canvasType.value = undefined
194
- }
195
- },
196
- {
197
- immediate: true,
198
- },
199
- )
200
-
201
- watch(
202
- () => props.value,
203
- () => {
204
- if (props.auto) {
205
- remake()
206
- }
207
- },
208
- )
209
-
210
- watch(
211
- () => props.size,
212
- () => {
213
- if (props.auto) {
214
- remake()
215
- }
216
- },
217
- )
218
-
219
- watch(
220
- () => props.options,
221
- () => {
222
- if (props.auto) {
223
- remake()
224
- }
225
- },
226
- {
227
- deep: true,
228
- },
229
- )
230
-
231
- watch(
232
- () => makeing.value,
233
- (val) => {
234
- if (!val) {
235
- if (typeof toTempFilePathDelegate.value === 'function') {
236
- toTempFilePathDelegate.value()
237
- }
238
- }
239
- },
240
- )
241
-
242
- onMounted(() => {
243
- templateOptions.value = {
244
- size: props.sizeUnit === 'rpx' ? uni.upx2px(props.size) : props.size,
245
- width: props.size,
246
- height: props.size,
247
- canvasWidth: props.size,
248
- canvasHeight: props.size,
249
- canvasTransform: `scale(${props.size / props.size}, ${props.size / props.size})`,
250
- canvasDisplay: false,
251
- }
252
-
253
- if (canvasType.value === '2d') {
254
- // #ifndef MP-WEIXIN
255
- templateOptions.value.canvasTransform = `scale(${templateOptions.value.size / templateOptions.value.canvasWidth}, ${
256
- templateOptions.value.size / templateOptions.value.canvasHeight
257
- })`
258
- // #endif
259
- } else {
260
- templateOptions.value.canvasTransform = `scale(${templateOptions.value.size / templateOptions.value.canvasWidth}, ${
261
- templateOptions.value.size / templateOptions.value.canvasHeight
262
- })`
263
- }
264
- if (props.start) {
265
- make()
266
- }
267
16
  })
268
-
269
- const getTemplateOptions = () => {
270
- const size = props.sizeUnit === 'rpx' ? uni.upx2px(props.size as any) : props.size
271
- return deepReplace(templateOptions.value, {
272
- size,
273
- width: size,
274
- height: size,
275
- })
276
- }
277
-
278
- const getUqrcodeOptions = () => {
279
- return deepReplace(toRaw(props.options), {
280
- data: String(props.value),
281
- size: Number(templateOptions.value.size),
282
- })
283
- }
284
-
285
- const resetCanvas = (callback) => {
286
- templateOptions.value.canvasDisplay = false
287
- nextTick(() => {
288
- templateOptions.value.canvasDisplay = true
289
- nextTick(() => {
290
- callback && callback()
291
- })
292
- })
293
- }
294
-
295
- const draw = async (callback: any = {}, isDrawDelegate = false) => {
296
- if (typeof callback.success !== 'function') {
297
- callback.success = () => {}
298
- }
299
- if (typeof callback.fail !== 'function') {
300
- callback.fail = () => {}
301
- }
302
- if (typeof callback.complete !== 'function') {
303
- callback.complete = () => {}
304
- }
305
-
306
- if (drawing.value) {
307
- if (!isDrawDelegate) {
308
- drawDelegate.value = () => {
309
- draw(callback, true)
310
- }
311
- return
312
- }
313
- } else {
314
- drawing.value = true
315
- }
316
-
317
- if (!props.canvasId) {
318
- console.error('[uQRCode]: canvasId must be set!')
319
- isError.value = true
320
- drawing.value = false
321
- callback.fail({
322
- errMsg: '[uQRCode]: canvasId must be set!',
323
- })
324
- callback.complete({
325
- errMsg: '[uQRCode]: canvasId must be set!',
326
- })
327
- return
328
- }
329
- if (!props.value) {
330
- console.error('[uQRCode]: value must be set!')
331
- isError.value = true
332
- drawing.value = false
333
- callback.fail({
334
- errMsg: '[uQRCode]: value must be set!',
335
- })
336
- callback.complete({
337
- errMsg: '[uQRCode]: value must be set!',
338
- })
339
- return
340
- }
341
-
342
- /* 组件数据 */
343
- templateOptions.value = getTemplateOptions()
344
- /* uQRCode选项 */
345
- uqrcodeOptions.value = getUqrcodeOptions()
346
- /* 纠错等级兼容字母写法 */
347
- if (typeof uqrcodeOptions.value.errorCorrectLevel === 'string') {
348
- uqrcodeOptions.value.errorCorrectLevel =
349
- UQRCode.errorCorrectLevel[uqrcodeOptions.value.errorCorrectLevel]
350
- }
351
- /* nvue不支持动态修改gcanvas尺寸,除nvue外,默认使用useDynamicSize */
352
- // #ifndef APP-NVUE
353
- if (typeof props.options?.useDynamicSize === 'undefined') {
354
- uqrcodeOptions.value.useDynamicSize = true
355
- }
356
- // #endif
357
- // #ifdef APP-NVUE
358
- if (typeof props.options?.useDynamicSize === 'undefined') {
359
- uqrcodeOptions.value.useDynamicSize = false
360
- }
361
- // if (typeof props.options.drawReserve === 'undefined') {
362
- // this.uqrcodeOptions.drawReserve = true;
363
- // }
364
- // #endif
365
- /* 获取uQRCode实例 */
366
- const qr = (instance = new UQRCode())
367
- /* 注册扩展 */
368
- plugins.value.forEach((p) => qr.register(p.plugin))
369
- /* 设置uQRCode选项 */
370
- qr.setOptions(uqrcodeOptions.value)
371
- /* 调用制作二维码方法 */
372
- qr.make()
373
-
374
- // #ifndef APP-NVUE
375
- if (canvasType.value === '2d') {
376
- // #ifdef MP-WEIXIN
377
- /* 微信小程序获取canvas2d上下文方式 */
378
-
379
- canvas.value = await new Promise((resolve) => {
380
- uni
381
- .createSelectorQuery()
382
- .in(getCurrentInstance()) // 在组件内使用需要
383
- .select(`#${props.canvasId}`)
384
- .fields(
385
- {
386
- node: true,
387
- size: true,
388
- },
389
- (res) => {
390
- resolve(res[0].node)
391
- },
392
- )
393
- .exec((res) => {
394
- resolve(res[0].node)
395
- })
396
- })
397
-
398
- canvasContext.value = canvas.value.getContext('2d')
399
- /* 2d的组件设置宽高与实际canvas绘制宽高不是一个,打个比方,组件size=200,canvas.width设置为100,那么绘制出来就是100=200,组件size=400,canvas.width设置为800,绘制大小还是800=400,所以无需理会下方返回的dynamicSize是多少,按dpr重新赋值给canvas即可 */
400
- templateOptions.value.canvasWidth = qr.size
401
- templateOptions.value.canvasHeight = qr.size
402
- templateOptions.value.canvasTransform = ''
403
- /* 使用dynamicSize+scale,可以解决小块间出现白线问题,dpr可以解决模糊问题 */
404
- const dpr = uni.getSystemInfoSync().pixelRatio
405
- canvas.value.width = qr.dynamicSize * dpr
406
- canvas.value.height = qr.dynamicSize * dpr
407
- canvasContext.value.scale(dpr, dpr)
408
- /* 微信小程序获取图像方式 */
409
- qr.loadImage = getLoadImage(function (src) {
410
- /* 小程序下获取网络图片信息需先配置download域名白名单才能生效 */
411
- return new Promise((resolve, reject) => {
412
- const img = canvas.value.createImage()
413
- img.src = src
414
- img.onload = () => {
415
- resolve(img)
416
- }
417
- img.onerror = (err) => {
418
- reject(err)
419
- }
420
- })
421
- })
422
- // #endif
423
- // #ifndef MP-WEIXIN
424
- /* 非微信小程序不支持2d,切换回uniapp获取canvas上下文方式 */
425
- const instance = getCurrentInstance()
426
-
427
- canvasContext.value = uni.createCanvasContext(props.canvasId, instance)
428
- /* 使用dynamicSize,可以解决小块间出现白线问题,再通过scale缩放至size,使其达到所设尺寸 */
429
- templateOptions.value.canvasWidth = qr.dynamicSize
430
- templateOptions.value.canvasHeight = qr.dynamicSize
431
- templateOptions.value.canvasTransform = `scale(${templateOptions.value.size / templateOptions.value.canvasWidth}, ${
432
- templateOptions.value.size / templateOptions.value.canvasHeight
433
- })`
434
- /* uniapp获取图像方式 */
435
- qr.loadImage = getLoadImage(function (src) {
436
- return new Promise((resolve, reject) => {
437
- if (src.startsWith('http')) {
438
- uni.getImageInfo({
439
- src,
440
- success: (res) => {
441
- resolve(res.path)
442
- },
443
- fail: (err) => {
444
- reject(err)
445
- },
446
- })
447
- } else {
448
- if (src.startsWith('.')) {
449
- console.error('[uQRCode]: 本地图片路径仅支持绝对路径!')
450
- throw new Error('[uQRCode]: local image path only supports absolute path!')
451
- } else {
452
- resolve(src)
453
- }
454
- }
455
- })
456
- })
457
- // #endif
458
- } else {
459
- /* uniapp获取canvas上下文方式 */
460
- canvasContext.value = uni.createCanvasContext(props.canvasId, getCurrentInstance())
461
- /* 使用dynamicSize,可以解决小块间出现白线问题,再通过scale缩放至size,使其达到所设尺寸 */
462
- templateOptions.value.canvasWidth = qr.dynamicSize
463
- templateOptions.value.canvasHeight = qr.dynamicSize
464
- templateOptions.value.canvasTransform = `scale(${templateOptions.value.size / templateOptions.value.canvasWidth}, ${
465
- templateOptions.value.size / templateOptions.value.canvasHeight
466
- })`
467
- /* uniapp获取图像方式 */
468
- qr.loadImage = getLoadImage(function (src) {
469
- return new Promise((resolve, reject) => {
470
- /* getImageInfo在微信小程序的bug:本地路径返回路径会把开头的/或../移除,导致路径错误,解决方法:限制只能使用绝对路径 */
471
- if (src.startsWith('http')) {
472
- uni.getImageInfo({
473
- src,
474
- success: (res) => {
475
- resolve(res.path)
476
- },
477
- fail: (err) => {
478
- reject(err)
479
- },
480
- })
481
- } else {
482
- if (src.startsWith('.')) {
483
- console.error('[uQRCode]: 本地图片路径仅支持绝对路径!')
484
- throw new Error('[uQRCode]: local image path only supports absolute path!')
485
- } else {
486
- resolve(src)
487
- }
488
- }
489
- })
490
- })
491
- }
492
- // #endif
493
- // #ifdef APP-NVUE
494
- /* NVue获取canvas上下文方式 */
495
- const cCanvas = enable(gcanvas.value, {
496
- bridge: WeexBridge,
497
- })
498
- canvasContext.value = cCanvas.getContext('2d')
499
- /* NVue获取图像方式 */
500
- qr.loadImage = getLoadImage(function (src) {
501
- return new Promise((resolve, reject) => {
502
- /* getImageInfo在nvue的bug:获取同一个路径的图片信息,同一时间第一次获取成功,后续失败,猜测是写入本地时产生文件写入冲突,所以没有返回,特别是对于网络资源 --- 已实现队列绘制,已解决此问题 */
503
- if (src.startsWith('.')) {
504
- console.error('[uQRCode]: 本地图片路径仅支持绝对路径!')
505
- throw new Error('[uQRCode]: local image path only supports absolute path!')
506
- } else {
507
- uni.getImageInfo({
508
- src,
509
- success: (res) => {
510
- resolve(res.path)
511
- },
512
- fail: (err) => {
513
- reject(err)
514
- },
515
- })
516
- }
517
- })
518
- })
519
- // #endif
520
- /* 设置uQRCode实例的canvas上下文 */
521
- qr.canvasContext = canvasContext.value
522
- /* 延时等待页面重新绘制完毕 */
523
- setTimeout(() => {
524
- /* 从插件获取具体要调用哪一个扩展函数 */
525
- const plugin = plugins.value.find((p) => p.name === qr.style)
526
- const drawCanvasName = plugin ? plugin.drawCanvas : 'drawCanvas'
527
- /* 虽然qr[drawCanvasName]是直接返回Promise的,但由于js内部this指向问题,故不能直接exec(qr[drawCanvasName])此方式执行,需要改成exec(() => qr[drawCanvasName]())才能正确获取this */
528
- let drawCanvas
529
- if (props.queue) {
530
- drawCanvas = () => queueDraw.exec(() => qr[drawCanvasName]())
531
- } else {
532
- drawCanvas = () => qr[drawCanvasName]()
533
- }
534
- /* 调用绘制方法将二维码图案绘制到canvas上 */
535
- drawCanvas()
536
- .then(() => {
537
- if (drawDelegate.value) {
538
- /* 高频重绘纠正 */
539
- const delegate = drawDelegate.value
540
- drawDelegate.value = undefined
541
- delegate()
542
- } else {
543
- drawing.value = false
544
- callback.success()
545
- }
546
- })
547
- .catch((err) => {
548
- console.log(err)
549
- if (drawDelegate.value) {
550
- /* 高频重绘纠正 */
551
- const delegate = drawDelegate.value
552
- drawDelegate.value = undefined
553
- delegate()
554
- } else {
555
- drawing.value = false
556
- isError.value = true
557
- callback.fail(err)
558
- }
559
- })
560
- .finally(() => {
561
- callback.complete()
562
- })
563
- }, 300)
564
- }
565
-
566
- /**
567
- * 生成二维码
568
- */
569
- const make = (callback: any = {}) => {
570
- makeExecuted.value = true
571
- makeing.value = true
572
- isError.value = false
573
-
574
- if (typeof callback.success !== 'function') {
575
- callback.success = () => {}
576
- }
577
- if (typeof callback.fail !== 'function') {
578
- callback.fail = () => {}
579
- }
580
- if (typeof callback.complete !== 'function') {
581
- callback.complete = () => {}
582
- }
583
-
584
- resetCanvas(() => {
585
- clearTimeout(makeDelegate.value)
586
- makeDelegate.value = setTimeout(() => {
587
- draw({
588
- success: () => {
589
- setTimeout(() => {
590
- callback.success()
591
- complete(true)
592
- }, 300)
593
- },
594
- fail: (err) => {
595
- callback.fail(err)
596
- error.value = err
597
- complete(false, err.errMsg)
598
- },
599
- complete: () => {
600
- callback.complete()
601
- makeing.value = false
602
- },
603
- })
604
- }, 300)
605
- })
606
- }
607
-
608
- /**
609
- * 重新生成
610
- */
611
- const remake = (callback: any = {}) => {
612
- emits('change')
613
- make(callback)
614
- }
615
-
616
- /**
617
- * 生成完成
618
- */
619
-
620
- const complete = (success = true, errMsg = '') => {
621
- if (success) {
622
- emits('complete', {
623
- success,
624
- })
625
- } else {
626
- emits('complete', {
627
- success,
628
- errMsg,
629
- })
630
- }
631
- }
632
-
633
- /**
634
- * 导出临时路径
635
- */
636
- const toTempFilePath = (callback: any = {}) => {
637
- if (typeof callback.success !== 'function') {
638
- callback.success = () => {}
639
- }
640
- if (typeof callback.fail !== 'function') {
641
- callback.fail = () => {}
642
- }
643
- if (typeof callback.complete !== 'function') {
644
- callback.complete = () => {}
645
- }
646
-
647
- if (!makeExecuted.value) {
648
- console.error('[uQRCode]: make() 方法从未调用!请先成功调用 make() 后再进行操作。')
649
- const err = {
650
- errMsg:
651
- '[uQRCode]: make() method has never been executed! please execute make() successfully before operating.',
652
- }
653
- callback.fail(err)
654
- callback.complete(err)
655
- return
656
- }
657
-
658
- if (isError.value) {
659
- callback.fail(error.value)
660
- callback.complete(error.value)
661
- return
662
- }
663
-
664
- if (makeing.value) {
665
- /* 如果还在生成状态,那当前操作将托管到委托,监听生成完成后再通过委托复调当前方法 */
666
- toTempFilePathDelegate.value = () => {
667
- toTempFilePath(callback)
668
- }
669
- return
670
- } else {
671
- toTempFilePathDelegate.value = null
672
- }
673
-
674
- // #ifndef APP-NVUE
675
- if (canvasType.value === '2d') {
676
- // #ifdef MP-WEIXIN
677
- try {
678
- let dataURL = null
679
- // #ifdef VUE3
680
- dataURL = toRaw(canvas.value).toDataURL()
681
- // #endif
682
- // #ifndef VUE3
683
- dataURL = canvas.value.toDataURL()
684
- // #endif
685
- callback.success({
686
- tempFilePath: dataURL,
687
- })
688
- callback.complete({
689
- tempFilePath: dataURL,
690
- })
691
- } catch (e) {
692
- callback.fail(e)
693
- callback.complete(e)
694
- }
695
- // #endif
696
- } else {
697
- const instance = getCurrentInstance()
698
- uni.canvasToTempFilePath(
699
- {
700
- canvasId: props.canvasId,
701
- fileType: props.fileType,
702
- width: Number(templateOptions.value.canvasWidth),
703
- height: Number(templateOptions.value.canvasHeight),
704
- destWidth: Number(templateOptions.value.size),
705
- destHeight: Number(templateOptions.value.size),
706
- success: (res) => {
707
- callback.success(res)
708
- },
709
- fail: (err) => {
710
- callback.fail(err)
711
- },
712
- complete: () => {
713
- callback.complete()
714
- },
715
- },
716
- instance,
717
- )
718
- }
719
- // #endif
720
- // #ifdef APP-NVUE
721
- const dpr = uni.getSystemInfoSync().pixelRatio
722
- canvasContext.value.toTempFilePath(
723
- 0,
724
- 0,
725
- templateOptions.value.canvasWidth * dpr,
726
- templateOptions.value.canvasHeight * dpr,
727
- templateOptions.value.size * dpr,
728
- templateOptions.value.size * dpr,
729
- '',
730
- 1,
731
- (res) => {
732
- callback.success(res)
733
- callback.complete(res)
734
- },
735
- )
736
- // #endif
737
- }
738
- /**
739
- * 保存
740
- */
741
- const save = (callback: any = {}) => {
742
- if (typeof callback.success !== 'function') {
743
- callback.success = () => {}
744
- }
745
- if (typeof callback.fail !== 'function') {
746
- callback.fail = () => {}
747
- }
748
- if (typeof callback.complete !== 'function') {
749
- callback.complete = () => {}
750
- }
751
-
752
- toTempFilePath({
753
- success: (res) => {
754
- // #ifndef H5
755
- if (canvasType.value === '2d') {
756
- // #ifdef MP-WEIXIN
757
- /* 需要将 data:image/png;base64, 这段去除 writeFile 才能正常打开文件,否则是损坏文件,无法打开 */
758
- const reg = /^data:image\/png;base64,/g
759
- const dataURL = res.tempFilePath.replace(reg, '')
760
- const fs = wx.getFileSystemManager()
761
- const tempFilePath = `${wx.env.USER_DATA_PATH}/${new Date().getTime()}${
762
- Math.random().toString().split('.')[1]
763
- }.png`
764
- fs.writeFile({
765
- filePath: tempFilePath, // 要写入的文件路径 (本地路径)
766
- data: dataURL, // base64图片
767
- encoding: 'base64',
768
- success: (res1) => {
769
- uni.saveImageToPhotosAlbum({
770
- filePath: tempFilePath,
771
- success: (res2) => {
772
- callback.success(res2)
773
- },
774
- fail: (err2) => {
775
- callback.fail(err2)
776
- },
777
- complete: () => {
778
- callback.complete()
779
- },
780
- })
781
- },
782
- fail: (err) => {
783
- callback.fail(err)
784
- },
785
- complete: () => {
786
- callback.complete()
787
- },
788
- })
789
- // #endif
790
- } else {
791
- uni.saveImageToPhotosAlbum({
792
- filePath: res.tempFilePath,
793
- success: (res1) => {
794
- callback.success(res1)
795
- },
796
- fail: (err1) => {
797
- callback.fail(err1)
798
- },
799
- complete: () => {
800
- callback.complete()
801
- },
802
- })
803
- }
804
- // #endif
805
-
806
- // #ifdef H5
807
- /* 可以在电脑浏览器下载,移动端iOS不行,安卓微信浏览器不行,安卓外部浏览器可以 */
808
- isH5Save.value = true
809
- tempFilePath.value = res.tempFilePath
810
- if (props.h5SaveIsDownload) {
811
- const aEle = document.createElement('a')
812
- aEle.download = props.h5DownloadName // 设置下载的文件名,默认是'下载'
813
- aEle.href = res.tempFilePath
814
- document.body.appendChild(aEle)
815
- aEle.click()
816
- aEle.remove() // 下载之后把创建的元素删除
817
- }
818
- callback.success({
819
- errMsg: 'ok',
820
- })
821
- callback.complete({
822
- errMsg: 'ok',
823
- })
824
- // #endif
825
- },
826
- fail: (err) => {
827
- callback.fail(err)
828
- callback.complete(err)
829
- },
830
- })
831
- }
832
- /**
833
- * 注册click事件
834
- */
835
- const onClick = (e) => {
836
- emits('click', e)
837
- }
838
- /**
839
- * 获取实例
840
- */
841
- const getInstance = () => {
842
- return instance
843
- }
844
- /**
845
- * 注册扩展,组件仅支持注册type为style的drawCanvas扩展
846
- * @param {Object} plugin
847
- */
848
- const registerStyle = (plugin: any) => {
849
- if (plugin.Type !== 'style') {
850
- console.warn('[uQRCode]: registerStyle 仅支持注册 style 类型的扩展!')
851
- return {
852
- errMsg: 'registerStyle 仅支持注册 style 类型的扩展!',
853
- }
854
- }
855
- if (typeof plugin === 'function') {
856
- plugins.value.push({
857
- plugin,
858
- name: plugin.Name,
859
- drawCanvas: plugin.DrawCanvas,
860
- })
861
- }
862
- }
863
- const getLoadImage = (loadImage: any) => {
864
- if (typeof loadImage === 'function') {
865
- return function (src) {
866
- /* 判断是否是队列加载图片的 */
867
- if (props.isQueueLoadImage) {
868
- /* 解决iOS APP||NVUE同时绘制多个二维码导致图片丢失需使用队列 */
869
- return queueLoadImage.exec(() => {
870
- return new Promise((resolve, reject) => {
871
- setTimeout(() => {
872
- const cache = cacheImageList.find((x) => x.src === src)
873
- if (cache) {
874
- resolve(cache.img)
875
- } else {
876
- loadImage(src)
877
- .then((img) => {
878
- cacheImageList.push({
879
- src,
880
- img,
881
- })
882
- resolve(img)
883
- })
884
- .catch((err) => {
885
- reject(err)
886
- })
887
- }
888
- }, 10)
889
- })
890
- })
891
- } else {
892
- return loadImage(src)
893
- }
894
- }
895
- } else {
896
- return function (src) {
897
- return Promise.resolve(src)
898
- }
899
- }
900
- }
901
-
902
- /**
903
- * 对象属性深度替换
904
- * @param {Object} o 原始对象/默认对象/被替换的对象
905
- * @param {Object} r 从这个对象里取值替换到o对象里
906
- * @return {Object} 替换后的新对象
907
- */
908
- function deepReplace(o = {}, r = {}, c = false) {
909
- let obj
910
- if (c) {
911
- // 从源替换
912
- obj = o
913
- } else {
914
- // 不替换源,copy一份备份来替换
915
- obj = {
916
- ...o,
917
- }
918
- }
919
- for (const k in r) {
920
- const vr = r[k]
921
- if (vr !== undefined) {
922
- if (vr.constructor === Object) {
923
- obj[k] = deepReplace(obj[k], vr)
924
- } else if (vr.constructor === String && !vr) {
925
- // @ts-ignore
926
- // eslint-disable-next-line no-self-assign
927
- obj[k] = obj[k]
928
- } else {
929
- obj[k] = vr
930
- }
931
- }
932
- }
933
- return obj
934
- }
17
+ defineProps(qrCodeProps)
935
18
  </script>
936
-
937
- <style scoped>
938
- .uqrcode {
939
- position: relative;
940
- }
941
-
942
- .uqrcode-hide {
943
- position: fixed;
944
- left: 7500rpx;
945
- }
946
-
947
- .uqrcode-canvas {
948
- transform-origin: top left;
949
- }
950
-
951
- .uqrcode-makeing {
952
- position: absolute;
953
- top: 0;
954
- right: 0;
955
- bottom: 0;
956
- left: 0;
957
- z-index: 10;
958
- /* #ifndef APP-NVUE */
959
- display: flex;
960
- /* #endif */
961
- justify-content: center;
962
- align-items: center;
963
- }
964
-
965
- .uqrcode-makeing-image {
966
- /* #ifndef APP-NVUE */
967
- display: block;
968
- max-width: 120px;
969
- max-height: 120px;
970
- /* #endif */
971
- }
972
-
973
- .uqrcode-error {
974
- position: absolute;
975
- top: 0;
976
- right: 0;
977
- bottom: 0;
978
- left: 0;
979
- /* #ifndef APP-NVUE */
980
- display: flex;
981
- /* #endif */
982
- justify-content: center;
983
- align-items: center;
984
- }
985
-
986
- .uqrcode-error-message {
987
- font-size: 12px;
988
- color: #939291;
989
- }
990
-
991
- /* #ifdef H5 */
992
- .uqrcode-h5-save {
993
- position: fixed;
994
- top: 0;
995
- right: 0;
996
- bottom: 0;
997
- left: 0;
998
- z-index: 100;
999
- background-color: rgba(0, 0, 0, 0.68);
1000
- display: flex;
1001
- flex-direction: column;
1002
- justify-content: center;
1003
- align-items: center;
1004
- }
1005
-
1006
- .uqrcode-h5-save-image {
1007
- width: 512rpx;
1008
- height: 512rpx;
1009
- padding: 32rpx;
1010
- }
1011
-
1012
- .uqrcode-h5-save-text {
1013
- margin-top: 20rpx;
1014
- font-size: 32rpx;
1015
- font-weight: 700;
1016
- color: #ffffff;
1017
- }
1018
-
1019
- .uqrcode-h5-save-close {
1020
- position: relative;
1021
- margin-top: 72rpx;
1022
- width: 60rpx;
1023
- height: 60rpx;
1024
- border: 2rpx solid #ffffff;
1025
- border-radius: 60rpx;
1026
- padding: 10rpx;
1027
- }
1028
-
1029
- .uqrcode-h5-save-close-before {
1030
- position: absolute;
1031
- top: 50%;
1032
- left: 50%;
1033
- transform: translate(-50%, -50%) rotate(45deg);
1034
- width: 40rpx;
1035
- height: 4rpx;
1036
- background: #ffffff;
1037
- }
1038
-
1039
- .uqrcode-h5-save-close-after {
1040
- position: absolute;
1041
- top: 50%;
1042
- left: 50%;
1043
- transform: translate(-50%, -50%) rotate(-45deg);
1044
- width: 40rpx;
1045
- height: 4rpx;
1046
- background: #ffffff;
1047
- }
1048
-
1049
- /* #endif */
1050
- </style>