@10yun/cv-mobile-ui 0.5.30 → 0.5.32
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/package.json +5 -1
- package/ui-cv/components/cv-btn-base/cv-btn-base.vue +1 -1
- package/uview-plus/README.md +1 -1
- package/uview-plus/components/u-action-sheet/u-action-sheet.vue +8 -8
- package/uview-plus/components/u-album/u-album.vue +1 -1
- package/uview-plus/components/u-alert/u-alert.vue +5 -5
- package/uview-plus/components/u-app-update/u-app-update.vue +2 -2
- package/uview-plus/components/u-avatar/u-avatar.vue +2 -2
- package/uview-plus/components/u-avatar-group/u-avatar-group.vue +79 -3
- package/uview-plus/components/u-back-top/u-back-top.vue +4 -4
- package/uview-plus/components/u-badge/u-badge.vue +1 -1
- package/uview-plus/components/u-button/u-button.vue +8 -8
- package/uview-plus/components/u-button-wu/u-button-wu.vue +9 -9
- package/uview-plus/components/u-calendar/u-calendar.vue +5 -6
- package/uview-plus/components/u-car-keyboard/u-car-keyboard.vue +2 -2
- package/uview-plus/components/u-card/u-card.vue +139 -3
- package/uview-plus/components/u-cell/u-cell.vue +4 -4
- package/uview-plus/components/u-cell-group/u-cell-group.vue +2 -2
- package/uview-plus/components/u-checkbox/u-checkbox.vue +4 -4
- package/uview-plus/components/u-checkbox-group/u-checkbox-group.vue +1 -1
- package/uview-plus/components/u-code/u-code.vue +1 -1
- package/uview-plus/components/u-code-input/u-code-input.vue +1 -1
- package/uview-plus/components/u-col/u-col.vue +1 -1
- package/uview-plus/components/u-collapse/u-collapse.vue +2 -2
- package/uview-plus/components/u-collapse-item/u-collapse-item.vue +218 -3
- package/uview-plus/components/u-column-notice/u-column-notice.vue +3 -3
- package/uview-plus/components/u-copy/u-copy.vue +68 -1
- package/uview-plus/components/u-count-down/u-count-down.vue +1 -1
- package/uview-plus/components/u-count-to/u-count-to.vue +1 -1
- package/uview-plus/components/u-datetime-picker/u-datetime-picker.vue +3 -3
- package/uview-plus/components/u-divider/u-divider.vue +3 -3
- package/uview-plus/components/u-dropdown/u-dropdown.vue +3 -3
- package/uview-plus/components/u-dropdown-item/u-dropdown-item.vue +1 -1
- package/uview-plus/components/u-empty/u-empty.vue +3 -3
- package/uview-plus/components/u-form/u-form.vue +243 -1
- package/uview-plus/components/u-form-item/u-form-item.vue +4 -4
- package/uview-plus/components/u-gap/u-gap.vue +1 -1
- package/uview-plus/components/u-grid/u-grid.vue +1 -1
- package/uview-plus/components/u-grid-item/u-grid-item.vue +1 -1
- package/uview-plus/components/u-icon/u-icon.vue +1 -1
- package/uview-plus/components/u-icon/u-icon2.vue +1 -1
- package/uview-plus/components/u-image/u-image.vue +5 -5
- package/uview-plus/components/u-image-wu/u-image-wu.vue +5 -5
- package/uview-plus/components/u-index-anchor/u-index-anchor.vue +1 -1
- package/uview-plus/components/u-index-list/u-index-list.vue +2 -2
- package/uview-plus/components/u-input/u-input.vue +4 -4
- package/uview-plus/components/u-keyboard/u-keyboard.vue +6 -6
- package/uview-plus/components/u-lazy-load/u-lazy-load.vue +257 -3
- package/uview-plus/components/u-line/u-line.vue +1 -1
- package/uview-plus/components/u-line-progress/u-line-progress.vue +1 -1
- package/uview-plus/components/u-link/u-link.vue +1 -1
- package/uview-plus/components/u-list/u-list.vue +1 -1
- package/uview-plus/components/u-list-item/u-list-item.vue +1 -1
- package/uview-plus/components/u-loading-icon/u-loading-icon.vue +191 -3
- package/uview-plus/components/u-loading-page/u-loading-page.vue +4 -4
- package/uview-plus/components/u-loadmore/u-loadmore.vue +4 -4
- package/uview-plus/components/u-mask/u-mask.vue +120 -113
- package/uview-plus/components/u-message-input/u-message-input.vue +1 -1
- package/uview-plus/components/u-modal/u-modal.vue +6 -6
- package/uview-plus/components/u-navbar/u-navbar.vue +4 -4
- package/uview-plus/components/u-navbar-mini/u-navbar-mini.vue +2 -2
- package/uview-plus/components/u-navbar-wu/u-navbar-wu.vue +4 -4
- package/uview-plus/components/u-no-network/u-no-network.vue +5 -5
- package/uview-plus/components/u-notice-bar/u-notice-bar.vue +5 -5
- package/uview-plus/components/u-notify/u-notify.vue +6 -6
- package/uview-plus/components/u-number-box/u-number-box.vue +9 -3
- package/uview-plus/components/u-number-keyboard/u-number-keyboard.vue +1 -1
- package/uview-plus/components/u-overlay/u-overlay.vue +3 -3
- package/uview-plus/components/u-picker/u-picker.vue +5 -5
- package/uview-plus/components/u-popup/u-popup.vue +8 -8
- package/uview-plus/components/u-popup-wu/u-popup-wu.vue +7 -7
- package/uview-plus/components/u-qrcode/u-qrcode.vue +275 -3
- package/uview-plus/components/u-radio/u-radio.vue +4 -4
- package/uview-plus/components/u-radio-group/u-radio-group.vue +1 -1
- package/uview-plus/components/u-rate/u-rate.vue +5 -5
- package/uview-plus/components/u-read-more/u-read-more.vue +126 -3
- package/uview-plus/components/u-row/u-row.vue +1 -1
- package/uview-plus/components/u-row-notice/u-row-notice.vue +3 -3
- package/uview-plus/components/u-safe-bottom/u-safe-bottom.vue +48 -3
- package/uview-plus/components/u-search/u-search.vue +4 -4
- package/uview-plus/components/u-select/u-select.vue +175 -3
- package/uview-plus/components/u-skeleton/u-skeleton.vue +3 -3
- package/uview-plus/components/u-sku-wu/u-sku-wu.vue +4 -4
- package/uview-plus/components/u-status-bar/u-status-bar.vue +1 -1
- package/uview-plus/components/u-steps/u-steps.vue +1 -1
- package/uview-plus/components/u-steps-item/u-steps-item.vue +7 -7
- package/uview-plus/components/u-sticky/u-sticky.vue +1 -1
- package/uview-plus/components/u-subsection/u-subsection.vue +1 -1
- package/uview-plus/components/u-swipe-action/u-swipe-action.vue +1 -1
- package/uview-plus/components/u-swipe-action-item/u-swipe-action-item.vue +3 -3
- package/uview-plus/components/u-swiper/u-swiper.vue +1 -1
- package/uview-plus/components/u-swiper-indicator/u-swiper-indicator.vue +1 -1
- package/uview-plus/components/u-switch/u-switch.vue +2 -2
- package/uview-plus/components/u-tabbar/u-tabbar.vue +2 -2
- package/uview-plus/components/u-tabbar-item/u-tabbar-item.vue +9 -4
- package/uview-plus/components/u-table/u-table.vue +1 -1
- package/uview-plus/components/u-tabs/u-tabs.vue +3 -3
- package/uview-plus/components/u-tag/u-tag.vue +5 -5
- package/uview-plus/components/u-text/u-text.vue +159 -3
- package/uview-plus/components/u-toast/u-toast.vue +8 -8
- package/uview-plus/components/u-tooltip/u-tooltip.vue +6 -6
- package/uview-plus/components/u-upload/u-upload.vue +10 -10
- package/uview-plus/components/u-waterfall/u-waterfall.vue +221 -3
- package/uview-plus/index.js +4 -2
- package/uview-plus/libs/ctocode/image.js +17 -0
- package/uview-plus/libs/ctocode/index.js +150 -0
- package/uview-plus/libs/ctocode/map.js +38 -0
- package/uview-plus/libs/function/index-wu.js +6 -34
- package/uview-plus/package.json +3 -3
- package/uview-plus/readme-wu.md +1 -1
- package/uview-plus/libs/function/cc.js +0 -66
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<slot name="trigger"></slot>
|
|
5
5
|
<view @click="open" class="u-popup__trigger__cover"></view>
|
|
6
6
|
</view>
|
|
7
|
-
<
|
|
7
|
+
<up-overlay
|
|
8
8
|
:show="show"
|
|
9
9
|
@click="overlayClick"
|
|
10
10
|
v-if="overlay"
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
:duration="overlayDuration"
|
|
13
13
|
:customStyle="overlayStyle"
|
|
14
14
|
:opacity="overlayOpacity"
|
|
15
|
-
></
|
|
16
|
-
<
|
|
15
|
+
></up-overlay>
|
|
16
|
+
<up-transition
|
|
17
17
|
:show="show"
|
|
18
18
|
:customStyle="transitionStyle"
|
|
19
19
|
:mode="position"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
>
|
|
24
24
|
<!-- @click.stop不能去除,去除会导致居中模式下点击内容区域触发关闭弹窗 -->
|
|
25
25
|
<view class="u-popup__content" :style="[contentStyle]" @click.stop="noop" @touchmove.stop.prevent="noop">
|
|
26
|
-
<
|
|
26
|
+
<up-status-bar v-if="safeAreaInsetTop"></up-status-bar>
|
|
27
27
|
<slot></slot>
|
|
28
28
|
<view
|
|
29
29
|
v-if="closeable"
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
hover-class="u-popup__content__close--hover"
|
|
34
34
|
hover-stay-time="150"
|
|
35
35
|
>
|
|
36
|
-
<
|
|
36
|
+
<up-icon name="close" color="#909399" size="18" bold></up-icon>
|
|
37
37
|
</view>
|
|
38
|
-
<
|
|
38
|
+
<up-safe-bottom v-if="safeAreaInsetBottom"></up-safe-bottom>
|
|
39
39
|
</view>
|
|
40
|
-
</
|
|
40
|
+
</up-transition>
|
|
41
41
|
</view>
|
|
42
42
|
</template>
|
|
43
43
|
<script>
|
|
@@ -67,7 +67,7 @@ import { addUnit, addStyle, deepMerge, sleep, getWindowInfo } from '../../libs/f
|
|
|
67
67
|
* @property {Object} customStyle 组件的样式,对象形式
|
|
68
68
|
* @event {Function} open 弹出层打开
|
|
69
69
|
* @event {Function} close 弹出层收起
|
|
70
|
-
* @example <
|
|
70
|
+
* @example <up-popup v-model:show="show"><text>出淤泥而不染,濯清涟而不妖</text></up-popup>
|
|
71
71
|
*/
|
|
72
72
|
export default {
|
|
73
73
|
name: 'u-popup',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<view v-if="showPopup" class="u-popup" :class="[popupClass, isDesktop ? 'fixforpc-z-index' : '']" :style="[{ zIndex: zIndex }]">
|
|
3
3
|
<view @touchstart="touchstart">
|
|
4
4
|
<!-- 遮罩层 -->
|
|
5
|
-
<
|
|
5
|
+
<up-overlay
|
|
6
6
|
key="1"
|
|
7
7
|
v-if="maskShow && overlay"
|
|
8
8
|
:show="showTrans"
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
:opacity="overlayOpacity"
|
|
12
12
|
:zIndex="zIndex"
|
|
13
13
|
@click="onTap"
|
|
14
|
-
></
|
|
15
|
-
<
|
|
14
|
+
></up-overlay>
|
|
15
|
+
<up-transition
|
|
16
16
|
key="2"
|
|
17
17
|
:mode="ani"
|
|
18
18
|
name="content"
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
@click="onTap"
|
|
23
23
|
>
|
|
24
24
|
<view class="u-popup__content" :style="[contentStyle]" :class="[popupClass]" @click="clear">
|
|
25
|
-
<
|
|
25
|
+
<up-status-bar v-if="safeAreaInsetTop"></up-status-bar>
|
|
26
26
|
<slot />
|
|
27
|
-
<
|
|
27
|
+
<up-safe-bottom v-if="safeAreaInsetBottom"></up-safe-bottom>
|
|
28
28
|
<view
|
|
29
29
|
v-if="closeable"
|
|
30
30
|
@tap.stop="close"
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
hover-class="u-popup__content__close--hover"
|
|
34
34
|
hover-stay-time="150"
|
|
35
35
|
>
|
|
36
|
-
<
|
|
36
|
+
<up-icon name="close" color="#909399" size="18" bold></up-icon>
|
|
37
37
|
</view>
|
|
38
38
|
</view>
|
|
39
|
-
</
|
|
39
|
+
</up-transition>
|
|
40
40
|
</view>
|
|
41
41
|
<!-- #ifdef H5 -->
|
|
42
42
|
<keypress v-if="maskShow" @esc="onTap" />
|
|
@@ -1,3 +1,275 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view class="u-qrcode" @longpress="longpress">
|
|
3
2
|
<view class="u-qrcode__content" @click="preview">
|
|
4
3
|
<!-- #ifndef APP-NVUE -->
|
|
5
4
|
<canvas class="u-qrcode__canvas" :id="cid" :canvas-id="cid" :style="{ width: size + unit, height: size + unit }" />
|
|
6
5
|
<!-- #endif -->
|
|
7
6
|
<!-- #ifdef APP-NVUE -->
|
|
8
7
|
<gcanvas class="u-qrcode__canvas" ref="gcanvess" :style="{ width: size + unit, height: size + unit }"></gcanvas>
|
|
9
8
|
<!-- #endif -->
|
|
10
9
|
<view v-if="showLoading && loading" class="u-qrcode__loading" :style="{ width: size + unit, height: size + unit }">
|
|
11
10
|
<up-loading-icon vertical :text="loadingText" textSize="14px"></up-loading-icon>
|
|
12
11
|
</view>
|
|
13
12
|
<!-- <image v-show="show" :src="result" :style="{ width: size + unit, height: size + unit }" /> -->
|
|
14
13
|
</view>
|
|
15
14
|
<!-- <up-action-sheet :actions="list" cancelText="取消"
|
|
16
15
|
</view>
|
|
17
16
|
name: 'u-qrcode',
|
|
18
17
|
props: {
|
|
19
18
|
cid: {
|
|
20
19
|
type: String,
|
|
21
20
|
default: 'u-qrcode-canvas' + Math.random().toString()
|
|
22
21
|
},
|
|
23
22
|
size: {
|
|
24
23
|
type: Number,
|
|
25
24
|
default: 200
|
|
26
25
|
},
|
|
27
26
|
unit: {
|
|
28
27
|
type: String,
|
|
29
28
|
default: 'px'
|
|
30
29
|
},
|
|
31
30
|
show: {
|
|
32
31
|
type: Boolean,
|
|
33
32
|
default: true
|
|
34
33
|
},
|
|
35
34
|
val: {
|
|
36
35
|
type: String,
|
|
37
36
|
default: ''
|
|
38
37
|
},
|
|
39
38
|
background: {
|
|
40
39
|
type: String,
|
|
41
40
|
default: '#ffffff'
|
|
42
41
|
},
|
|
43
42
|
foreground: {
|
|
44
43
|
type: String,
|
|
45
44
|
default: '#000000'
|
|
46
45
|
},
|
|
47
46
|
pdground: {
|
|
48
47
|
type: String,
|
|
49
48
|
default: '#000000'
|
|
50
49
|
},
|
|
51
50
|
icon: {
|
|
52
51
|
type: String,
|
|
53
52
|
default: ''
|
|
54
53
|
},
|
|
55
54
|
iconSize: {
|
|
56
55
|
type: Number,
|
|
57
56
|
default: 40
|
|
58
57
|
},
|
|
59
58
|
lv: {
|
|
60
59
|
type: Number,
|
|
61
60
|
default: 3
|
|
62
61
|
},
|
|
63
62
|
onval: {
|
|
64
63
|
type: Boolean,
|
|
65
64
|
default: true
|
|
66
65
|
},
|
|
67
66
|
loadMake: {
|
|
68
67
|
type: Boolean,
|
|
69
68
|
default: true
|
|
70
69
|
},
|
|
71
70
|
usingComponents: {
|
|
72
71
|
type: Boolean,
|
|
73
72
|
default: true
|
|
74
73
|
},
|
|
75
74
|
showLoading: {
|
|
76
75
|
type: Boolean,
|
|
77
76
|
default: true
|
|
78
77
|
},
|
|
79
78
|
loadingText: {
|
|
80
79
|
type: String,
|
|
81
80
|
default: '生成中'
|
|
82
81
|
},
|
|
83
82
|
allowPreview: {
|
|
84
83
|
type: Boolean,
|
|
85
84
|
default: false
|
|
86
85
|
}
|
|
87
86
|
},
|
|
88
87
|
emits: ['result', 'longpress'],
|
|
89
88
|
data() {
|
|
90
89
|
return {
|
|
91
90
|
loading: false,
|
|
92
91
|
result: '',
|
|
93
92
|
popupShow: false,
|
|
94
93
|
list: [
|
|
95
94
|
{
|
|
96
95
|
name: '保存二维码'
|
|
97
96
|
}
|
|
98
97
|
],
|
|
99
98
|
ganvas: null,
|
|
100
99
|
context: '',
|
|
101
100
|
canvasObj: {}
|
|
102
101
|
};
|
|
103
102
|
},
|
|
104
103
|
mounted: function () {
|
|
105
104
|
// #ifdef APP-NVUE
|
|
106
105
|
/*获取元素引用*/
|
|
107
106
|
this.ganvas = this.$refs['gcanvess'];
|
|
108
107
|
/*通过元素引用获取canvas对象*/
|
|
109
108
|
this.canvasObj = enable(this.ganvas, {
|
|
110
109
|
bridge: WeexBridge
|
|
111
110
|
});
|
|
112
111
|
/*获取绘图所需的上下文,目前不支持3d*/
|
|
113
112
|
this.context = this.canvasObj.getContext('2d');
|
|
114
113
|
// #endif
|
|
115
114
|
if (this.loadMake) {
|
|
116
115
|
if (!this._empty(this.val)) {
|
|
117
116
|
setTimeout(() => {
|
|
118
117
|
this._makeCode();
|
|
119
118
|
}, 0);
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
},
|
|
123
122
|
methods: {
|
|
124
123
|
_makeCode() {
|
|
125
124
|
let that = this;
|
|
126
125
|
if (!this._empty(this.val)) {
|
|
127
126
|
// #ifndef APP-NVUE
|
|
128
127
|
this.loading = true;
|
|
129
128
|
// #endif
|
|
130
129
|
qrcode = new QRCode({
|
|
131
130
|
context: that, // 上下文环境
|
|
132
131
|
canvasId: that.cid, // canvas-id
|
|
133
132
|
nvueContext: that.context,
|
|
134
133
|
usingComponents: that.usingComponents, // 是否是自定义组件
|
|
135
134
|
showLoading: false, // 是否显示loading
|
|
136
135
|
loadingText: that.loadingText, // loading文字
|
|
137
136
|
text: that.val, // 生成内容
|
|
138
137
|
size: that.size, // 二维码大小
|
|
139
138
|
background: that.background, // 背景色
|
|
140
139
|
foreground: that.foreground, // 前景色
|
|
141
140
|
pdground: that.pdground, // 定位角点颜色
|
|
142
141
|
correctLevel: that.lv, // 容错级别
|
|
143
142
|
image: that.icon, // 二维码图标
|
|
144
143
|
imageSize: that.iconSize, // 二维码图标大小
|
|
145
144
|
cbResult: function (res) {
|
|
146
145
|
// 生成二维码的回调
|
|
147
146
|
that._result(res);
|
|
148
147
|
}
|
|
149
148
|
});
|
|
150
149
|
} else {
|
|
151
150
|
uni.showToast({
|
|
152
151
|
title: '二维码内容不能为空',
|
|
153
152
|
icon: 'none',
|
|
154
153
|
duration: 2000
|
|
155
154
|
});
|
|
156
155
|
}
|
|
157
156
|
},
|
|
158
157
|
_clearCode() {
|
|
159
158
|
this._result('');
|
|
160
159
|
qrcode.clear();
|
|
161
160
|
},
|
|
162
161
|
_saveCode() {
|
|
163
162
|
let that = this;
|
|
164
163
|
if (this.result != '') {
|
|
165
164
|
uni.saveImageToPhotosAlbum({
|
|
166
165
|
filePath: that.result,
|
|
167
166
|
success: function () {
|
|
168
167
|
uni.showToast({
|
|
169
168
|
title: '二维码保存成功',
|
|
170
169
|
icon: 'success',
|
|
171
170
|
duration: 2000
|
|
172
171
|
});
|
|
173
172
|
}
|
|
174
173
|
});
|
|
175
174
|
}
|
|
176
175
|
},
|
|
177
176
|
preview(e) {
|
|
178
177
|
// 预览图片
|
|
179
178
|
// console.log(this.result)
|
|
180
179
|
if (this.allowPreview) {
|
|
181
180
|
uni.previewImage({
|
|
182
181
|
urls: [this.result],
|
|
183
182
|
longPressActions: {
|
|
184
183
|
itemList: ['保存二维码图片'],
|
|
185
184
|
success: function (data) {
|
|
186
185
|
// console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
|
|
187
186
|
switch (data.tapIndex) {
|
|
188
187
|
case 0:
|
|
189
188
|
that._saveCode();
|
|
190
189
|
break;
|
|
191
190
|
}
|
|
192
191
|
},
|
|
193
192
|
fail: function (err) {
|
|
194
193
|
console.log(err.errMsg);
|
|
195
194
|
}
|
|
196
195
|
}
|
|
197
196
|
});
|
|
198
197
|
}
|
|
199
198
|
this.$emit(
|
|
200
199
|
'preview',
|
|
201
200
|
{
|
|
202
201
|
url: this.result
|
|
203
202
|
},
|
|
204
203
|
e
|
|
205
204
|
);
|
|
206
205
|
},
|
|
207
206
|
longpress() {
|
|
208
207
|
this.$emit('longpress', this.result);
|
|
209
208
|
},
|
|
210
209
|
selectClick(index) {
|
|
211
210
|
switch (index) {
|
|
212
211
|
case 0:
|
|
213
212
|
alert('保存二维码');
|
|
214
213
|
this._saveCode();
|
|
215
214
|
break;
|
|
216
215
|
}
|
|
217
216
|
},
|
|
218
217
|
_result(res) {
|
|
219
218
|
this.loading = false;
|
|
220
219
|
this.result = res;
|
|
221
220
|
this.$emit('result', res);
|
|
222
221
|
},
|
|
223
222
|
_empty(v) {
|
|
224
223
|
let tp = typeof v,
|
|
225
224
|
rt = false;
|
|
226
225
|
if (tp == 'number' && String(v) == '') {
|
|
227
226
|
rt = true;
|
|
228
227
|
} else if (tp == 'undefined') {
|
|
229
228
|
rt = true;
|
|
230
229
|
} else if (tp == 'object') {
|
|
231
230
|
if (JSON.stringify(v) == '{}' || JSON.stringify(v) == '[]' || v == null) rt = true;
|
|
232
231
|
} else if (tp == 'string') {
|
|
233
232
|
if (v == '' || v == 'undefined' || v == 'null' || v == '{}' || v == '[]') rt = true;
|
|
234
233
|
} else if (tp == 'function') {
|
|
235
234
|
rt = false;
|
|
236
235
|
}
|
|
237
236
|
return rt;
|
|
238
237
|
}
|
|
239
238
|
},
|
|
240
239
|
watch: {
|
|
241
240
|
size: function (n, o) {
|
|
242
241
|
if (n != o && !this._empty(n)) {
|
|
243
242
|
this.cSize = n;
|
|
244
243
|
if (!this._empty(this.val)) {
|
|
245
244
|
setTimeout(() => {
|
|
246
245
|
this._makeCode();
|
|
247
246
|
}, 100);
|
|
248
247
|
}
|
|
249
248
|
}
|
|
250
249
|
},
|
|
251
250
|
val: function (n, o) {
|
|
252
251
|
if (this.onval) {
|
|
253
252
|
if (n != o && !this._empty(n)) {
|
|
254
253
|
setTimeout(() => {
|
|
255
254
|
this._makeCode();
|
|
256
255
|
}, 0);
|
|
257
256
|
}
|
|
258
257
|
}
|
|
259
258
|
}
|
|
260
259
|
},
|
|
261
260
|
computed: {}
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
<template>
|
|
262
|
+
<view class="u-qrcode" @longpress="longpress">
|
|
263
|
+
<view class="u-qrcode__content" @click="preview">
|
|
264
|
+
<!-- #ifndef APP-NVUE -->
|
|
265
|
+
<canvas class="u-qrcode__canvas" :id="cid" :canvas-id="cid" :style="{ width: size + unit, height: size + unit }" />
|
|
266
|
+
<!-- #endif -->
|
|
267
|
+
<!-- #ifdef APP-NVUE -->
|
|
268
|
+
<gcanvas class="u-qrcode__canvas" ref="gcanvess" :style="{ width: size + unit, height: size + unit }"></gcanvas>
|
|
269
|
+
<!-- #endif -->
|
|
270
|
+
<view v-if="showLoading && loading" class="u-qrcode__loading" :style="{ width: size + unit, height: size + unit }">
|
|
271
|
+
<up-loading-icon vertical :text="loadingText" textSize="14px"></up-loading-icon>
|
|
272
|
+
</view>
|
|
273
|
+
<!-- <image v-show="show" :src="result" :style="{ width: size + unit, height: size + unit }" /> -->
|
|
274
|
+
</view>
|
|
275
|
+
<!-- <up-action-sheet :actions="list" cancelText="取消" v-model:show="popupShow" @select="selectClick"></up-action-sheet> -->
|
|
276
|
+
</view>
|
|
277
|
+
</template>
|
|
278
|
+
<script>
|
|
279
|
+
import QRCode from './qrcode.js';
|
|
280
|
+
// #ifdef APP-NVUE
|
|
281
|
+
// https://github.com/dcloudio/NvueCanvasDemo/blob/master/README.md
|
|
282
|
+
import { enable, WeexBridge } from '../../libs/util/gcanvas/index.js';
|
|
283
|
+
// #endif
|
|
284
|
+
let qrcode;
|
|
285
|
+
export default {
|
|
286
|
+
name: 'u-qrcode',
|
|
287
|
+
props: {
|
|
288
|
+
cid: {
|
|
289
|
+
type: String,
|
|
290
|
+
default: 'u-qrcode-canvas' + Math.random().toString()
|
|
291
|
+
},
|
|
292
|
+
size: {
|
|
293
|
+
type: Number,
|
|
294
|
+
default: 200
|
|
295
|
+
},
|
|
296
|
+
unit: {
|
|
297
|
+
type: String,
|
|
298
|
+
default: 'px'
|
|
299
|
+
},
|
|
300
|
+
show: {
|
|
301
|
+
type: Boolean,
|
|
302
|
+
default: true
|
|
303
|
+
},
|
|
304
|
+
val: {
|
|
305
|
+
type: String,
|
|
306
|
+
default: ''
|
|
307
|
+
},
|
|
308
|
+
background: {
|
|
309
|
+
type: String,
|
|
310
|
+
default: '#ffffff'
|
|
311
|
+
},
|
|
312
|
+
foreground: {
|
|
313
|
+
type: String,
|
|
314
|
+
default: '#000000'
|
|
315
|
+
},
|
|
316
|
+
pdground: {
|
|
317
|
+
type: String,
|
|
318
|
+
default: '#000000'
|
|
319
|
+
},
|
|
320
|
+
icon: {
|
|
321
|
+
type: String,
|
|
322
|
+
default: ''
|
|
323
|
+
},
|
|
324
|
+
iconSize: {
|
|
325
|
+
type: Number,
|
|
326
|
+
default: 40
|
|
327
|
+
},
|
|
328
|
+
lv: {
|
|
329
|
+
type: Number,
|
|
330
|
+
default: 3
|
|
331
|
+
},
|
|
332
|
+
onval: {
|
|
333
|
+
type: Boolean,
|
|
334
|
+
default: true
|
|
335
|
+
},
|
|
336
|
+
loadMake: {
|
|
337
|
+
type: Boolean,
|
|
338
|
+
default: true
|
|
339
|
+
},
|
|
340
|
+
usingComponents: {
|
|
341
|
+
type: Boolean,
|
|
342
|
+
default: true
|
|
343
|
+
},
|
|
344
|
+
showLoading: {
|
|
345
|
+
type: Boolean,
|
|
346
|
+
default: true
|
|
347
|
+
},
|
|
348
|
+
loadingText: {
|
|
349
|
+
type: String,
|
|
350
|
+
default: '生成中'
|
|
351
|
+
},
|
|
352
|
+
allowPreview: {
|
|
353
|
+
type: Boolean,
|
|
354
|
+
default: false
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
emits: ['result', 'longpress'],
|
|
358
|
+
data() {
|
|
359
|
+
return {
|
|
360
|
+
loading: false,
|
|
361
|
+
result: '',
|
|
362
|
+
popupShow: false,
|
|
363
|
+
list: [
|
|
364
|
+
{
|
|
365
|
+
name: '保存二维码'
|
|
366
|
+
}
|
|
367
|
+
],
|
|
368
|
+
ganvas: null,
|
|
369
|
+
context: '',
|
|
370
|
+
canvasObj: {}
|
|
371
|
+
};
|
|
372
|
+
},
|
|
373
|
+
mounted: function () {
|
|
374
|
+
// #ifdef APP-NVUE
|
|
375
|
+
/*获取元素引用*/
|
|
376
|
+
this.ganvas = this.$refs['gcanvess'];
|
|
377
|
+
/*通过元素引用获取canvas对象*/
|
|
378
|
+
this.canvasObj = enable(this.ganvas, {
|
|
379
|
+
bridge: WeexBridge
|
|
380
|
+
});
|
|
381
|
+
/*获取绘图所需的上下文,目前不支持3d*/
|
|
382
|
+
this.context = this.canvasObj.getContext('2d');
|
|
383
|
+
// #endif
|
|
384
|
+
if (this.loadMake) {
|
|
385
|
+
if (!this._empty(this.val)) {
|
|
386
|
+
setTimeout(() => {
|
|
387
|
+
this._makeCode();
|
|
388
|
+
}, 0);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
methods: {
|
|
393
|
+
_makeCode() {
|
|
394
|
+
let that = this;
|
|
395
|
+
if (!this._empty(this.val)) {
|
|
396
|
+
// #ifndef APP-NVUE
|
|
397
|
+
this.loading = true;
|
|
398
|
+
// #endif
|
|
399
|
+
qrcode = new QRCode({
|
|
400
|
+
context: that, // 上下文环境
|
|
401
|
+
canvasId: that.cid, // canvas-id
|
|
402
|
+
nvueContext: that.context,
|
|
403
|
+
usingComponents: that.usingComponents, // 是否是自定义组件
|
|
404
|
+
showLoading: false, // 是否显示loading
|
|
405
|
+
loadingText: that.loadingText, // loading文字
|
|
406
|
+
text: that.val, // 生成内容
|
|
407
|
+
size: that.size, // 二维码大小
|
|
408
|
+
background: that.background, // 背景色
|
|
409
|
+
foreground: that.foreground, // 前景色
|
|
410
|
+
pdground: that.pdground, // 定位角点颜色
|
|
411
|
+
correctLevel: that.lv, // 容错级别
|
|
412
|
+
image: that.icon, // 二维码图标
|
|
413
|
+
imageSize: that.iconSize, // 二维码图标大小
|
|
414
|
+
cbResult: function (res) {
|
|
415
|
+
// 生成二维码的回调
|
|
416
|
+
that._result(res);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
} else {
|
|
420
|
+
uni.showToast({
|
|
421
|
+
title: '二维码内容不能为空',
|
|
422
|
+
icon: 'none',
|
|
423
|
+
duration: 2000
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
_clearCode() {
|
|
428
|
+
this._result('');
|
|
429
|
+
qrcode.clear();
|
|
430
|
+
},
|
|
431
|
+
_saveCode() {
|
|
432
|
+
let that = this;
|
|
433
|
+
if (this.result != '') {
|
|
434
|
+
uni.saveImageToPhotosAlbum({
|
|
435
|
+
filePath: that.result,
|
|
436
|
+
success: function () {
|
|
437
|
+
uni.showToast({
|
|
438
|
+
title: '二维码保存成功',
|
|
439
|
+
icon: 'success',
|
|
440
|
+
duration: 2000
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
preview(e) {
|
|
447
|
+
// 预览图片
|
|
448
|
+
// console.log(this.result)
|
|
449
|
+
if (this.allowPreview) {
|
|
450
|
+
uni.previewImage({
|
|
451
|
+
urls: [this.result],
|
|
452
|
+
longPressActions: {
|
|
453
|
+
itemList: ['保存二维码图片'],
|
|
454
|
+
success: function (data) {
|
|
455
|
+
// console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
|
|
456
|
+
switch (data.tapIndex) {
|
|
457
|
+
case 0:
|
|
458
|
+
that._saveCode();
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
fail: function (err) {
|
|
463
|
+
console.log(err.errMsg);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
this.$emit(
|
|
469
|
+
'preview',
|
|
470
|
+
{
|
|
471
|
+
url: this.result
|
|
472
|
+
},
|
|
473
|
+
e
|
|
474
|
+
);
|
|
475
|
+
},
|
|
476
|
+
longpress() {
|
|
477
|
+
this.$emit('longpress', this.result);
|
|
478
|
+
},
|
|
479
|
+
selectClick(index) {
|
|
480
|
+
switch (index) {
|
|
481
|
+
case 0:
|
|
482
|
+
alert('保存二维码');
|
|
483
|
+
this._saveCode();
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
_result(res) {
|
|
488
|
+
this.loading = false;
|
|
489
|
+
this.result = res;
|
|
490
|
+
this.$emit('result', res);
|
|
491
|
+
},
|
|
492
|
+
_empty(v) {
|
|
493
|
+
let tp = typeof v,
|
|
494
|
+
rt = false;
|
|
495
|
+
if (tp == 'number' && String(v) == '') {
|
|
496
|
+
rt = true;
|
|
497
|
+
} else if (tp == 'undefined') {
|
|
498
|
+
rt = true;
|
|
499
|
+
} else if (tp == 'object') {
|
|
500
|
+
if (JSON.stringify(v) == '{}' || JSON.stringify(v) == '[]' || v == null) rt = true;
|
|
501
|
+
} else if (tp == 'string') {
|
|
502
|
+
if (v == '' || v == 'undefined' || v == 'null' || v == '{}' || v == '[]') rt = true;
|
|
503
|
+
} else if (tp == 'function') {
|
|
504
|
+
rt = false;
|
|
505
|
+
}
|
|
506
|
+
return rt;
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
watch: {
|
|
510
|
+
size: function (n, o) {
|
|
511
|
+
if (n != o && !this._empty(n)) {
|
|
512
|
+
this.cSize = n;
|
|
513
|
+
if (!this._empty(this.val)) {
|
|
514
|
+
setTimeout(() => {
|
|
515
|
+
this._makeCode();
|
|
516
|
+
}, 100);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
val: function (n, o) {
|
|
521
|
+
if (this.onval) {
|
|
522
|
+
if (n != o && !this._empty(n)) {
|
|
523
|
+
setTimeout(() => {
|
|
524
|
+
this._makeCode();
|
|
525
|
+
}, 0);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
computed: {}
|
|
531
|
+
};
|
|
532
|
+
</script>
|
|
533
|
+
<style scoped>
|
|
534
|
+
@import './style.css';
|
|
535
|
+
</style>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
>
|
|
11
11
|
<view class="u-radio__icon-wrap cursor-pointer" @tap.stop="iconClickHandler" :class="iconClasses" :style="[iconWrapStyle]">
|
|
12
12
|
<slot name="icon" :elIconSize="elIconSize" :elIconColor="elIconColor">
|
|
13
|
-
<
|
|
13
|
+
<up-icon class="u-radio__icon-wrap__icon" name="checkbox-mark" :size="elIconSize" :color="elIconColor" />
|
|
14
14
|
</slot>
|
|
15
15
|
</view>
|
|
16
16
|
<view class="u-radio__label-wrap cursor-pointer" @tap.stop="labelClickHandler">
|
|
@@ -53,7 +53,7 @@ import { addUnit, addStyle, os, deepMerge, formValidate, error } from '../../lib
|
|
|
53
53
|
* @property {Object} customStyle 组件的样式,对象形式
|
|
54
54
|
*
|
|
55
55
|
* @event {Function} change 某个radio状态发生变化时触发(选中状态)
|
|
56
|
-
* @example <
|
|
56
|
+
* @example <up-radio :labelDisabled="false">门掩黄昏,无计留春住</up-radio>
|
|
57
57
|
*/
|
|
58
58
|
export default {
|
|
59
59
|
name: 'u-radio',
|
|
@@ -91,8 +91,8 @@ export default {
|
|
|
91
91
|
return this.labelDisabled !== ''
|
|
92
92
|
? this.labelDisabled
|
|
93
93
|
: this.parentData.labelDisabled !== null
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
? this.parentData.labelDisabled
|
|
95
|
+
: false;
|
|
96
96
|
},
|
|
97
97
|
// 组件尺寸,对应size的值,默认值为21px
|
|
98
98
|
elSize() {
|
|
@@ -31,7 +31,7 @@ import { addUnit, addStyle, deepMerge } from '../../libs/function/index';
|
|
|
31
31
|
* @property {Object} gap item 之间的间距
|
|
32
32
|
* @property {Object} customStyle 组件的样式,对象形式
|
|
33
33
|
* @event {Function} change 任一个radio状态发生变化时触发
|
|
34
|
-
* @example <
|
|
34
|
+
* @example <up-radio-group v-model="value"></up-radio-group>
|
|
35
35
|
*/
|
|
36
36
|
export default {
|
|
37
37
|
name: 'u-radio-group',
|