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