@10yun/cv-mobile-ui 0.4.11 → 0.5.1
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 +1 -1
- package/plugins/MessageBox.js +2 -2
- package/plugins/MessageTip.js +4 -4
- package/plugins/request.js +54 -39
- package/plugins/storage.js +1 -4
- package/plugins/utils.js +13 -0
- package/ui-cv/cv-draw-barcode/barcode.js +225 -202
- package/ui-cv/cv-draw-barcode/barcodes/Barcode.js +14 -17
- package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128.js +202 -164
- package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128A.js +58 -35
- package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128B.js +58 -36
- package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128C.js +58 -34
- package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128_AUTO.js +50 -41
- package/ui-cv/cv-draw-barcode/barcodes/CODE128/auto.js +43 -57
- package/ui-cv/cv-draw-barcode/barcodes/CODE128/constants.js +71 -30
- package/ui-cv/cv-draw-barcode/barcodes/CODE128/index.js +11 -29
- package/ui-cv/cv-draw-barcode/barcodes/CODE39/index.js +150 -77
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN.js +122 -90
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN13.js +169 -111
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN2.js +77 -56
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN5.js +84 -60
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN8.js +133 -74
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/UPC.js +174 -156
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/UPCE.js +220 -174
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/constants.js +80 -21
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/encoder.js +18 -24
- package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/index.js +15 -39
- package/ui-cv/cv-draw-barcode/barcodes/GenericBarcode/index.js +80 -55
- package/ui-cv/cv-draw-barcode/barcodes/ITF/ITF.js +99 -69
- package/ui-cv/cv-draw-barcode/barcodes/ITF/ITF14.js +73 -45
- package/ui-cv/cv-draw-barcode/barcodes/ITF/constants.js +8 -8
- package/ui-cv/cv-draw-barcode/barcodes/ITF/index.js +6 -18
- package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI.js +86 -66
- package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI10.js +40 -33
- package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI1010.js +41 -35
- package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI11.js +42 -33
- package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI1110.js +37 -35
- package/ui-cv/cv-draw-barcode/barcodes/MSI/checksums.js +22 -25
- package/ui-cv/cv-draw-barcode/barcodes/MSI/index.js +13 -34
- package/ui-cv/cv-draw-barcode/barcodes/codabar/index.js +120 -90
- package/ui-cv/cv-draw-barcode/barcodes/common.js +0 -0
- package/ui-cv/cv-draw-barcode/barcodes/index.js +32 -33
- package/ui-cv/cv-draw-barcode/barcodes/index.tmp.js +32 -33
- package/ui-cv/cv-draw-barcode/barcodes/pharmacode/index.js +93 -71
- package/ui-cv/cv-draw-barcode/cv-draw-barcode.vue +4 -4
- package/ui-cv/cv-icons/icons/default-icons.js +132 -0
- package/ui-cv/cv-icons/icons/icons-action.js +72 -0
- package/ui-cv/cv-icons/icons/icons-arrow.js +46 -0
- package/ui-cv/cv-icons/icons/icons-base.js +89 -0
- package/ui-cv/cv-icons/icons/icons-mall.js +34 -0
- package/ui-cv/cv-icons/icons/icons-media.js +44 -0
- package/ui-cv/cv-icons/icons/icons-order.js +33 -0
- package/ui-cv/cv-icons/icons/icons-people.js +46 -0
- package/ui-cv/cv-icons/icons/icons-status.js +32 -0
- package/ui-cv/cv-icons/icons/icons-wallet.js +15 -0
- package/ui-cv/cv-icons/icons.js +14 -13
- package/ui-cv/cv-lists-base/cv-lists-base.vue +0 -2
- package/ui-cv/cv-tab-lists/cv-tab-lists.vue +0 -2
- package/ui-uni/u-charts/u-charts.js +1093 -744
- package/ui-uni/uni-list/uni-refresh.wxs +1 -1
- package/ui-uni/uni-swipe-action-item/index.wxs +6 -6
|
@@ -1,204 +1,227 @@
|
|
|
1
|
-
|
|
2
|
-
let barcode = {};
|
|
3
|
-
(function () {
|
|
4
|
-
// 初始化
|
|
5
|
-
barcode = function (cont, ctxid, options, ctxsize, result) {
|
|
6
|
-
let ops = {},
|
|
7
|
-
newOptions, encodings, globaContext, ctx, globaCtxid, cbCanvasSize, cbResult;
|
|
8
|
-
globaCtxid = ctxid
|
|
9
|
-
cbCanvasSize = ctxsize
|
|
10
|
-
cbResult = result
|
|
11
|
-
newOptions = Object.assign(ops, options);
|
|
12
|
-
// 修成margin
|
|
13
|
-
fixMargin(newOptions)
|
|
14
|
-
// 处理options 数据
|
|
15
|
-
if (newOptions.text == '' || cont == '') {
|
|
16
|
-
return false
|
|
17
|
-
}
|
|
18
|
-
// 获取ctx
|
|
1
|
+
import barcodes from './barcodes/index.js';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
3
|
+
var barCode = {};
|
|
4
|
+
(function () {
|
|
5
|
+
// 初始化
|
|
6
|
+
barCode = function (cont, ctxid, options, ctxsize, result) {
|
|
7
|
+
let ops = {},
|
|
8
|
+
newOptions,
|
|
9
|
+
encodings,
|
|
10
|
+
globaContext,
|
|
11
|
+
ctx,
|
|
12
|
+
globaCtxid,
|
|
13
|
+
cbCanvasSize,
|
|
14
|
+
cbResult;
|
|
15
|
+
globaCtxid = ctxid;
|
|
16
|
+
cbCanvasSize = ctxsize;
|
|
17
|
+
cbResult = result;
|
|
18
|
+
newOptions = Object.assign(ops, options);
|
|
19
|
+
// 修成margin
|
|
20
|
+
fixMargin(newOptions);
|
|
21
|
+
// 处理options 数据
|
|
22
|
+
if (newOptions.text == '' || cont == undefined) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
// 获取ctx
|
|
26
|
+
globaContext = cont;
|
|
27
|
+
ctx = uni.createCanvasContext(globaCtxid, globaContext);
|
|
28
|
+
// 获取编码数据
|
|
29
|
+
encodings = new barcodes[newOptions.format.toUpperCase()](newOptions.text, newOptions).encode();
|
|
30
|
+
let fixencodings = fixEncodings(encodings, newOptions);
|
|
31
|
+
// 返回canvas实际大小
|
|
32
|
+
cbCanvasSize({
|
|
33
|
+
width: fixencodings.width,
|
|
34
|
+
height: fixencodings.height
|
|
35
|
+
});
|
|
36
|
+
// 绘制canvas
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
drawCanvas.render(newOptions, fixencodings);
|
|
39
|
+
}, 50);
|
|
40
|
+
// 绘制canvas
|
|
41
|
+
let drawCanvas = {
|
|
42
|
+
render(options, encoding) {
|
|
43
|
+
this.prepare(options, encoding);
|
|
44
|
+
encoding.encodings.forEach((v, i) => {
|
|
45
|
+
this.barcode(options, v);
|
|
46
|
+
this.text(options, v);
|
|
47
|
+
this.move(v);
|
|
48
|
+
});
|
|
49
|
+
this.draw(options, encoding);
|
|
50
|
+
},
|
|
51
|
+
barcode(options, encoding) {
|
|
52
|
+
let binary = encoding.data;
|
|
53
|
+
let yFrom;
|
|
54
|
+
if (options.textPosition == 'top') {
|
|
55
|
+
yFrom = options.marginTop + options.fontSize + options.textMargin;
|
|
56
|
+
} else {
|
|
57
|
+
yFrom = options.marginTop;
|
|
58
|
+
}
|
|
59
|
+
// 绘制条码
|
|
60
|
+
ctx.fillStyle = options.lineColor;
|
|
61
|
+
for (let b = 0; b < binary.length; b++) {
|
|
62
|
+
let x = b * options.width + encoding.barcodePadding;
|
|
63
|
+
let height = options.height;
|
|
64
|
+
if (encoding.options) {
|
|
65
|
+
if (encoding.options.height != undefined) {
|
|
66
|
+
height = encoding.options.height;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (binary[b] === '1') {
|
|
70
|
+
ctx.fillRect(x, yFrom, options.width, height);
|
|
71
|
+
} else if (binary[b]) {
|
|
72
|
+
ctx.fillRect(x, yFrom, options.width, height * binary[b]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
text(options, encoding) {
|
|
77
|
+
if (options.displayValue) {
|
|
78
|
+
let x, y, align, size;
|
|
79
|
+
if (options.textPosition == 'top') {
|
|
80
|
+
y = options.marginTop + options.fontSize;
|
|
81
|
+
} else {
|
|
82
|
+
y = options.height + options.textMargin + options.marginTop + options.fontSize;
|
|
83
|
+
}
|
|
84
|
+
if (encoding.options) {
|
|
85
|
+
if (encoding.options.textAlign != undefined) {
|
|
86
|
+
align = encoding.options.textAlign;
|
|
87
|
+
}
|
|
88
|
+
if (encoding.options.fontSize != undefined) {
|
|
89
|
+
size = encoding.options.fontSize;
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
align = options.textAlign;
|
|
93
|
+
size = options.fontSize;
|
|
94
|
+
}
|
|
95
|
+
ctx.setFontSize(size);
|
|
96
|
+
if (align == 'left' || encoding.barcodePadding > 0) {
|
|
97
|
+
x = 0;
|
|
98
|
+
ctx.setTextAlign('left');
|
|
99
|
+
} else if (align == 'right') {
|
|
100
|
+
x = encoding.width - 1;
|
|
101
|
+
ctx.setTextAlign('right');
|
|
102
|
+
} else {
|
|
103
|
+
x = encoding.width / 2;
|
|
104
|
+
ctx.setTextAlign('center');
|
|
105
|
+
}
|
|
106
|
+
ctx.fillStyle = options.fontColor;
|
|
107
|
+
if (encoding.text != undefined) {
|
|
108
|
+
ctx.fillText(encoding.text, x, y);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
move(encoding) {
|
|
113
|
+
ctx.translate(encoding.width, 0);
|
|
114
|
+
},
|
|
115
|
+
prepare(options, encoding) {
|
|
116
|
+
// 绘制背景
|
|
117
|
+
if (options.background) {
|
|
118
|
+
ctx.fillStyle = options.background;
|
|
119
|
+
ctx.fillRect(0, 0, encoding.width, encoding.height);
|
|
120
|
+
}
|
|
121
|
+
ctx.translate(options.marginLeft, 0);
|
|
122
|
+
},
|
|
123
|
+
draw(options, encoding) {
|
|
124
|
+
ctx.draw(false, () => {
|
|
125
|
+
this.toImgs(options, encoding);
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
toImgs(options, encoding) {
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
uni.canvasToTempFilePath(
|
|
131
|
+
{
|
|
132
|
+
width: encoding.width,
|
|
133
|
+
height: encoding.height,
|
|
134
|
+
destWidth: encoding.width,
|
|
135
|
+
destHeight: encoding.height,
|
|
136
|
+
canvasId: globaCtxid,
|
|
137
|
+
fileType: 'png',
|
|
138
|
+
success: function (res) {
|
|
139
|
+
cbResult(res.tempFilePath);
|
|
140
|
+
},
|
|
141
|
+
fail: function (res) {
|
|
142
|
+
cbResult(res);
|
|
143
|
+
},
|
|
144
|
+
complete: function () {
|
|
145
|
+
uni.hideLoading();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
globaContext
|
|
149
|
+
);
|
|
150
|
+
}, options.text.length + 100);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
// 混入canvas数据
|
|
154
|
+
function fixEncodings(encoding, options) {
|
|
155
|
+
let encodingArr = [],
|
|
156
|
+
width = options.marginLeft + options.marginRight,
|
|
157
|
+
height;
|
|
158
|
+
if (!Array.isArray(encoding)) {
|
|
159
|
+
encodingArr[0] = JSON.parse(JSON.stringify(encoding));
|
|
160
|
+
} else {
|
|
161
|
+
encodingArr = [...encoding];
|
|
162
|
+
}
|
|
163
|
+
encodingArr.forEach((v, i) => {
|
|
164
|
+
// 获取文本宽度
|
|
165
|
+
let textWidth = ctx.measureText(encodingArr[i].text ? encodingArr[i].text : '').width;
|
|
166
|
+
// 获取条形码宽度
|
|
167
|
+
let barcodeWidth = encodingArr[i].data.length * options.width;
|
|
168
|
+
// 获取内边距
|
|
169
|
+
let barcodePadding = 0;
|
|
170
|
+
if (options.displayValue && barcodeWidth < textWidth) {
|
|
171
|
+
if (options.textAlign == 'center') {
|
|
172
|
+
barcodePadding = Math.floor((textWidth - barcodeWidth) / 2);
|
|
173
|
+
} else if (options.textAlign == 'left') {
|
|
174
|
+
barcodePadding = 0;
|
|
175
|
+
} else if (options.textAlign == 'right') {
|
|
176
|
+
barcodePadding = Math.floor(textWidth - barcodeWidth);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// 混入encodingArr[i]
|
|
180
|
+
encodingArr[i].barcodePadding = barcodePadding;
|
|
181
|
+
encodingArr[i].width = Math.ceil(Math.max(textWidth, barcodeWidth));
|
|
182
|
+
width += encodingArr[i].width;
|
|
183
|
+
if (encodingArr[i].options) {
|
|
184
|
+
if (encodingArr[i].options.height != undefined) {
|
|
185
|
+
encodingArr[i].height =
|
|
186
|
+
encodingArr[i].options.height +
|
|
187
|
+
(options.displayValue && (encodingArr[i].text ? encodingArr[i].text : '').length > 0
|
|
188
|
+
? options.fontSize + options.textMargin
|
|
189
|
+
: 0) +
|
|
190
|
+
options.marginTop +
|
|
191
|
+
options.marginBottom;
|
|
192
|
+
} else {
|
|
193
|
+
encodingArr[i].height = height =
|
|
194
|
+
options.height +
|
|
195
|
+
(options.displayValue && (encodingArr[i].text ? encodingArr[i].text : '').length > 0
|
|
196
|
+
? options.fontSize + options.textMargin
|
|
197
|
+
: 0) +
|
|
198
|
+
options.marginTop +
|
|
199
|
+
options.marginBottom;
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
encodingArr[i].height = height =
|
|
203
|
+
options.height +
|
|
204
|
+
(options.displayValue && (encodingArr[i].text ? encodingArr[i].text : '').length > 0
|
|
205
|
+
? options.fontSize + options.textMargin
|
|
206
|
+
: 0) +
|
|
207
|
+
options.marginTop +
|
|
208
|
+
options.marginBottom;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
encodings: encodingArr,
|
|
213
|
+
width,
|
|
214
|
+
height
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
// 修正Margin
|
|
218
|
+
function fixMargin(options) {
|
|
219
|
+
options.marginTop = options.marginTop == undefined ? options.margin : options.marginTop;
|
|
220
|
+
options.marginBottom = options.marginBottom == undefined ? options.margin : options.marginBottom;
|
|
221
|
+
options.marginRight = options.marginRight == undefined ? options.margin : options.marginRight;
|
|
222
|
+
options.marginLeft = options.marginLeft == undefined ? options.margin : options.marginLeft;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
})();
|
|
203
226
|
|
|
204
|
-
export default
|
|
227
|
+
export default barCode;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
exports.default = Barcode;
|
|
1
|
+
function _classCallCheck(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError('Cannot call a class as a function');
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function BarcodeFunc(data, options) {
|
|
8
|
+
_classCallCheck(this, BarcodeFunc);
|
|
9
|
+
this.data = data;
|
|
10
|
+
this.text = options.text || data;
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
// export function BarcodeFunc;
|
|
14
|
+
// export function BarcodeFunc;
|