uview-plus 3.4.40 → 3.4.42
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/changelog.md +10 -0
- package/components/u-action-sheet/u-action-sheet.vue +0 -1
- package/components/u-album/u-album.vue +0 -2
- package/components/u-alert/u-alert.vue +0 -1
- package/components/u-avatar/u-avatar.vue +0 -1
- package/components/u-avatar-group/u-avatar-group.vue +0 -1
- package/components/u-back-top/u-back-top.vue +0 -1
- package/components/u-badge/u-badge.vue +0 -1
- package/components/u-box/u-box.vue +0 -1
- package/components/u-button/u-button.vue +0 -2
- package/components/u-calendar/header.vue +0 -1
- package/components/u-calendar/month.vue +0 -1
- package/components/u-calendar/u-calendar.vue +0 -2
- package/components/u-car-keyboard/u-car-keyboard.vue +0 -1
- package/components/u-card/u-card.vue +0 -2
- package/components/u-cell/u-cell.vue +0 -1
- package/components/u-cell-group/u-cell-group.vue +0 -1
- package/components/u-checkbox/u-checkbox.vue +0 -1
- package/components/u-checkbox-group/u-checkbox-group.vue +0 -1
- package/components/u-circle-progress/u-circle-progress.vue +0 -1
- package/components/u-code/u-code.vue +0 -1
- package/components/u-code-input/u-code-input.vue +0 -1
- package/components/u-col/u-col.vue +0 -1
- package/components/u-collapse/u-collapse.vue +0 -1
- package/components/u-collapse-item/u-collapse-item.vue +0 -1
- package/components/u-column-notice/u-column-notice.vue +0 -1
- package/components/u-count-down/u-count-down.vue +0 -1
- package/components/u-count-to/u-count-to.vue +0 -2
- package/components/u-datetime-picker/u-datetime-picker.vue +0 -1
- package/components/u-divider/u-divider.vue +0 -1
- package/components/u-dropdown/u-dropdown.vue +0 -1
- package/components/u-dropdown-item/u-dropdown-item.vue +0 -1
- package/components/u-empty/u-empty.vue +0 -1
- package/components/u-float-button/u-float-button.vue +0 -2
- package/components/u-form-item/u-form-item.vue +0 -1
- package/components/u-gap/u-gap.vue +0 -1
- package/components/u-grid/u-grid.vue +0 -1
- package/components/u-grid-item/u-grid-item.vue +0 -1
- package/components/u-icon/u-icon.vue +0 -1
- package/components/u-image/u-image.vue +0 -2
- package/components/u-index-anchor/u-index-anchor.vue +0 -1
- package/components/u-index-item/u-index-item.vue +0 -1
- package/components/u-index-list/u-index-list.vue +0 -1
- package/components/u-input/u-input.vue +0 -2
- package/components/u-keyboard/u-keyboard.vue +0 -1
- package/components/u-lazy-load/u-lazy-load.vue +0 -2
- package/components/u-line/u-line.vue +0 -1
- package/components/u-line-progress/u-line-progress.vue +0 -1
- package/components/u-link/u-link.vue +0 -1
- package/components/u-list/u-list.vue +0 -1
- package/components/u-list-item/u-list-item.vue +0 -1
- package/components/u-loading-icon/u-loading-icon.vue +0 -1
- package/components/u-loading-page/u-loading-page.vue +0 -2
- package/components/u-loadmore/u-loadmore.vue +0 -1
- package/components/u-modal/u-modal.vue +0 -1
- package/components/u-navbar/u-navbar.vue +0 -1
- package/components/u-navbar-mini/u-navbar-mini.vue +0 -1
- package/components/u-no-network/u-no-network.vue +0 -1
- package/components/u-notice-bar/u-notice-bar.vue +0 -1
- package/components/u-notify/u-notify.vue +0 -1
- package/components/u-number-box/u-number-box.vue +0 -2
- package/components/u-number-keyboard/u-number-keyboard.vue +0 -1
- package/components/u-overlay/u-overlay.vue +0 -1
- package/components/u-picker/u-picker.vue +0 -1
- package/components/u-picker-column/u-picker-column.vue +0 -1
- package/components/u-popup/u-popup.vue +0 -1
- package/components/u-qrcode/qrcode.js +24 -10
- package/components/u-qrcode/u-qrcode.vue +412 -281
- package/components/u-radio/u-radio.vue +0 -1
- package/components/u-radio-group/u-radio-group.vue +0 -1
- package/components/u-rate/u-rate.vue +0 -1
- package/components/u-read-more/u-read-more.vue +0 -2
- package/components/u-row/u-row.vue +0 -1
- package/components/u-row-notice/u-row-notice.vue +0 -1
- package/components/u-scroll-list/u-scroll-list.vue +0 -2
- package/components/u-search/u-search.vue +0 -1
- package/components/u-skeleton/u-skeleton.vue +0 -1
- package/components/u-slider/u-slider.vue +0 -1
- package/components/u-steps/u-steps.vue +0 -1
- package/components/u-steps-item/u-steps-item.vue +0 -1
- package/components/u-subsection/u-subsection.vue +0 -2
- package/components/u-swipe-action-item/u-swipe-action-item.vue +0 -1
- package/components/u-swiper/u-swiper.vue +0 -1
- package/components/u-swiper-indicator/u-swiper-indicator.vue +0 -1
- package/components/u-switch/u-switch.vue +0 -1
- package/components/u-tabbar/u-tabbar.vue +0 -1
- package/components/u-tabbar-item/u-tabbar-item.vue +0 -1
- package/components/u-table/u-table.vue +0 -1
- package/components/u-tabs/u-tabs.vue +0 -1
- package/components/u-tag/u-tag.vue +0 -1
- package/components/u-td/u-td.vue +0 -1
- package/components/u-text/u-text.vue +4 -6
- package/components/u-textarea/u-textarea.vue +9 -11
- package/components/u-th/u-th.vue +0 -1
- package/components/u-toast/u-toast.vue +2 -2
- package/components/u-toolbar/u-toolbar.vue +0 -1
- package/components/u-tooltip/u-tooltip.vue +0 -1
- package/components/u-tr/u-tr.vue +0 -1
- package/components/u-transition/u-transition.vue +114 -3
- package/components/u-upload/u-upload.vue +0 -1
- package/components/u-view/u-view.vue +0 -2
- package/components/u-waterfall/u-waterfall.vue +0 -2
- package/index.scss +2 -1
- package/libs/util/gcanvas/bridge/bridge-weex.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStylePattern.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/ActiveInfo.js +0 -0
- package/libs/util/gcanvas/context-webgl/Buffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/Framebuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLenum.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLmethod.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLtype.js +0 -0
- package/libs/util/gcanvas/context-webgl/Program.js +0 -0
- package/libs/util/gcanvas/context-webgl/Renderbuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/Shader.js +0 -0
- package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +0 -0
- package/libs/util/gcanvas/context-webgl/Texture.js +0 -0
- package/libs/util/gcanvas/context-webgl/UniformLocation.js +0 -0
- package/libs/util/gcanvas/context-webgl/classUtils.js +0 -0
- package/libs/util/gcanvas/env/canvas.js +0 -0
- package/libs/util/gcanvas/env/image.js +0 -0
- package/libs/util/gcanvas/env/tool.js +0 -0
- package/libs/util/gcanvas/index.js +0 -0
- package/package.json +1 -1
- package/types/comps/qrcode.d.ts +77 -0
- package/types/comps.d.ts +1 -0
|
@@ -1,26 +1,50 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<view class="u-qrcode"
|
|
3
|
+
:id="rootId"
|
|
4
|
+
:style="{
|
|
5
|
+
width: useRootHeightAndWidth ? '100%' : 'auto',
|
|
6
|
+
height: useRootHeightAndWidth ? '100%' : 'auto',
|
|
7
|
+
}"
|
|
8
|
+
@longpress="longpress">
|
|
9
|
+
<view class="u-qrcode__content" @click="preview">
|
|
10
|
+
|
|
11
|
+
<!-- #ifndef APP-NVUE || APP-PLUS -->
|
|
12
|
+
<canvas
|
|
6
13
|
class="u-qrcode__canvas"
|
|
7
|
-
|
|
14
|
+
:id="cid"
|
|
8
15
|
:canvas-id="cid"
|
|
9
16
|
type="2d"
|
|
10
|
-
:style="{ width:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
:style="{ width: sizeLocal + unit, height: sizeLocal + unit }" />
|
|
18
|
+
<!-- #endif -->
|
|
19
|
+
|
|
20
|
+
<!-- #ifdef APP-PLUS -->
|
|
21
|
+
<canvas
|
|
22
|
+
class="u-qrcode__canvas"
|
|
23
|
+
:id="cid"
|
|
24
|
+
:canvas-id="cid"
|
|
25
|
+
:style="{ width: sizeLocal + unit, height: sizeLocal + unit }" />
|
|
26
|
+
<!-- #endif -->
|
|
27
|
+
|
|
28
|
+
<!-- #ifdef APP-PLUS -->
|
|
29
|
+
<canvas
|
|
30
|
+
class="u-qrcode__canvas"
|
|
31
|
+
:id="cid"
|
|
32
|
+
:canvas-id="cid"
|
|
33
|
+
:style="{ width: sizeLocal + unit, height: sizeLocal + unit }" />
|
|
34
|
+
<!-- #endif -->
|
|
35
|
+
|
|
36
|
+
<!-- #ifdef APP-NVUE -->
|
|
37
|
+
<gcanvas class="u-qrcode__canvas" ref="gcanvess"
|
|
38
|
+
:style="{ width: sizeLocal + unit, height: sizeLocal + unit }">
|
|
39
|
+
</gcanvas>
|
|
40
|
+
<!-- #endif -->
|
|
41
|
+
<view v-if="showLoading && loading" class="u-qrcode__loading"
|
|
42
|
+
:style="{ width: sizeLocal + unit, height: sizeLocal + unit }">
|
|
43
|
+
<up-loading-icon vertical :text="loadingText" textSize="14px"></up-loading-icon>
|
|
44
|
+
</view>
|
|
45
|
+
</view>
|
|
22
46
|
|
|
23
|
-
|
|
47
|
+
</view>
|
|
24
48
|
</template>
|
|
25
49
|
|
|
26
50
|
<script>
|
|
@@ -28,272 +52,379 @@ import QRCode from "./qrcode.js"
|
|
|
28
52
|
// #ifdef APP-NVUE
|
|
29
53
|
// https://github.com/dcloudio/NvueCanvasDemo/blob/master/README.md
|
|
30
54
|
import {
|
|
31
|
-
|
|
32
|
-
|
|
55
|
+
enable,
|
|
56
|
+
WeexBridge
|
|
33
57
|
} from '../../libs/util/gcanvas/index.js';
|
|
34
58
|
// #endif
|
|
35
59
|
let qrcode
|
|
36
60
|
export default {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
61
|
+
name: "u-qrcode",
|
|
62
|
+
props: {
|
|
63
|
+
cid: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: () => `u-qrcode-canvas${Math.floor(Math.random() * 1000000)}`
|
|
66
|
+
},
|
|
67
|
+
size: {
|
|
68
|
+
type: Number,
|
|
69
|
+
default: 200
|
|
70
|
+
},
|
|
71
|
+
unit: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: 'px'
|
|
74
|
+
},
|
|
75
|
+
show: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: true
|
|
78
|
+
},
|
|
79
|
+
val: {
|
|
80
|
+
type: String,
|
|
81
|
+
default: ''
|
|
82
|
+
},
|
|
83
|
+
background: {
|
|
84
|
+
type: String,
|
|
85
|
+
default: '#ffffff'
|
|
86
|
+
},
|
|
87
|
+
foreground: {
|
|
88
|
+
type: String,
|
|
89
|
+
default: '#000000'
|
|
90
|
+
},
|
|
91
|
+
pdground: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: '#000000'
|
|
94
|
+
},
|
|
95
|
+
icon: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: ''
|
|
98
|
+
},
|
|
99
|
+
iconSize: {
|
|
100
|
+
type: Number,
|
|
101
|
+
default: 40
|
|
102
|
+
},
|
|
103
|
+
lv: {
|
|
104
|
+
type: Number,
|
|
105
|
+
default: 3
|
|
106
|
+
},
|
|
107
|
+
onval: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
default: true
|
|
110
|
+
},
|
|
111
|
+
loadMake: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
default: true
|
|
114
|
+
},
|
|
115
|
+
usingComponents: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
default: true
|
|
118
|
+
},
|
|
119
|
+
showLoading: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: true
|
|
122
|
+
},
|
|
123
|
+
loadingText: {
|
|
124
|
+
type: String,
|
|
125
|
+
default: '生成中'
|
|
126
|
+
},
|
|
127
|
+
allowPreview: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: false
|
|
130
|
+
},
|
|
131
|
+
// 是否使用根节点宽高
|
|
132
|
+
useRootHeightAndWidth: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
default: () => false
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
emits: ['result', 'longpressCallback'],
|
|
138
|
+
data() {
|
|
139
|
+
return {
|
|
140
|
+
loading: false,
|
|
141
|
+
result: '',
|
|
142
|
+
popupShow: false,
|
|
143
|
+
list: [
|
|
144
|
+
{
|
|
145
|
+
name: '保存二维码',
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
rootId: `rootId${Number(Math.random() * 100).toFixed(0)}`,
|
|
149
|
+
ganvas: null,
|
|
150
|
+
context: '',
|
|
151
|
+
canvasObj: {},
|
|
152
|
+
sizeLocal: this.size,
|
|
153
|
+
ctx: null, // ctx 在new Qrcode 时js文件内部设置
|
|
154
|
+
canvas: null, // ctx 在new Qrcode 时js文件内部设置
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
async mounted(){
|
|
158
|
+
// 如果使用根节点的宽高 则 重新设置 size
|
|
159
|
+
if(this.useRootHeightAndWidth){
|
|
160
|
+
await this.setNewSize()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// #ifdef APP-NVUE
|
|
164
|
+
/*获取元素引用*/
|
|
165
|
+
this.ganvas = this.$refs["gcanvess"]
|
|
166
|
+
/*通过元素引用获取canvas对象*/
|
|
167
|
+
this.canvasObj = enable(this.ganvas, {
|
|
168
|
+
bridge: WeexBridge
|
|
169
|
+
})
|
|
170
|
+
/*获取绘图所需的上下文,目前不支持3d*/
|
|
171
|
+
this.context = this.canvasObj.getContext('2d')
|
|
172
|
+
// #endif
|
|
135
173
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
174
|
+
if (this.loadMake) {
|
|
175
|
+
if (!this._empty(this.val)) {
|
|
176
|
+
setTimeout(() => {
|
|
139
177
|
setTimeout(()=>{
|
|
140
178
|
this._makeCode()
|
|
141
179
|
})
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
180
|
+
}, 0);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
methods: {
|
|
185
|
+
_makeCode() {
|
|
186
|
+
let that = this
|
|
187
|
+
if (!this._empty(this.val)) {
|
|
188
|
+
// #ifndef APP-NVUE
|
|
189
|
+
this.loading = true
|
|
190
|
+
// #endif
|
|
191
|
+
qrcode = new QRCode({
|
|
192
|
+
context: that, // 上下文环境
|
|
193
|
+
canvasId: that.cid, // canvas-id
|
|
194
|
+
nvueContext: that.context,
|
|
195
|
+
usingComponents: that.usingComponents, // 是否是自定义组件
|
|
196
|
+
showLoading: false, // 是否显示loading
|
|
197
|
+
loadingText: that.loadingText, // loading文字
|
|
198
|
+
text: that.val, // 生成内容
|
|
199
|
+
size: that.sizeLocal, // 二维码大小
|
|
200
|
+
background: that.background, // 背景色
|
|
201
|
+
foreground: that.foreground, // 前景色
|
|
202
|
+
pdground: that.pdground, // 定位角点颜色
|
|
203
|
+
correctLevel: that.lv, // 容错级别
|
|
204
|
+
image: that.icon, // 二维码图标
|
|
205
|
+
imageSize: that.iconSize,// 二维码图标大小
|
|
206
|
+
cbResult: function (res) { // 生成二维码的回调
|
|
207
|
+
that._result(res)
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
} else {
|
|
211
|
+
uni.showToast({
|
|
212
|
+
title: '二维码内容不能为空',
|
|
213
|
+
icon: 'none',
|
|
214
|
+
duration: 2000
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
_clearCode() {
|
|
219
|
+
this._result('')
|
|
220
|
+
qrcode.clear()
|
|
221
|
+
},
|
|
222
|
+
_saveCode() {
|
|
223
|
+
let that = this;
|
|
224
|
+
if (this.result != "") {
|
|
225
|
+
uni.saveImageToPhotosAlbum({
|
|
226
|
+
filePath: that.result,
|
|
227
|
+
success: function () {
|
|
228
|
+
uni.showToast({
|
|
229
|
+
title: '二维码保存成功',
|
|
230
|
+
icon: 'success',
|
|
231
|
+
duration: 2000
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
preview(e) {
|
|
238
|
+
// 预览图片
|
|
239
|
+
// console.log(this.result)
|
|
240
|
+
if (this.allowPreview) {
|
|
241
|
+
uni.previewImage({
|
|
242
|
+
urls: [this.result],
|
|
243
|
+
longPressActions: {
|
|
244
|
+
itemList: ['保存二维码图片'],
|
|
245
|
+
success: function(data) {
|
|
246
|
+
// console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
|
|
247
|
+
switch (data.tapIndex) {
|
|
248
|
+
case 0:
|
|
249
|
+
that._saveCode();
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
fail: function(err) {
|
|
254
|
+
console.log(err.errMsg);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
this.$emit('preview', {
|
|
260
|
+
url: this.result
|
|
261
|
+
}, e)
|
|
262
|
+
},
|
|
263
|
+
async longpress() {
|
|
264
|
+
if (this.context) {
|
|
265
|
+
this.ctx.toTempFilePath(
|
|
266
|
+
0,
|
|
267
|
+
0,
|
|
268
|
+
this.sizeLocal,
|
|
269
|
+
this.sizeLocal,
|
|
270
|
+
this.sizeLocal,
|
|
271
|
+
this.sizeLocal,
|
|
272
|
+
"",
|
|
273
|
+
1,
|
|
274
|
+
res => {
|
|
275
|
+
this.$emit('longpressCallback', res.tempFilePath)
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
|
|
281
|
+
// #ifdef MP-TOUTIAO || H5
|
|
282
|
+
this.$emit('longpressCallback', this.ctx.canvas.toDataURL("image/png", 1));
|
|
283
|
+
// #endif
|
|
284
|
+
|
|
285
|
+
// #ifdef APP-PLUS
|
|
286
|
+
uni.canvasToTempFilePath(
|
|
287
|
+
{
|
|
288
|
+
canvasId: this.cid,
|
|
289
|
+
success :res => {
|
|
290
|
+
this.$emit('longpressCallback', res.tempFilePath)
|
|
291
|
+
},
|
|
292
|
+
fail: err =>{
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
this)
|
|
296
|
+
// #endif
|
|
297
|
+
|
|
298
|
+
// #ifndef MP-TOUTIAO || H5 || APP-PLUS
|
|
299
|
+
const canvas = await this.getNode(this.cId,true);
|
|
300
|
+
uni.canvasToTempFilePath(
|
|
301
|
+
{
|
|
302
|
+
canvas,
|
|
303
|
+
success :res => {
|
|
304
|
+
this.$emit('longpressCallback', res.tempFilePath)
|
|
305
|
+
},
|
|
306
|
+
fail: err =>{
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
this)
|
|
310
|
+
// #endif
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* 使用根节点宽高 设置新的size
|
|
318
|
+
* @return {Promise<void>}
|
|
319
|
+
*/
|
|
320
|
+
async setNewSize(){
|
|
321
|
+
const rootNode = await this.getNode(this.rootId,false);
|
|
322
|
+
const { width , height } = rootNode;
|
|
323
|
+
// 将最短的设置为二维码 的size
|
|
324
|
+
if(width > height){
|
|
325
|
+
this.sizeLocal = height
|
|
326
|
+
}
|
|
327
|
+
else{
|
|
328
|
+
this.sizeLocal = width
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* 获取节点
|
|
334
|
+
* @param id 节点id
|
|
335
|
+
* @param isCanvas 是否为Canvas节点
|
|
336
|
+
* @return {Promise<unknown>}
|
|
337
|
+
*/
|
|
338
|
+
async getNode(id,isCanvas){
|
|
339
|
+
return new Promise((resolve, reject)=>{
|
|
340
|
+
try {
|
|
341
|
+
const query = uni.createSelectorQuery().in(this);
|
|
342
|
+
query.select(`#${id}`)
|
|
343
|
+
.fields({ node: true, size: true })
|
|
344
|
+
.exec((res) => {
|
|
345
|
+
if(isCanvas){
|
|
346
|
+
resolve(res[0].node)
|
|
347
|
+
}
|
|
348
|
+
else{
|
|
349
|
+
resolve(res[0])
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
})
|
|
353
|
+
}
|
|
354
|
+
catch (e) {
|
|
355
|
+
console.error("获取节点失败",e)
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
selectClick(index) {
|
|
361
|
+
switch (index) {
|
|
362
|
+
case 0:
|
|
363
|
+
alert('保存二维码')
|
|
364
|
+
this._saveCode();
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
_result(res) {
|
|
369
|
+
this.loading = false;
|
|
370
|
+
this.result = res;
|
|
371
|
+
this.$emit('result', res);
|
|
372
|
+
},
|
|
373
|
+
_empty(v) {
|
|
374
|
+
let tp = typeof v,
|
|
375
|
+
rt = false;
|
|
376
|
+
if (tp == "number" && String(v) == "") {
|
|
377
|
+
rt = true
|
|
378
|
+
} else if (tp == "undefined") {
|
|
379
|
+
rt = true
|
|
380
|
+
} else if (tp == "object") {
|
|
381
|
+
if (JSON.stringify(v) == "{}" || JSON.stringify(v) == "[]" || v == null) rt = true
|
|
382
|
+
} else if (tp == "string") {
|
|
383
|
+
if (v == "" || v == "undefined" || v == "null" || v == "{}" || v == "[]") rt = true
|
|
384
|
+
} else if (tp == "function") {
|
|
385
|
+
rt = false
|
|
386
|
+
}
|
|
387
|
+
return rt
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
watch: {
|
|
391
|
+
size: function (n, o) {
|
|
392
|
+
if (n != o && !this._empty(n)) {
|
|
393
|
+
this.cSize = n
|
|
394
|
+
if (!this._empty(this.val)) {
|
|
395
|
+
setTimeout(() => {
|
|
396
|
+
this._makeCode()
|
|
397
|
+
}, 100);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
val: function (n, o) {
|
|
402
|
+
if (this.onval) {
|
|
403
|
+
if (n != o && !this._empty(n)) {
|
|
404
|
+
setTimeout(() => {
|
|
405
|
+
this._makeCode()
|
|
406
|
+
}, 0);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
computed: {
|
|
412
|
+
}
|
|
282
413
|
}
|
|
283
414
|
</script>
|
|
284
415
|
<style lang="scss" scoped>
|
|
285
416
|
.u-qrcode {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
417
|
+
&__loading {
|
|
418
|
+
display: flex;
|
|
419
|
+
justify-content: center;
|
|
420
|
+
align-items: center;
|
|
421
|
+
background-color: #f7f7f7;
|
|
422
|
+
position: absolute;
|
|
423
|
+
top: 0;
|
|
424
|
+
bottom: 0;
|
|
425
|
+
left: 0;
|
|
426
|
+
right: 0;
|
|
427
|
+
}
|
|
297
428
|
|
|
298
429
|
/* #ifdef MP-TOUTIAO */
|
|
299
430
|
/**字节小程序在编译时会出现一个 [hidde]:{ display: none !important; } 这个样式
|
|
@@ -304,15 +435,15 @@ export default {
|
|
|
304
435
|
}
|
|
305
436
|
/* #endif */
|
|
306
437
|
|
|
307
|
-
|
|
308
|
-
|
|
438
|
+
&__content {
|
|
439
|
+
position: relative;
|
|
309
440
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
441
|
+
&__canvas {
|
|
442
|
+
position: fixed;
|
|
443
|
+
top: -99999rpx;
|
|
444
|
+
left: -99999rpx;
|
|
445
|
+
z-index: -99999;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
317
448
|
}
|
|
318
449
|
</style>
|