@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,119 +1,177 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import _constants from './constants.js';
|
|
2
|
+
import EAN_FUNC from './EAN.js';
|
|
3
|
+
|
|
4
|
+
var _createClass = (function () {
|
|
5
|
+
function defineProperties(target, props) {
|
|
6
|
+
for (var i = 0; i < props.length; i++) {
|
|
7
|
+
var descriptor = props[i];
|
|
8
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
9
|
+
descriptor.configurable = true;
|
|
10
|
+
if ('value' in descriptor) descriptor.writable = true;
|
|
11
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return function (Constructor, protoProps, staticProps) {
|
|
15
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
16
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
17
|
+
return Constructor;
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
|
|
21
|
+
var _get = function get(object, property, receiver) {
|
|
22
|
+
if (object === null) object = Function.prototype;
|
|
23
|
+
var desc = Object.getOwnPropertyDescriptor(object, property);
|
|
24
|
+
if (desc === undefined) {
|
|
25
|
+
var parent = Object.getPrototypeOf(object);
|
|
26
|
+
if (parent === null) {
|
|
27
|
+
return undefined;
|
|
28
|
+
} else {
|
|
29
|
+
return get(parent, property, receiver);
|
|
30
|
+
}
|
|
31
|
+
} else if ('value' in desc) {
|
|
32
|
+
return desc.value;
|
|
33
|
+
} else {
|
|
34
|
+
var getter = desc.get;
|
|
35
|
+
if (getter === undefined) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return getter.call(receiver);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
22
41
|
|
|
23
|
-
function
|
|
42
|
+
function _classCallCheck(instance, Constructor) {
|
|
43
|
+
if (!(instance instanceof Constructor)) {
|
|
44
|
+
throw new TypeError('Cannot call a class as a function');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _possibleConstructorReturn(self, call) {
|
|
49
|
+
if (!self) {
|
|
50
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
51
|
+
}
|
|
52
|
+
return call && (typeof call === 'object' || typeof call === 'function') ? call : self;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _inherits(subClass, superClass) {
|
|
56
|
+
if (typeof superClass !== 'function' && superClass !== null) {
|
|
57
|
+
throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
|
|
58
|
+
}
|
|
59
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
60
|
+
constructor: { value: subClass, enumerable: false, writable: true, configurable: true }
|
|
61
|
+
});
|
|
62
|
+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : (subClass.__proto__ = superClass);
|
|
63
|
+
} // Encoding documentation:
|
|
24
64
|
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Binary_encoding_of_data_digits_into_EAN-13_barcode
|
|
25
65
|
|
|
26
66
|
// Calculate the checksum digit
|
|
27
67
|
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
|
|
28
68
|
var checksum = function checksum(number) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
69
|
+
var res = number
|
|
70
|
+
.substr(0, 12)
|
|
71
|
+
.split('')
|
|
72
|
+
.map(function (n) {
|
|
73
|
+
return +n;
|
|
74
|
+
})
|
|
75
|
+
.reduce(function (sum, a, idx) {
|
|
76
|
+
return idx % 2 ? sum + a * 3 : sum + a;
|
|
77
|
+
}, 0);
|
|
78
|
+
|
|
79
|
+
return (10 - (res % 10)) % 10;
|
|
36
80
|
};
|
|
37
81
|
|
|
38
|
-
var EAN13 = function (_EAN) {
|
|
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
|
-
|
|
82
|
+
var EAN13 = (function (_EAN) {
|
|
83
|
+
_inherits(EAN13, _EAN);
|
|
84
|
+
|
|
85
|
+
function EAN13(data, options) {
|
|
86
|
+
_classCallCheck(this, EAN13);
|
|
87
|
+
|
|
88
|
+
// Add checksum if it does not exist
|
|
89
|
+
if (data.search(/^[0-9]{12}$/) !== -1) {
|
|
90
|
+
data += checksum(data);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Adds a last character to the end of the barcode
|
|
94
|
+
var _this = _possibleConstructorReturn(this, (EAN13.__proto__ || Object.getPrototypeOf(EAN13)).call(this, data, options));
|
|
95
|
+
|
|
96
|
+
_this.lastChar = options.lastChar;
|
|
97
|
+
return _this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_createClass(EAN13, [
|
|
101
|
+
{
|
|
102
|
+
key: 'valid',
|
|
103
|
+
value: function valid() {
|
|
104
|
+
return this.data.search(/^[0-9]{13}$/) !== -1 && +this.data[12] === checksum(this.data);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
key: 'leftText',
|
|
109
|
+
value: function leftText() {
|
|
110
|
+
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftText', this).call(this, 1, 6);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: 'leftEncode',
|
|
115
|
+
value: function leftEncode() {
|
|
116
|
+
var data = this.data.substr(1, 6);
|
|
117
|
+
var structure = _constants.EAN13_STRUCTURE[this.data[0]];
|
|
118
|
+
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftEncode', this).call(
|
|
119
|
+
this,
|
|
120
|
+
data,
|
|
121
|
+
structure
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
key: 'rightText',
|
|
127
|
+
value: function rightText() {
|
|
128
|
+
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightText', this).call(this, 7, 6);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: 'rightEncode',
|
|
133
|
+
value: function rightEncode() {
|
|
134
|
+
var data = this.data.substr(7, 6);
|
|
135
|
+
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightEncode', this).call(
|
|
136
|
+
this,
|
|
137
|
+
data,
|
|
138
|
+
'RRRRRR'
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// The "standard" way of printing EAN13 barcodes with guard bars
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
key: 'encodeGuarded',
|
|
146
|
+
value: function encodeGuarded() {
|
|
147
|
+
var data = _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'encodeGuarded', this).call(this);
|
|
148
|
+
|
|
149
|
+
// Extend data with left digit & last character
|
|
150
|
+
if (this.options.displayValue) {
|
|
151
|
+
data.unshift({
|
|
152
|
+
data: '000000000000',
|
|
153
|
+
text: this.text.substr(0, 1),
|
|
154
|
+
options: { textAlign: 'left', fontSize: this.fontSize }
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (this.options.lastChar) {
|
|
158
|
+
data.push({
|
|
159
|
+
data: '00'
|
|
160
|
+
});
|
|
161
|
+
data.push({
|
|
162
|
+
data: '00000',
|
|
163
|
+
text: this.options.lastChar,
|
|
164
|
+
options: { fontSize: this.fontSize }
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return data;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
]);
|
|
173
|
+
|
|
174
|
+
return EAN13;
|
|
175
|
+
})(EAN_FUNC);
|
|
176
|
+
|
|
177
|
+
export default EAN13;
|
|
@@ -1,58 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import _constants from './constants.js';
|
|
2
|
+
import { BarcodeFunc } from '../Barcode.js';
|
|
3
|
+
import { encoderFunc } from './encoder.js';
|
|
4
|
+
|
|
5
|
+
var _createClass = (function () {
|
|
6
|
+
function defineProperties(target, props) {
|
|
7
|
+
for (var i = 0; i < props.length; i++) {
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ('value' in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return function (Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
};
|
|
20
|
+
})();
|
|
21
|
+
|
|
22
|
+
function _classCallCheck(instance, Constructor) {
|
|
23
|
+
if (!(instance instanceof Constructor)) {
|
|
24
|
+
throw new TypeError('Cannot call a class as a function');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _possibleConstructorReturn(self, call) {
|
|
29
|
+
if (!self) {
|
|
30
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
31
|
+
}
|
|
32
|
+
return call && (typeof call === 'object' || typeof call === 'function') ? call : self;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _inherits(subClass, superClass) {
|
|
36
|
+
if (typeof superClass !== 'function' && superClass !== null) {
|
|
37
|
+
throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
|
|
38
|
+
}
|
|
39
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
40
|
+
constructor: { value: subClass, enumerable: false, writable: true, configurable: true }
|
|
41
|
+
});
|
|
42
|
+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : (subClass.__proto__ = superClass);
|
|
43
|
+
} // Encoding documentation:
|
|
26
44
|
// https://en.wikipedia.org/wiki/EAN_2#Encoding
|
|
27
45
|
|
|
28
|
-
var EAN2 = function (_Barcode) {
|
|
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
|
-
|
|
46
|
+
var EAN2 = (function (_Barcode) {
|
|
47
|
+
_inherits(EAN2, _Barcode);
|
|
48
|
+
|
|
49
|
+
function EAN2(data, options) {
|
|
50
|
+
_classCallCheck(this, EAN2);
|
|
51
|
+
|
|
52
|
+
return _possibleConstructorReturn(this, (EAN2.__proto__ || Object.getPrototypeOf(EAN2)).call(this, data, options));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_createClass(EAN2, [
|
|
56
|
+
{
|
|
57
|
+
key: 'valid',
|
|
58
|
+
value: function valid() {
|
|
59
|
+
return this.data.search(/^[0-9]{2}$/) !== -1;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: 'encode',
|
|
64
|
+
value: function encode() {
|
|
65
|
+
// Choose the structure based on the number mod 4
|
|
66
|
+
var structure = _constants.EAN2_STRUCTURE[parseInt(this.data) % 4];
|
|
67
|
+
return {
|
|
68
|
+
// Start bits + Encode the two digits with 01 in between
|
|
69
|
+
data: '1011' + (0, encoderFunc)(this.data, structure, '01'),
|
|
70
|
+
text: this.text
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
return EAN2;
|
|
77
|
+
})(BarcodeFunc);
|
|
78
|
+
|
|
79
|
+
export default EAN2;
|
|
@@ -1,65 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import _constants from './constants.js';
|
|
2
|
+
import { BarcodeFunc } from '../Barcode.js';
|
|
3
|
+
import { encoderFunc } from './encoder.js';
|
|
4
|
+
|
|
5
|
+
var _createClass = (function () {
|
|
6
|
+
function defineProperties(target, props) {
|
|
7
|
+
for (var i = 0; i < props.length; i++) {
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ('value' in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return function (Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
};
|
|
20
|
+
})();
|
|
21
|
+
|
|
22
|
+
function _classCallCheck(instance, Constructor) {
|
|
23
|
+
if (!(instance instanceof Constructor)) {
|
|
24
|
+
throw new TypeError('Cannot call a class as a function');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _possibleConstructorReturn(self, call) {
|
|
29
|
+
if (!self) {
|
|
30
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
31
|
+
}
|
|
32
|
+
return call && (typeof call === 'object' || typeof call === 'function') ? call : self;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _inherits(subClass, superClass) {
|
|
36
|
+
if (typeof superClass !== 'function' && superClass !== null) {
|
|
37
|
+
throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
|
|
38
|
+
}
|
|
39
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
40
|
+
constructor: { value: subClass, enumerable: false, writable: true, configurable: true }
|
|
41
|
+
});
|
|
42
|
+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : (subClass.__proto__ = superClass);
|
|
43
|
+
} // Encoding documentation:
|
|
26
44
|
// https://en.wikipedia.org/wiki/EAN_5#Encoding
|
|
27
45
|
|
|
28
46
|
var checksum = function checksum(data) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
var result = data
|
|
48
|
+
.split('')
|
|
49
|
+
.map(function (n) {
|
|
50
|
+
return +n;
|
|
51
|
+
})
|
|
52
|
+
.reduce(function (sum, a, idx) {
|
|
53
|
+
return idx % 2 ? sum + a * 9 : sum + a * 3;
|
|
54
|
+
}, 0);
|
|
55
|
+
return result % 10;
|
|
35
56
|
};
|
|
36
57
|
|
|
37
|
-
var EAN5 = function (_Barcode) {
|
|
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
|
-
|
|
58
|
+
var EAN5 = (function (_Barcode) {
|
|
59
|
+
_inherits(EAN5, _Barcode);
|
|
60
|
+
|
|
61
|
+
function EAN5(data, options) {
|
|
62
|
+
_classCallCheck(this, EAN5);
|
|
63
|
+
|
|
64
|
+
return _possibleConstructorReturn(this, (EAN5.__proto__ || Object.getPrototypeOf(EAN5)).call(this, data, options));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_createClass(EAN5, [
|
|
68
|
+
{
|
|
69
|
+
key: 'valid',
|
|
70
|
+
value: function valid() {
|
|
71
|
+
return this.data.search(/^[0-9]{5}$/) !== -1;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
key: 'encode',
|
|
76
|
+
value: function encode() {
|
|
77
|
+
var structure = _constants.EAN5_STRUCTURE[checksum(this.data)];
|
|
78
|
+
return {
|
|
79
|
+
data: '1011' + (0, encoderFunc)(this.data, structure, '01'),
|
|
80
|
+
text: this.text
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
return EAN5;
|
|
87
|
+
})(BarcodeFunc);
|
|
88
|
+
|
|
89
|
+
export default EAN5;
|