@10yun/cv-mobile-ui 0.5.51 → 0.5.52

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 (110) hide show
  1. package/build/common_func.js +3 -1
  2. package/build/parse-create.js +17 -8
  3. package/build/parse-pages-pkg.js +10 -4
  4. package/empty-devtools.js +3 -0
  5. package/libs/aes.js +50 -0
  6. package/libs/bledefine/bledefine.js +51 -0
  7. package/libs/bledefine/ios-ble-statuscode.js +97 -0
  8. package/libs/nfc/hexiii-nfc.js +236 -0
  9. package/libs/nfc.js +179 -0
  10. package/libs/sdk/html2canvas.js +8 -0
  11. package/libs/sdk/sdk-h5.js +585 -0
  12. package/{plugins → libs}/storage2.js +0 -5
  13. package/{plugins → libs}/storage3.js +0 -4
  14. package/libs/validators/index.js +438 -0
  15. package/libs/weapp-qrcode.js +1108 -0
  16. package/package.json +2 -3
  17. package/ui-cv/components/cv-dialog-share/tui-share.vue +16 -16
  18. package/ui-fireui/components/{fui-actionsheet/fui-actionsheet.vue → u-action-sheet/u-action-sheet.vue} +21 -21
  19. package/ui-fireui/components/{fui-alert/fui-alert.vue → u-alert/u-alert.vue} +13 -13
  20. package/ui-fireui/components/{fui-badge/fui-badge.vue → u-badge/u-badge.vue} +16 -16
  21. package/ui-fireui/components/{fui-bottom-navigation/fui-bottom-navigation.vue → u-bottom-navigation/u-bottom-navigation.vue} +47 -46
  22. package/ui-fireui/components/{fui-bottom-popup/fui-bottom-popup.vue → u-bottom-popup/u-bottom-popup.vue} +9 -8
  23. package/ui-fireui/components/{fui-bubble-popup/fui-bubble-popup.vue → u-bubble-popup/u-bubble-popup.vue} +19 -15
  24. package/ui-fireui/components/{fui-button/fui-button.vue → u-button/u-button.vue} +69 -69
  25. package/ui-fireui/components/u-button/u-button2.vue +553 -0
  26. package/ui-fireui/components/{fui-calendar/fui-calendar.vue → u-calendar/u-calendar.vue} +78 -78
  27. package/ui-fireui/components/u-calendar/u-calendar2.vue +801 -0
  28. package/ui-fireui/components/{fui-card/fui-card.vue → u-card/u-card.vue} +24 -24
  29. package/ui-fireui/components/{fui-cascade-selection/fui-cascade-selection.vue → u-cascade-selection/u-cascade-selection.vue} +32 -32
  30. package/ui-fireui/components/{fui-circular-progress/fui-circular-progress.vue → u-circular-progress/u-circular-progress.vue} +14 -6
  31. package/ui-fireui/components/{fui-collapse/fui-collapse.vue → u-collapse/u-collapse.vue} +19 -19
  32. package/ui-fireui/components/{fui-countdown/fui-countdown.vue → u-countdown/u-countdown.vue} +28 -28
  33. package/ui-fireui/components/{fui-datetime/fui-datetime.vue → u-datetime/u-datetime.vue} +51 -51
  34. package/ui-fireui/components/{fui-divider/fui-divider.vue → u-divider/u-divider.vue} +6 -6
  35. package/ui-fireui/components/{fui-drawer/fui-drawer.vue → u-drawer/u-drawer.vue} +11 -11
  36. package/ui-fireui/components/{fui-dropdown-list/fui-dropdown-list.vue → u-dropdown-list/u-dropdown-list.vue} +11 -6
  37. package/ui-fireui/components/{fui-fab/fui-fab.vue → u-fab/u-fab.vue} +30 -30
  38. package/ui-fireui/components/{fui-footer/fui-footer.vue → u-footer/u-footer.vue} +19 -15
  39. package/ui-fireui/components/{fui-grid/fui-grid.vue → u-grid/u-grid.vue} +13 -5
  40. package/ui-fireui/components/{fui-grid-item/fui-grid-item.vue → u-grid-item/u-grid-item.vue} +19 -19
  41. package/ui-fireui/components/{fui-icon/fui-icon.vue → u-icon/u-icon.vue} +191 -191
  42. package/ui-fireui/components/{fui-image-cropper/fui-image-cropper.vue → u-image-cropper/u-image-cropper.vue} +44 -44
  43. package/ui-fireui/components/{fui-image-group/fui-image-group.vue → u-image-group/u-image-group.vue} +7 -7
  44. package/ui-fireui/components/{fui-keyboard/fui-keyboard.vue → u-keyboard/u-keyboard.vue} +29 -32
  45. package/ui-fireui/components/{fui-keyboard-input/fui-keyboard-input.vue → u-keyboard-input/u-keyboard-input.vue} +9 -9
  46. package/ui-fireui/components/{fui-list-cell/fui-list-cell.vue → u-list-cell/u-list-cell.vue} +23 -23
  47. package/ui-fireui/components/{fui-list-view/fui-list-view.vue → u-list-view/u-list-view.vue} +11 -11
  48. package/ui-fireui/components/{fui-loading/fui-loading.vue → u-loading/u-loading.vue} +6 -6
  49. package/ui-fireui/components/{fui-loadmore/fui-loadmore.vue → u-loadmore/u-loadmore.vue} +15 -15
  50. package/ui-fireui/components/{fui-modal/fui-modal.vue → u-modal/u-modal.vue} +58 -58
  51. package/ui-fireui/components/{fui-navigation-bar/fui-navigation-bar.vue → u-navigation-bar/u-navigation-bar.vue} +11 -10
  52. package/ui-fireui/components/{fui-no-data/fui-no-data.vue → u-no-data/u-no-data.vue} +11 -11
  53. package/ui-fireui/components/{fui-nomore/fui-nomore.vue → u-nomore/u-nomore.vue} +10 -10
  54. package/ui-fireui/components/{fui-numberbox/fui-numberbox.vue → u-numberbox/u-numberbox.vue} +12 -12
  55. package/ui-fireui/components/{fui-numberbox-border/fui-numberbox-border.vue → u-numberbox-border/u-numberbox-border.vue} +10 -10
  56. package/ui-fireui/components/{fui-picture-cropper/fui-picture-cropper.vue → u-picture-cropper/u-picture-cropper.vue} +42 -42
  57. package/ui-fireui/components/u-picture-cropper/u-picture-cropper.wxs +582 -0
  58. package/ui-fireui/components/{fui-round-progress/fui-round-progress.vue → u-round-progress/u-round-progress.vue} +2 -2
  59. package/ui-fireui/components/{fui-scroll-top/fui-scroll-top.vue → u-scroll-top/u-scroll-top.vue} +21 -21
  60. package/ui-fireui/components/{fui-sharemodel/fui-sharemodel.vue → u-share-model/u-share-model.vue} +24 -24
  61. package/ui-fireui/components/{fui-skeleton/fui-skeleton.vue → u-skeleton/u-skeleton.vue} +22 -22
  62. package/ui-fireui/components/{fui-steps/fui-steps.vue → u-steps/u-steps.vue} +27 -27
  63. package/ui-fireui/components/{fui-sticky/fui-sticky.vue → u-sticky/u-sticky.vue} +4 -4
  64. package/ui-fireui/components/{fui-sticky-wxs/fui-sticky-wxs.vue → u-sticky-wxs/u-sticky-wxs.vue} +7 -7
  65. package/ui-fireui/components/u-sticky-wxs/u-sticky.wxs +46 -0
  66. package/ui-fireui/components/{fui-swipe-action/fui-swipe-action.vue → u-swipe-action/u-swipe-action.vue} +11 -11
  67. package/ui-fireui/components/{fui-tabbar/fui-tabbar.vue → u-tabbar/u-tabbar.vue} +26 -30
  68. package/ui-fireui/components/{fui-tabs/fui-tabs.vue → u-tabs/u-tabs.vue} +17 -17
  69. package/ui-fireui/components/{fui-tabs2/fui-tabs2.vue → u-tabs2/u-tabs2.vue} +17 -17
  70. package/ui-fireui/components/{fui-tag/fui-tag.vue → u-tag/u-tag.vue} +362 -374
  71. package/ui-fireui/components/{fui-time-axis/fui-time-axis.vue → u-time-axis/u-time-axis.vue} +3 -3
  72. package/ui-fireui/components/{fui-timeaxis-item/fui-timeaxis-item.vue → u-timeaxis-item/u-timeaxis-item.vue} +4 -4
  73. package/ui-fireui/components/{fui-tips/fui-tips.vue → u-tips/u-tips.vue} +20 -20
  74. package/ui-fireui/components/{fui-toast/fui-toast.vue → u-toast/u-toast.vue} +13 -13
  75. package/ui-fireui/components/{fui-top-dropdown/fui-top-dropdown.vue → u-top-dropdown/u-top-dropdown.vue} +8 -8
  76. package/ui-fireui/components/{fui-upload/fui-upload.vue → u-upload/u-upload.vue} +30 -30
  77. package/ui-fireui/components/u-upload2/u-upload.vue +464 -0
  78. package/ui-fireui/components/{fui-uploadsamll/fui-uploadsamll.vue → u-uploadsamll/u-uploadsamll.vue} +34 -34
  79. package/ui-fireui/css/thorui.css +589 -0
  80. package/ui-fireui/{fireui.css → index.css} +306 -268
  81. package/ui-fireui/nvue/u-circular-progress/gcanvas/bridge/bridge-weex.js +241 -0
  82. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  83. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/FillStylePattern.js +8 -0
  84. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  85. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/RenderingContext.js +666 -0
  86. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/ActiveInfo.js +11 -0
  87. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Buffer.js +21 -0
  88. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Framebuffer.js +21 -0
  89. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/GLenum.js +298 -0
  90. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/GLmethod.js +142 -0
  91. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/GLtype.js +23 -0
  92. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Program.js +21 -0
  93. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Renderbuffer.js +21 -0
  94. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/RenderingContext.js +1191 -0
  95. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Shader.js +22 -0
  96. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  97. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Texture.js +22 -0
  98. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/UniformLocation.js +22 -0
  99. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/classUtils.js +3 -0
  100. package/ui-fireui/nvue/u-circular-progress/gcanvas/env/canvas.js +74 -0
  101. package/ui-fireui/nvue/u-circular-progress/gcanvas/env/image.js +96 -0
  102. package/ui-fireui/nvue/u-circular-progress/gcanvas/env/tool.js +24 -0
  103. package/ui-fireui/nvue/u-circular-progress/gcanvas/index.js +47 -0
  104. package/ui-fireui/nvue/u-circular-progress/u-circular-progress.nvue +203 -0
  105. package/ui-fireui/nvue/u-icon/icons.js +188 -0
  106. package/ui-fireui/nvue/u-icon/u-icon.vue +78 -0
  107. package/ui-fireui/components/fui-picture-cropper/fui-picture-cropper.wxs +0 -560
  108. package/ui-fireui/components/fui-rate/fui-rate.vue +0 -167
  109. package/ui-fireui/components/fui-sticky-wxs/fui-sticky.wxs +0 -44
  110. /package/ui-fireui/components/{fui-calendar/fui-calendar.js → u-calendar/u-calendar.js} +0 -0
@@ -0,0 +1,1108 @@
1
+ //Core code comes from https://github.com/davidshimjs/qrcodejs
2
+
3
+ var QRCode;
4
+
5
+ (function () {
6
+ /**
7
+ * Get the type by string length
8
+ *
9
+ * @private
10
+ * @param {String} sText
11
+ * @param {Number} nCorrectLevel
12
+ * @return {Number} type
13
+ */
14
+ function _getTypeNumber(sText, nCorrectLevel) {
15
+ var nType = 1;
16
+ var length = _getUTF8Length(sText);
17
+
18
+ for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
19
+ var nLimit = 0;
20
+
21
+ switch (nCorrectLevel) {
22
+ case QRErrorCorrectLevel.L:
23
+ nLimit = QRCodeLimitLength[i][0];
24
+ break;
25
+ case QRErrorCorrectLevel.M:
26
+ nLimit = QRCodeLimitLength[i][1];
27
+ break;
28
+ case QRErrorCorrectLevel.Q:
29
+ nLimit = QRCodeLimitLength[i][2];
30
+ break;
31
+ case QRErrorCorrectLevel.H:
32
+ nLimit = QRCodeLimitLength[i][3];
33
+ break;
34
+ }
35
+
36
+ if (length <= nLimit) {
37
+ break;
38
+ } else {
39
+ nType++;
40
+ }
41
+ }
42
+
43
+ if (nType > QRCodeLimitLength.length) {
44
+ throw new Error('Too long data');
45
+ }
46
+
47
+ return nType;
48
+ }
49
+
50
+ function _getUTF8Length(sText) {
51
+ var replacedText = encodeURI(sText)
52
+ .toString()
53
+ .replace(/\%[0-9a-fA-F]{2}/g, 'a');
54
+ return replacedText.length + (replacedText.length != sText ? 3 : 0);
55
+ }
56
+
57
+ function QR8bitByte(data) {
58
+ this.mode = QRMode.MODE_8BIT_BYTE;
59
+ this.data = data;
60
+ this.parsedData = [];
61
+
62
+ // Added to support UTF-8 Characters
63
+ for (var i = 0, l = this.data.length; i < l; i++) {
64
+ var byteArray = [];
65
+ var code = this.data.charCodeAt(i);
66
+
67
+ if (code > 0x10000) {
68
+ byteArray[0] = 0xf0 | ((code & 0x1c0000) >>> 18);
69
+ byteArray[1] = 0x80 | ((code & 0x3f000) >>> 12);
70
+ byteArray[2] = 0x80 | ((code & 0xfc0) >>> 6);
71
+ byteArray[3] = 0x80 | (code & 0x3f);
72
+ } else if (code > 0x800) {
73
+ byteArray[0] = 0xe0 | ((code & 0xf000) >>> 12);
74
+ byteArray[1] = 0x80 | ((code & 0xfc0) >>> 6);
75
+ byteArray[2] = 0x80 | (code & 0x3f);
76
+ } else if (code > 0x80) {
77
+ byteArray[0] = 0xc0 | ((code & 0x7c0) >>> 6);
78
+ byteArray[1] = 0x80 | (code & 0x3f);
79
+ } else {
80
+ byteArray[0] = code;
81
+ }
82
+
83
+ this.parsedData.push(byteArray);
84
+ }
85
+
86
+ this.parsedData = Array.prototype.concat.apply([], this.parsedData);
87
+
88
+ if (this.parsedData.length != this.data.length) {
89
+ this.parsedData.unshift(191);
90
+ this.parsedData.unshift(187);
91
+ this.parsedData.unshift(239);
92
+ }
93
+ }
94
+
95
+ QR8bitByte.prototype = {
96
+ getLength: function (buffer) {
97
+ return this.parsedData.length;
98
+ },
99
+ write: function (buffer) {
100
+ for (var i = 0, l = this.parsedData.length; i < l; i++) {
101
+ buffer.put(this.parsedData[i], 8);
102
+ }
103
+ }
104
+ };
105
+
106
+ // QRCodeModel
107
+ function QRCodeModel(typeNumber, errorCorrectLevel) {
108
+ this.typeNumber = typeNumber;
109
+ this.errorCorrectLevel = errorCorrectLevel;
110
+ this.modules = null;
111
+ this.moduleCount = 0;
112
+ this.dataCache = null;
113
+ this.dataList = [];
114
+ }
115
+ QRCodeModel.prototype = {
116
+ addData: function (data) {
117
+ var newData = new QR8bitByte(data);
118
+ this.dataList.push(newData);
119
+ this.dataCache = null;
120
+ },
121
+ isDark: function (row, col) {
122
+ if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
123
+ throw new Error(row + ',' + col);
124
+ }
125
+ return this.modules[row][col];
126
+ },
127
+ getModuleCount: function () {
128
+ return this.moduleCount;
129
+ },
130
+ make: function () {
131
+ this.makeImpl(false, this.getBestMaskPattern());
132
+ },
133
+ makeImpl: function (test, maskPattern) {
134
+ this.moduleCount = this.typeNumber * 4 + 17;
135
+ this.modules = new Array(this.moduleCount);
136
+ for (var row = 0; row < this.moduleCount; row++) {
137
+ this.modules[row] = new Array(this.moduleCount);
138
+ for (var col = 0; col < this.moduleCount; col++) {
139
+ this.modules[row][col] = null;
140
+ }
141
+ }
142
+ this.setupPositionProbePattern(0, 0);
143
+ this.setupPositionProbePattern(this.moduleCount - 7, 0);
144
+ this.setupPositionProbePattern(0, this.moduleCount - 7);
145
+ this.setupPositionAdjustPattern();
146
+ this.setupTimingPattern();
147
+ this.setupTypeInfo(test, maskPattern);
148
+ if (this.typeNumber >= 7) {
149
+ this.setupTypeNumber(test);
150
+ }
151
+ if (this.dataCache == null) {
152
+ this.dataCache = QRCodeModel.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
153
+ }
154
+ this.mapData(this.dataCache, maskPattern);
155
+ },
156
+ setupPositionProbePattern: function (row, col) {
157
+ for (var r = -1; r <= 7; r++) {
158
+ if (row + r <= -1 || this.moduleCount <= row + r) continue;
159
+ for (var c = -1; c <= 7; c++) {
160
+ if (col + c <= -1 || this.moduleCount <= col + c) continue;
161
+ if (
162
+ (0 <= r && r <= 6 && (c == 0 || c == 6)) ||
163
+ (0 <= c && c <= 6 && (r == 0 || r == 6)) ||
164
+ (2 <= r && r <= 4 && 2 <= c && c <= 4)
165
+ ) {
166
+ this.modules[row + r][col + c] = true;
167
+ } else {
168
+ this.modules[row + r][col + c] = false;
169
+ }
170
+ }
171
+ }
172
+ },
173
+ getBestMaskPattern: function () {
174
+ var minLostPoint = 0;
175
+ var pattern = 0;
176
+ for (var i = 0; i < 8; i++) {
177
+ this.makeImpl(true, i);
178
+ var lostPoint = QRUtil.getLostPoint(this);
179
+ if (i == 0 || minLostPoint > lostPoint) {
180
+ minLostPoint = lostPoint;
181
+ pattern = i;
182
+ }
183
+ }
184
+ return pattern;
185
+ },
186
+ createMovieClip: function (target_mc, instance_name, depth) {
187
+ var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
188
+ var cs = 1;
189
+ this.make();
190
+ for (var row = 0; row < this.modules.length; row++) {
191
+ var y = row * cs;
192
+ for (var col = 0; col < this.modules[row].length; col++) {
193
+ var x = col * cs;
194
+ var dark = this.modules[row][col];
195
+ if (dark) {
196
+ qr_mc.beginFill(0, 100);
197
+ qr_mc.moveTo(x, y);
198
+ qr_mc.lineTo(x + cs, y);
199
+ qr_mc.lineTo(x + cs, y + cs);
200
+ qr_mc.lineTo(x, y + cs);
201
+ qr_mc.endFill();
202
+ }
203
+ }
204
+ }
205
+ return qr_mc;
206
+ },
207
+ setupTimingPattern: function () {
208
+ for (var r = 8; r < this.moduleCount - 8; r++) {
209
+ if (this.modules[r][6] != null) {
210
+ continue;
211
+ }
212
+ this.modules[r][6] = r % 2 == 0;
213
+ }
214
+ for (var c = 8; c < this.moduleCount - 8; c++) {
215
+ if (this.modules[6][c] != null) {
216
+ continue;
217
+ }
218
+ this.modules[6][c] = c % 2 == 0;
219
+ }
220
+ },
221
+ setupPositionAdjustPattern: function () {
222
+ var pos = QRUtil.getPatternPosition(this.typeNumber);
223
+ for (var i = 0; i < pos.length; i++) {
224
+ for (var j = 0; j < pos.length; j++) {
225
+ var row = pos[i];
226
+ var col = pos[j];
227
+ if (this.modules[row][col] != null) {
228
+ continue;
229
+ }
230
+ for (var r = -2; r <= 2; r++) {
231
+ for (var c = -2; c <= 2; c++) {
232
+ if (r == -2 || r == 2 || c == -2 || c == 2 || (r == 0 && c == 0)) {
233
+ this.modules[row + r][col + c] = true;
234
+ } else {
235
+ this.modules[row + r][col + c] = false;
236
+ }
237
+ }
238
+ }
239
+ }
240
+ }
241
+ },
242
+ setupTypeNumber: function (test) {
243
+ var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
244
+ for (var i = 0; i < 18; i++) {
245
+ var mod = !test && ((bits >> i) & 1) == 1;
246
+ this.modules[Math.floor(i / 3)][(i % 3) + this.moduleCount - 8 - 3] = mod;
247
+ }
248
+ for (var i = 0; i < 18; i++) {
249
+ var mod = !test && ((bits >> i) & 1) == 1;
250
+ this.modules[(i % 3) + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
251
+ }
252
+ },
253
+ setupTypeInfo: function (test, maskPattern) {
254
+ var data = (this.errorCorrectLevel << 3) | maskPattern;
255
+ var bits = QRUtil.getBCHTypeInfo(data);
256
+ for (var i = 0; i < 15; i++) {
257
+ var mod = !test && ((bits >> i) & 1) == 1;
258
+ if (i < 6) {
259
+ this.modules[i][8] = mod;
260
+ } else if (i < 8) {
261
+ this.modules[i + 1][8] = mod;
262
+ } else {
263
+ this.modules[this.moduleCount - 15 + i][8] = mod;
264
+ }
265
+ }
266
+ for (var i = 0; i < 15; i++) {
267
+ var mod = !test && ((bits >> i) & 1) == 1;
268
+ if (i < 8) {
269
+ this.modules[8][this.moduleCount - i - 1] = mod;
270
+ } else if (i < 9) {
271
+ this.modules[8][15 - i - 1 + 1] = mod;
272
+ } else {
273
+ this.modules[8][15 - i - 1] = mod;
274
+ }
275
+ }
276
+ this.modules[this.moduleCount - 8][8] = !test;
277
+ },
278
+ mapData: function (data, maskPattern) {
279
+ var inc = -1;
280
+ var row = this.moduleCount - 1;
281
+ var bitIndex = 7;
282
+ var byteIndex = 0;
283
+ for (var col = this.moduleCount - 1; col > 0; col -= 2) {
284
+ if (col == 6) col--;
285
+ while (true) {
286
+ for (var c = 0; c < 2; c++) {
287
+ if (this.modules[row][col - c] == null) {
288
+ var dark = false;
289
+ if (byteIndex < data.length) {
290
+ dark = ((data[byteIndex] >>> bitIndex) & 1) == 1;
291
+ }
292
+ var mask = QRUtil.getMask(maskPattern, row, col - c);
293
+ if (mask) {
294
+ dark = !dark;
295
+ }
296
+ this.modules[row][col - c] = dark;
297
+ bitIndex--;
298
+ if (bitIndex == -1) {
299
+ byteIndex++;
300
+ bitIndex = 7;
301
+ }
302
+ }
303
+ }
304
+ row += inc;
305
+ if (row < 0 || this.moduleCount <= row) {
306
+ row -= inc;
307
+ inc = -inc;
308
+ break;
309
+ }
310
+ }
311
+ }
312
+ }
313
+ };
314
+ QRCodeModel.PAD0 = 0xec;
315
+ QRCodeModel.PAD1 = 0x11;
316
+ QRCodeModel.createData = function (typeNumber, errorCorrectLevel, dataList) {
317
+ var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
318
+ var buffer = new QRBitBuffer();
319
+ for (var i = 0; i < dataList.length; i++) {
320
+ var data = dataList[i];
321
+ buffer.put(data.mode, 4);
322
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
323
+ data.write(buffer);
324
+ }
325
+ var totalDataCount = 0;
326
+ for (var i = 0; i < rsBlocks.length; i++) {
327
+ totalDataCount += rsBlocks[i].dataCount;
328
+ }
329
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
330
+ throw new Error('code length overflow. (' + buffer.getLengthInBits() + '>' + totalDataCount * 8 + ')');
331
+ }
332
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
333
+ buffer.put(0, 4);
334
+ }
335
+ while (buffer.getLengthInBits() % 8 != 0) {
336
+ buffer.putBit(false);
337
+ }
338
+ while (true) {
339
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
340
+ break;
341
+ }
342
+ buffer.put(QRCodeModel.PAD0, 8);
343
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
344
+ break;
345
+ }
346
+ buffer.put(QRCodeModel.PAD1, 8);
347
+ }
348
+ return QRCodeModel.createBytes(buffer, rsBlocks);
349
+ };
350
+ QRCodeModel.createBytes = function (buffer, rsBlocks) {
351
+ var offset = 0;
352
+ var maxDcCount = 0;
353
+ var maxEcCount = 0;
354
+ var dcdata = new Array(rsBlocks.length);
355
+ var ecdata = new Array(rsBlocks.length);
356
+ for (var r = 0; r < rsBlocks.length; r++) {
357
+ var dcCount = rsBlocks[r].dataCount;
358
+ var ecCount = rsBlocks[r].totalCount - dcCount;
359
+ maxDcCount = Math.max(maxDcCount, dcCount);
360
+ maxEcCount = Math.max(maxEcCount, ecCount);
361
+ dcdata[r] = new Array(dcCount);
362
+ for (var i = 0; i < dcdata[r].length; i++) {
363
+ dcdata[r][i] = 0xff & buffer.buffer[i + offset];
364
+ }
365
+ offset += dcCount;
366
+ var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
367
+ var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
368
+ var modPoly = rawPoly.mod(rsPoly);
369
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
370
+ for (var i = 0; i < ecdata[r].length; i++) {
371
+ var modIndex = i + modPoly.getLength() - ecdata[r].length;
372
+ ecdata[r][i] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
373
+ }
374
+ }
375
+ var totalCodeCount = 0;
376
+ for (var i = 0; i < rsBlocks.length; i++) {
377
+ totalCodeCount += rsBlocks[i].totalCount;
378
+ }
379
+ var data = new Array(totalCodeCount);
380
+ var index = 0;
381
+ for (var i = 0; i < maxDcCount; i++) {
382
+ for (var r = 0; r < rsBlocks.length; r++) {
383
+ if (i < dcdata[r].length) {
384
+ data[index++] = dcdata[r][i];
385
+ }
386
+ }
387
+ }
388
+ for (var i = 0; i < maxEcCount; i++) {
389
+ for (var r = 0; r < rsBlocks.length; r++) {
390
+ if (i < ecdata[r].length) {
391
+ data[index++] = ecdata[r][i];
392
+ }
393
+ }
394
+ }
395
+ return data;
396
+ };
397
+ var QRMode = { MODE_NUMBER: 1 << 0, MODE_ALPHA_NUM: 1 << 1, MODE_8BIT_BYTE: 1 << 2, MODE_KANJI: 1 << 3 };
398
+ var QRErrorCorrectLevel = { L: 1, M: 0, Q: 3, H: 2 };
399
+ var QRMaskPattern = {
400
+ PATTERN000: 0,
401
+ PATTERN001: 1,
402
+ PATTERN010: 2,
403
+ PATTERN011: 3,
404
+ PATTERN100: 4,
405
+ PATTERN101: 5,
406
+ PATTERN110: 6,
407
+ PATTERN111: 7
408
+ };
409
+ var QRUtil = {
410
+ PATTERN_POSITION_TABLE: [
411
+ [],
412
+ [6, 18],
413
+ [6, 22],
414
+ [6, 26],
415
+ [6, 30],
416
+ [6, 34],
417
+ [6, 22, 38],
418
+ [6, 24, 42],
419
+ [6, 26, 46],
420
+ [6, 28, 50],
421
+ [6, 30, 54],
422
+ [6, 32, 58],
423
+ [6, 34, 62],
424
+ [6, 26, 46, 66],
425
+ [6, 26, 48, 70],
426
+ [6, 26, 50, 74],
427
+ [6, 30, 54, 78],
428
+ [6, 30, 56, 82],
429
+ [6, 30, 58, 86],
430
+ [6, 34, 62, 90],
431
+ [6, 28, 50, 72, 94],
432
+ [6, 26, 50, 74, 98],
433
+ [6, 30, 54, 78, 102],
434
+ [6, 28, 54, 80, 106],
435
+ [6, 32, 58, 84, 110],
436
+ [6, 30, 58, 86, 114],
437
+ [6, 34, 62, 90, 118],
438
+ [6, 26, 50, 74, 98, 122],
439
+ [6, 30, 54, 78, 102, 126],
440
+ [6, 26, 52, 78, 104, 130],
441
+ [6, 30, 56, 82, 108, 134],
442
+ [6, 34, 60, 86, 112, 138],
443
+ [6, 30, 58, 86, 114, 142],
444
+ [6, 34, 62, 90, 118, 146],
445
+ [6, 30, 54, 78, 102, 126, 150],
446
+ [6, 24, 50, 76, 102, 128, 154],
447
+ [6, 28, 54, 80, 106, 132, 158],
448
+ [6, 32, 58, 84, 110, 136, 162],
449
+ [6, 26, 54, 82, 110, 138, 166],
450
+ [6, 30, 58, 86, 114, 142, 170]
451
+ ],
452
+ G15: (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0),
453
+ G18: (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0),
454
+ G15_MASK: (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
455
+ getBCHTypeInfo: function (data) {
456
+ var d = data << 10;
457
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
458
+ d ^= QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15));
459
+ }
460
+ return ((data << 10) | d) ^ QRUtil.G15_MASK;
461
+ },
462
+ getBCHTypeNumber: function (data) {
463
+ var d = data << 12;
464
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
465
+ d ^= QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18));
466
+ }
467
+ return (data << 12) | d;
468
+ },
469
+ getBCHDigit: function (data) {
470
+ var digit = 0;
471
+ while (data != 0) {
472
+ digit++;
473
+ data >>>= 1;
474
+ }
475
+ return digit;
476
+ },
477
+ getPatternPosition: function (typeNumber) {
478
+ return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
479
+ },
480
+ getMask: function (maskPattern, i, j) {
481
+ switch (maskPattern) {
482
+ case QRMaskPattern.PATTERN000:
483
+ return (i + j) % 2 == 0;
484
+ case QRMaskPattern.PATTERN001:
485
+ return i % 2 == 0;
486
+ case QRMaskPattern.PATTERN010:
487
+ return j % 3 == 0;
488
+ case QRMaskPattern.PATTERN011:
489
+ return (i + j) % 3 == 0;
490
+ case QRMaskPattern.PATTERN100:
491
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
492
+ case QRMaskPattern.PATTERN101:
493
+ return ((i * j) % 2) + ((i * j) % 3) == 0;
494
+ case QRMaskPattern.PATTERN110:
495
+ return (((i * j) % 2) + ((i * j) % 3)) % 2 == 0;
496
+ case QRMaskPattern.PATTERN111:
497
+ return (((i * j) % 3) + ((i + j) % 2)) % 2 == 0;
498
+ default:
499
+ throw new Error('bad maskPattern:' + maskPattern);
500
+ }
501
+ },
502
+ getErrorCorrectPolynomial: function (errorCorrectLength) {
503
+ var a = new QRPolynomial([1], 0);
504
+ for (var i = 0; i < errorCorrectLength; i++) {
505
+ a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
506
+ }
507
+ return a;
508
+ },
509
+ getLengthInBits: function (mode, type) {
510
+ if (1 <= type && type < 10) {
511
+ switch (mode) {
512
+ case QRMode.MODE_NUMBER:
513
+ return 10;
514
+ case QRMode.MODE_ALPHA_NUM:
515
+ return 9;
516
+ case QRMode.MODE_8BIT_BYTE:
517
+ return 8;
518
+ case QRMode.MODE_KANJI:
519
+ return 8;
520
+ default:
521
+ throw new Error('mode:' + mode);
522
+ }
523
+ } else if (type < 27) {
524
+ switch (mode) {
525
+ case QRMode.MODE_NUMBER:
526
+ return 12;
527
+ case QRMode.MODE_ALPHA_NUM:
528
+ return 11;
529
+ case QRMode.MODE_8BIT_BYTE:
530
+ return 16;
531
+ case QRMode.MODE_KANJI:
532
+ return 10;
533
+ default:
534
+ throw new Error('mode:' + mode);
535
+ }
536
+ } else if (type < 41) {
537
+ switch (mode) {
538
+ case QRMode.MODE_NUMBER:
539
+ return 14;
540
+ case QRMode.MODE_ALPHA_NUM:
541
+ return 13;
542
+ case QRMode.MODE_8BIT_BYTE:
543
+ return 16;
544
+ case QRMode.MODE_KANJI:
545
+ return 12;
546
+ default:
547
+ throw new Error('mode:' + mode);
548
+ }
549
+ } else {
550
+ throw new Error('type:' + type);
551
+ }
552
+ },
553
+ getLostPoint: function (qrCode) {
554
+ var moduleCount = qrCode.getModuleCount();
555
+ var lostPoint = 0;
556
+ for (var row = 0; row < moduleCount; row++) {
557
+ for (var col = 0; col < moduleCount; col++) {
558
+ var sameCount = 0;
559
+ var dark = qrCode.isDark(row, col);
560
+ for (var r = -1; r <= 1; r++) {
561
+ if (row + r < 0 || moduleCount <= row + r) {
562
+ continue;
563
+ }
564
+ for (var c = -1; c <= 1; c++) {
565
+ if (col + c < 0 || moduleCount <= col + c) {
566
+ continue;
567
+ }
568
+ if (r == 0 && c == 0) {
569
+ continue;
570
+ }
571
+ if (dark == qrCode.isDark(row + r, col + c)) {
572
+ sameCount++;
573
+ }
574
+ }
575
+ }
576
+ if (sameCount > 5) {
577
+ lostPoint += 3 + sameCount - 5;
578
+ }
579
+ }
580
+ }
581
+ for (var row = 0; row < moduleCount - 1; row++) {
582
+ for (var col = 0; col < moduleCount - 1; col++) {
583
+ var count = 0;
584
+ if (qrCode.isDark(row, col)) count++;
585
+ if (qrCode.isDark(row + 1, col)) count++;
586
+ if (qrCode.isDark(row, col + 1)) count++;
587
+ if (qrCode.isDark(row + 1, col + 1)) count++;
588
+ if (count == 0 || count == 4) {
589
+ lostPoint += 3;
590
+ }
591
+ }
592
+ }
593
+ for (var row = 0; row < moduleCount; row++) {
594
+ for (var col = 0; col < moduleCount - 6; col++) {
595
+ if (
596
+ qrCode.isDark(row, col) &&
597
+ !qrCode.isDark(row, col + 1) &&
598
+ qrCode.isDark(row, col + 2) &&
599
+ qrCode.isDark(row, col + 3) &&
600
+ qrCode.isDark(row, col + 4) &&
601
+ !qrCode.isDark(row, col + 5) &&
602
+ qrCode.isDark(row, col + 6)
603
+ ) {
604
+ lostPoint += 40;
605
+ }
606
+ }
607
+ }
608
+ for (var col = 0; col < moduleCount; col++) {
609
+ for (var row = 0; row < moduleCount - 6; row++) {
610
+ if (
611
+ qrCode.isDark(row, col) &&
612
+ !qrCode.isDark(row + 1, col) &&
613
+ qrCode.isDark(row + 2, col) &&
614
+ qrCode.isDark(row + 3, col) &&
615
+ qrCode.isDark(row + 4, col) &&
616
+ !qrCode.isDark(row + 5, col) &&
617
+ qrCode.isDark(row + 6, col)
618
+ ) {
619
+ lostPoint += 40;
620
+ }
621
+ }
622
+ }
623
+ var darkCount = 0;
624
+ for (var col = 0; col < moduleCount; col++) {
625
+ for (var row = 0; row < moduleCount; row++) {
626
+ if (qrCode.isDark(row, col)) {
627
+ darkCount++;
628
+ }
629
+ }
630
+ }
631
+ var ratio = Math.abs((100 * darkCount) / moduleCount / moduleCount - 50) / 5;
632
+ lostPoint += ratio * 10;
633
+ return lostPoint;
634
+ }
635
+ };
636
+ var QRMath = {
637
+ glog: function (n) {
638
+ if (n < 1) {
639
+ throw new Error('glog(' + n + ')');
640
+ }
641
+ return QRMath.LOG_TABLE[n];
642
+ },
643
+ gexp: function (n) {
644
+ while (n < 0) {
645
+ n += 255;
646
+ }
647
+ while (n >= 256) {
648
+ n -= 255;
649
+ }
650
+ return QRMath.EXP_TABLE[n];
651
+ },
652
+ EXP_TABLE: new Array(256),
653
+ LOG_TABLE: new Array(256)
654
+ };
655
+ for (var i = 0; i < 8; i++) {
656
+ QRMath.EXP_TABLE[i] = 1 << i;
657
+ }
658
+ for (var i = 8; i < 256; i++) {
659
+ QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
660
+ }
661
+ for (var i = 0; i < 255; i++) {
662
+ QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
663
+ }
664
+ function QRPolynomial(num, shift) {
665
+ if (num.length == undefined) {
666
+ throw new Error(num.length + '/' + shift);
667
+ }
668
+ var offset = 0;
669
+ while (offset < num.length && num[offset] == 0) {
670
+ offset++;
671
+ }
672
+ this.num = new Array(num.length - offset + shift);
673
+ for (var i = 0; i < num.length - offset; i++) {
674
+ this.num[i] = num[i + offset];
675
+ }
676
+ }
677
+ QRPolynomial.prototype = {
678
+ get: function (index) {
679
+ return this.num[index];
680
+ },
681
+ getLength: function () {
682
+ return this.num.length;
683
+ },
684
+ multiply: function (e) {
685
+ var num = new Array(this.getLength() + e.getLength() - 1);
686
+ for (var i = 0; i < this.getLength(); i++) {
687
+ for (var j = 0; j < e.getLength(); j++) {
688
+ num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
689
+ }
690
+ }
691
+ return new QRPolynomial(num, 0);
692
+ },
693
+ mod: function (e) {
694
+ if (this.getLength() - e.getLength() < 0) {
695
+ return this;
696
+ }
697
+ var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0));
698
+ var num = new Array(this.getLength());
699
+ for (var i = 0; i < this.getLength(); i++) {
700
+ num[i] = this.get(i);
701
+ }
702
+ for (var i = 0; i < e.getLength(); i++) {
703
+ num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio);
704
+ }
705
+ return new QRPolynomial(num, 0).mod(e);
706
+ }
707
+ };
708
+ function QRRSBlock(totalCount, dataCount) {
709
+ this.totalCount = totalCount;
710
+ this.dataCount = dataCount;
711
+ }
712
+ QRRSBlock.RS_BLOCK_TABLE = [
713
+ [1, 26, 19],
714
+ [1, 26, 16],
715
+ [1, 26, 13],
716
+ [1, 26, 9],
717
+ [1, 44, 34],
718
+ [1, 44, 28],
719
+ [1, 44, 22],
720
+ [1, 44, 16],
721
+ [1, 70, 55],
722
+ [1, 70, 44],
723
+ [2, 35, 17],
724
+ [2, 35, 13],
725
+ [1, 100, 80],
726
+ [2, 50, 32],
727
+ [2, 50, 24],
728
+ [4, 25, 9],
729
+ [1, 134, 108],
730
+ [2, 67, 43],
731
+ [2, 33, 15, 2, 34, 16],
732
+ [2, 33, 11, 2, 34, 12],
733
+ [2, 86, 68],
734
+ [4, 43, 27],
735
+ [4, 43, 19],
736
+ [4, 43, 15],
737
+ [2, 98, 78],
738
+ [4, 49, 31],
739
+ [2, 32, 14, 4, 33, 15],
740
+ [4, 39, 13, 1, 40, 14],
741
+ [2, 121, 97],
742
+ [2, 60, 38, 2, 61, 39],
743
+ [4, 40, 18, 2, 41, 19],
744
+ [4, 40, 14, 2, 41, 15],
745
+ [2, 146, 116],
746
+ [3, 58, 36, 2, 59, 37],
747
+ [4, 36, 16, 4, 37, 17],
748
+ [4, 36, 12, 4, 37, 13],
749
+ [2, 86, 68, 2, 87, 69],
750
+ [4, 69, 43, 1, 70, 44],
751
+ [6, 43, 19, 2, 44, 20],
752
+ [6, 43, 15, 2, 44, 16],
753
+ [4, 101, 81],
754
+ [1, 80, 50, 4, 81, 51],
755
+ [4, 50, 22, 4, 51, 23],
756
+ [3, 36, 12, 8, 37, 13],
757
+ [2, 116, 92, 2, 117, 93],
758
+ [6, 58, 36, 2, 59, 37],
759
+ [4, 46, 20, 6, 47, 21],
760
+ [7, 42, 14, 4, 43, 15],
761
+ [4, 133, 107],
762
+ [8, 59, 37, 1, 60, 38],
763
+ [8, 44, 20, 4, 45, 21],
764
+ [12, 33, 11, 4, 34, 12],
765
+ [3, 145, 115, 1, 146, 116],
766
+ [4, 64, 40, 5, 65, 41],
767
+ [11, 36, 16, 5, 37, 17],
768
+ [11, 36, 12, 5, 37, 13],
769
+ [5, 109, 87, 1, 110, 88],
770
+ [5, 65, 41, 5, 66, 42],
771
+ [5, 54, 24, 7, 55, 25],
772
+ [11, 36, 12],
773
+ [5, 122, 98, 1, 123, 99],
774
+ [7, 73, 45, 3, 74, 46],
775
+ [15, 43, 19, 2, 44, 20],
776
+ [3, 45, 15, 13, 46, 16],
777
+ [1, 135, 107, 5, 136, 108],
778
+ [10, 74, 46, 1, 75, 47],
779
+ [1, 50, 22, 15, 51, 23],
780
+ [2, 42, 14, 17, 43, 15],
781
+ [5, 150, 120, 1, 151, 121],
782
+ [9, 69, 43, 4, 70, 44],
783
+ [17, 50, 22, 1, 51, 23],
784
+ [2, 42, 14, 19, 43, 15],
785
+ [3, 141, 113, 4, 142, 114],
786
+ [3, 70, 44, 11, 71, 45],
787
+ [17, 47, 21, 4, 48, 22],
788
+ [9, 39, 13, 16, 40, 14],
789
+ [3, 135, 107, 5, 136, 108],
790
+ [3, 67, 41, 13, 68, 42],
791
+ [15, 54, 24, 5, 55, 25],
792
+ [15, 43, 15, 10, 44, 16],
793
+ [4, 144, 116, 4, 145, 117],
794
+ [17, 68, 42],
795
+ [17, 50, 22, 6, 51, 23],
796
+ [19, 46, 16, 6, 47, 17],
797
+ [2, 139, 111, 7, 140, 112],
798
+ [17, 74, 46],
799
+ [7, 54, 24, 16, 55, 25],
800
+ [34, 37, 13],
801
+ [4, 151, 121, 5, 152, 122],
802
+ [4, 75, 47, 14, 76, 48],
803
+ [11, 54, 24, 14, 55, 25],
804
+ [16, 45, 15, 14, 46, 16],
805
+ [6, 147, 117, 4, 148, 118],
806
+ [6, 73, 45, 14, 74, 46],
807
+ [11, 54, 24, 16, 55, 25],
808
+ [30, 46, 16, 2, 47, 17],
809
+ [8, 132, 106, 4, 133, 107],
810
+ [8, 75, 47, 13, 76, 48],
811
+ [7, 54, 24, 22, 55, 25],
812
+ [22, 45, 15, 13, 46, 16],
813
+ [10, 142, 114, 2, 143, 115],
814
+ [19, 74, 46, 4, 75, 47],
815
+ [28, 50, 22, 6, 51, 23],
816
+ [33, 46, 16, 4, 47, 17],
817
+ [8, 152, 122, 4, 153, 123],
818
+ [22, 73, 45, 3, 74, 46],
819
+ [8, 53, 23, 26, 54, 24],
820
+ [12, 45, 15, 28, 46, 16],
821
+ [3, 147, 117, 10, 148, 118],
822
+ [3, 73, 45, 23, 74, 46],
823
+ [4, 54, 24, 31, 55, 25],
824
+ [11, 45, 15, 31, 46, 16],
825
+ [7, 146, 116, 7, 147, 117],
826
+ [21, 73, 45, 7, 74, 46],
827
+ [1, 53, 23, 37, 54, 24],
828
+ [19, 45, 15, 26, 46, 16],
829
+ [5, 145, 115, 10, 146, 116],
830
+ [19, 75, 47, 10, 76, 48],
831
+ [15, 54, 24, 25, 55, 25],
832
+ [23, 45, 15, 25, 46, 16],
833
+ [13, 145, 115, 3, 146, 116],
834
+ [2, 74, 46, 29, 75, 47],
835
+ [42, 54, 24, 1, 55, 25],
836
+ [23, 45, 15, 28, 46, 16],
837
+ [17, 145, 115],
838
+ [10, 74, 46, 23, 75, 47],
839
+ [10, 54, 24, 35, 55, 25],
840
+ [19, 45, 15, 35, 46, 16],
841
+ [17, 145, 115, 1, 146, 116],
842
+ [14, 74, 46, 21, 75, 47],
843
+ [29, 54, 24, 19, 55, 25],
844
+ [11, 45, 15, 46, 46, 16],
845
+ [13, 145, 115, 6, 146, 116],
846
+ [14, 74, 46, 23, 75, 47],
847
+ [44, 54, 24, 7, 55, 25],
848
+ [59, 46, 16, 1, 47, 17],
849
+ [12, 151, 121, 7, 152, 122],
850
+ [12, 75, 47, 26, 76, 48],
851
+ [39, 54, 24, 14, 55, 25],
852
+ [22, 45, 15, 41, 46, 16],
853
+ [6, 151, 121, 14, 152, 122],
854
+ [6, 75, 47, 34, 76, 48],
855
+ [46, 54, 24, 10, 55, 25],
856
+ [2, 45, 15, 64, 46, 16],
857
+ [17, 152, 122, 4, 153, 123],
858
+ [29, 74, 46, 14, 75, 47],
859
+ [49, 54, 24, 10, 55, 25],
860
+ [24, 45, 15, 46, 46, 16],
861
+ [4, 152, 122, 18, 153, 123],
862
+ [13, 74, 46, 32, 75, 47],
863
+ [48, 54, 24, 14, 55, 25],
864
+ [42, 45, 15, 32, 46, 16],
865
+ [20, 147, 117, 4, 148, 118],
866
+ [40, 75, 47, 7, 76, 48],
867
+ [43, 54, 24, 22, 55, 25],
868
+ [10, 45, 15, 67, 46, 16],
869
+ [19, 148, 118, 6, 149, 119],
870
+ [18, 75, 47, 31, 76, 48],
871
+ [34, 54, 24, 34, 55, 25],
872
+ [20, 45, 15, 61, 46, 16]
873
+ ];
874
+ QRRSBlock.getRSBlocks = function (typeNumber, errorCorrectLevel) {
875
+ var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
876
+ if (rsBlock == undefined) {
877
+ throw new Error('bad rs block @ typeNumber:' + typeNumber + '/errorCorrectLevel:' + errorCorrectLevel);
878
+ }
879
+ var length = rsBlock.length / 3;
880
+ var list = [];
881
+ for (var i = 0; i < length; i++) {
882
+ var count = rsBlock[i * 3 + 0];
883
+ var totalCount = rsBlock[i * 3 + 1];
884
+ var dataCount = rsBlock[i * 3 + 2];
885
+ for (var j = 0; j < count; j++) {
886
+ list.push(new QRRSBlock(totalCount, dataCount));
887
+ }
888
+ }
889
+ return list;
890
+ };
891
+ QRRSBlock.getRsBlockTable = function (typeNumber, errorCorrectLevel) {
892
+ switch (errorCorrectLevel) {
893
+ case QRErrorCorrectLevel.L:
894
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
895
+ case QRErrorCorrectLevel.M:
896
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
897
+ case QRErrorCorrectLevel.Q:
898
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
899
+ case QRErrorCorrectLevel.H:
900
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
901
+ default:
902
+ return undefined;
903
+ }
904
+ };
905
+ function QRBitBuffer() {
906
+ this.buffer = [];
907
+ this.length = 0;
908
+ }
909
+ QRBitBuffer.prototype = {
910
+ get: function (index) {
911
+ var bufIndex = Math.floor(index / 8);
912
+ return ((this.buffer[bufIndex] >>> (7 - (index % 8))) & 1) == 1;
913
+ },
914
+ put: function (num, length) {
915
+ for (var i = 0; i < length; i++) {
916
+ this.putBit(((num >>> (length - i - 1)) & 1) == 1);
917
+ }
918
+ },
919
+ getLengthInBits: function () {
920
+ return this.length;
921
+ },
922
+ putBit: function (bit) {
923
+ var bufIndex = Math.floor(this.length / 8);
924
+ if (this.buffer.length <= bufIndex) {
925
+ this.buffer.push(0);
926
+ }
927
+ if (bit) {
928
+ this.buffer[bufIndex] |= 0x80 >>> this.length % 8;
929
+ }
930
+ this.length++;
931
+ }
932
+ };
933
+ var QRCodeLimitLength = [
934
+ [17, 14, 11, 7],
935
+ [32, 26, 20, 14],
936
+ [53, 42, 32, 24],
937
+ [78, 62, 46, 34],
938
+ [106, 84, 60, 44],
939
+ [134, 106, 74, 58],
940
+ [154, 122, 86, 64],
941
+ [192, 152, 108, 84],
942
+ [230, 180, 130, 98],
943
+ [271, 213, 151, 119],
944
+ [321, 251, 177, 137],
945
+ [367, 287, 203, 155],
946
+ [425, 331, 241, 177],
947
+ [458, 362, 258, 194],
948
+ [520, 412, 292, 220],
949
+ [586, 450, 322, 250],
950
+ [644, 504, 364, 280],
951
+ [718, 560, 394, 310],
952
+ [792, 624, 442, 338],
953
+ [858, 666, 482, 382],
954
+ [929, 711, 509, 403],
955
+ [1003, 779, 565, 439],
956
+ [1091, 857, 611, 461],
957
+ [1171, 911, 661, 511],
958
+ [1273, 997, 715, 535],
959
+ [1367, 1059, 751, 593],
960
+ [1465, 1125, 805, 625],
961
+ [1528, 1190, 868, 658],
962
+ [1628, 1264, 908, 698],
963
+ [1732, 1370, 982, 742],
964
+ [1840, 1452, 1030, 790],
965
+ [1952, 1538, 1112, 842],
966
+ [2068, 1628, 1168, 898],
967
+ [2188, 1722, 1228, 958],
968
+ [2303, 1809, 1283, 983],
969
+ [2431, 1911, 1351, 1051],
970
+ [2563, 1989, 1423, 1093],
971
+ [2699, 2099, 1499, 1139],
972
+ [2809, 2213, 1579, 1219],
973
+ [2953, 2331, 1663, 1273]
974
+ ];
975
+
976
+ // QRCode object
977
+ QRCode = function (canvasId, vOption) {
978
+ this._htOption = {
979
+ width: 256,
980
+ height: 256,
981
+ typeNumber: 4,
982
+ colorDark: '#000000',
983
+ colorLight: '#ffffff',
984
+ correctLevel: QRErrorCorrectLevel.H
985
+ };
986
+
987
+ if (typeof vOption === 'string') {
988
+ vOption = {
989
+ text: vOption
990
+ };
991
+ }
992
+
993
+ // Overwrites options
994
+ if (vOption) {
995
+ for (var i in vOption) {
996
+ this._htOption[i] = vOption[i];
997
+ }
998
+ }
999
+
1000
+ this._oQRCode = null;
1001
+ this.canvasId = canvasId;
1002
+
1003
+ if (this._htOption.text && this.canvasId) {
1004
+ this.makeCode(this._htOption.text);
1005
+ }
1006
+ };
1007
+
1008
+ QRCode.prototype.makeCode = function (sText) {
1009
+ this._oQRCode = new QRCodeModel(_getTypeNumber(sText, this._htOption.correctLevel), this._htOption.correctLevel);
1010
+ this._oQRCode.addData(sText);
1011
+ this._oQRCode.make();
1012
+ this.makeImage();
1013
+ };
1014
+
1015
+ QRCode.prototype.makeImage = function () {
1016
+ var _oContext;
1017
+ if (this._htOption.usingIn) {
1018
+ _oContext = wx.createCanvasContext(this.canvasId, this._htOption.usingIn);
1019
+ } else {
1020
+ _oContext = wx.createCanvasContext(this.canvasId);
1021
+ }
1022
+ var _htOption = this._htOption;
1023
+ var oQRCode = this._oQRCode;
1024
+
1025
+ var nCount = oQRCode.getModuleCount();
1026
+ var nWidth = _htOption.width / nCount;
1027
+ var nHeight = _htOption.height / nCount;
1028
+ var nRoundedWidth = Math.round(nWidth);
1029
+ var nRoundedHeight = Math.round(nHeight);
1030
+
1031
+ if (_htOption.image && _htOption.image != '') {
1032
+ _oContext.drawImage(_htOption.image, 0, 0, _htOption.width, _htOption.height);
1033
+ }
1034
+
1035
+ for (var row = 0; row < nCount; row++) {
1036
+ for (var col = 0; col < nCount; col++) {
1037
+ var bIsDark = oQRCode.isDark(row, col);
1038
+ var nLeft = col * nWidth;
1039
+ var nTop = row * nHeight;
1040
+ _oContext.setStrokeStyle(bIsDark ? _htOption.colorDark : _htOption.colorLight);
1041
+ // _oContext.setStrokeStyle('yellow')
1042
+ _oContext.setLineWidth(1);
1043
+ _oContext.setFillStyle(bIsDark ? _htOption.colorDark : _htOption.colorLight);
1044
+ // _oContext.setFillStyle('red')
1045
+ // if (bIsDark) {
1046
+ _oContext.fillRect(nLeft, nTop, nWidth, nHeight);
1047
+ // }
1048
+
1049
+ // 안티 앨리어싱 방지 처리
1050
+ // if (bIsDark) {
1051
+ _oContext.strokeRect(Math.floor(nLeft) + 0.5, Math.floor(nTop) + 0.5, nRoundedWidth, nRoundedHeight);
1052
+
1053
+ _oContext.strokeRect(Math.ceil(nLeft) - 0.5, Math.ceil(nTop) - 0.5, nRoundedWidth, nRoundedHeight);
1054
+ // }
1055
+ // _oContext.fillRect(
1056
+ // Math.floor(nLeft) + 0.5,
1057
+ // Math.floor(nTop) + 0.5,
1058
+ // nRoundedWidth,
1059
+ // nRoundedHeight
1060
+ // );
1061
+ // _oContext.fillRect(
1062
+ // Math.ceil(nLeft) - 0.5,
1063
+ // Math.ceil(nTop) - 0.5,
1064
+ // nRoundedWidth,
1065
+ // nRoundedHeight
1066
+ // );
1067
+ // _oContext.clearRect(
1068
+ // Math.floor(nLeft) + 0.5,
1069
+ // Math.floor(nTop) + 0.5,
1070
+ // nRoundedWidth,
1071
+ // nRoundedHeight
1072
+ // );
1073
+ // _oContext.clearRect(
1074
+ // Math.ceil(nLeft) - 0.5,
1075
+ // Math.ceil(nTop) - 0.5,
1076
+ // nRoundedWidth,
1077
+ // nRoundedHeight
1078
+ // );
1079
+ }
1080
+ }
1081
+
1082
+ _oContext.draw();
1083
+ };
1084
+
1085
+ // 保存为图片,将临时路径传给回调
1086
+ QRCode.prototype.exportImage = function (callback) {
1087
+ if (!callback) {
1088
+ return;
1089
+ }
1090
+ wx.canvasToTempFilePath({
1091
+ x: 0,
1092
+ y: 0,
1093
+ width: this._htOption.width,
1094
+ height: this._htOption.height,
1095
+ destWidth: this._htOption.width,
1096
+ destHeight: this._htOption.height,
1097
+ canvasId: this.canvasId,
1098
+ success: function (res) {
1099
+ console.log(res.tempFilePath);
1100
+ callback(res.tempFilePath);
1101
+ }
1102
+ });
1103
+ };
1104
+
1105
+ QRCode.CorrectLevel = QRErrorCorrectLevel;
1106
+ })();
1107
+
1108
+ module.exports = QRCode;