react_hsbc_teller 2.0.3 → 2.0.4-6.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 (46) hide show
  1. package/lib/hsbc.js +1 -1
  2. package/lib/hsbc.js.LICENSE.txt +11 -0
  3. package/package.json +2 -1
  4. package/packages/api/api.js +267 -2
  5. package/packages/assets/img/icon_asr.png +0 -0
  6. package/packages/assets/img/icon_env.png +0 -0
  7. package/packages/assets/img/icon_fail.jpg +0 -0
  8. package/packages/assets/img/icon_paper.png +0 -0
  9. package/packages/assets/img/icon_success.jpg +0 -0
  10. package/packages/assets/mp3/ipad_join_meeting.mp3 +0 -0
  11. package/packages/assets/mp3/ipad_leave_error.mp3 +0 -0
  12. package/packages/assets/mp3/ipad_leave_meeting.mp3 +0 -0
  13. package/packages/assets/mp3/ipad_low_power.mp3 +0 -0
  14. package/packages/assets/mp3/networkweak.mp3 +0 -0
  15. package/packages/assets/mp3/pip_close.mp3 +0 -0
  16. package/packages/assets/mp3/record_error.mp3 +0 -0
  17. package/packages/demo/demo.js +52 -18
  18. package/packages/demo/pdf.js +16 -1
  19. package/packages/pages/foot/foot.jsx +29 -6
  20. package/packages/pages/foot/foot.less +1 -0
  21. package/packages/pages/header/header.jsx +1 -1
  22. package/packages/pages/multiModule/components/copy/agree.jsx +115 -0
  23. package/packages/pages/multiModule/components/copy/agree.less +105 -0
  24. package/packages/pages/multiModule/components/copy/copyTwo.jsx +666 -0
  25. package/packages/pages/multiModule/components/copy/copyTwo.less +180 -0
  26. package/packages/pages/multiModule/components/copy/copy_en.jsx +368 -0
  27. package/packages/pages/multiModule/components/copy/copy_en.less +145 -0
  28. package/packages/pages/multiModule/components/copy/copylist.jsx +291 -0
  29. package/packages/pages/multiModule/components/copy/copylist.less +83 -0
  30. package/packages/pages/multiModule/components/copy/risk.jsx +296 -0
  31. package/packages/pages/multiModule/components/copy/risk.less +123 -0
  32. package/packages/pages/multiModule/components/sign/signMy.jsx +308 -0
  33. package/packages/pages/multiModule/components/sign/signMy.less +128 -0
  34. package/packages/pages/multiModule/components/subscribe/subscribe.jsx +113 -0
  35. package/packages/pages/multiModule/components/subscribe/subscribe.less +82 -0
  36. package/packages/pages/multiModule/multiModule.jsx +26 -0
  37. package/packages/pages/multiModule/multiModule.less +20 -0
  38. package/packages/pages/sign/signMy.jsx +2 -0
  39. package/packages/pages/video/video.jsx +2351 -730
  40. package/packages/pages/video/video.less +92 -2
  41. package/packages/utils/asrController.js +246 -0
  42. package/packages/utils/utils.js +122 -0
  43. package/packages/common/JKL.js +0 -61
  44. package/packages/common/XML.js +0 -271
  45. package/packages/common/websocket.js +0 -267
  46. package/packages/utils/cell.js +0 -64
@@ -0,0 +1,666 @@
1
+ import React, { Component } from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import './copyTwo.less'
4
+ import Modal from "antd/lib/modal";
5
+ import 'antd/lib/modal/style'
6
+ import { Button } from '../../../../../node_modules/antd/lib/index';
7
+ class Copy extends Component {
8
+ signCanvas = React.createRef();
9
+ timer = null;
10
+ state = {
11
+ finalImage: "",
12
+ pics: [],
13
+ isFinish: false,
14
+ ctx: null,
15
+ stageInfo: '',
16
+ isDown: false,
17
+ startY: '',
18
+ startX: '',
19
+ moveX: '',
20
+ moveY: '',
21
+ mask1: false,
22
+ mask2: true,
23
+ imgWidth: '0px',
24
+ imgHeight: '0px',
25
+ isModalVisibleEnd: false,
26
+ isModalVisibleSubmit: false,
27
+ isSignOk: false
28
+ };
29
+ componentWillUnmount() {
30
+ clearTimeout(this.timer)
31
+ const canvas = this.refs.canvas1;
32
+ const canvas2 = this.refs.canvas2;
33
+ canvas.removeEventListener('touchstart', this.touchStart);
34
+ canvas.removeEventListener('touchmove', this.touchMove);
35
+ canvas.removeEventListener('touchend', this.touchEnd);
36
+ canvas2.removeEventListener('touchstart', this.touchStart);
37
+ canvas2.removeEventListener('touchmove', this.touchMove);
38
+ canvas2.removeEventListener('touchend', this.touchEnd);
39
+ }
40
+ componentDidMount() {
41
+ setTimeout(() => {
42
+ let canvas = this.refs.canvas1;
43
+ canvas.height = this.refs.canvasHW.offsetHeight - 0;
44
+ canvas.width = this.refs.canvasHW.offsetWidth - 0;
45
+ this.state.ctx = canvas.getContext('2d');
46
+ this.state.stageInfo = canvas.getBoundingClientRect();
47
+ this.state.ctx.lineWidth = 7;
48
+ this.state.ctx.lineCap = "round";
49
+
50
+ let canvas2 = this.refs.canvas2;
51
+ canvas2.height = this.refs.canvasHW2.offsetHeight - 0;
52
+ canvas2.width = this.refs.canvasHW2.offsetWidth - 0;
53
+ this.state.ctx2 = canvas2.getContext('2d');
54
+ this.state.ctx2.lineWidth = 7;
55
+ this.state.ctx2.lineCap = "round";
56
+ this.state.stageInfo2 = canvas2.getBoundingClientRect();
57
+ this.state.isSignOk = false
58
+ this.drawText()
59
+ this.drawText(1)
60
+
61
+ canvas.addEventListener('touchstart', this.touchStart, { passive: false });
62
+ canvas.addEventListener('touchmove', this.touchMove, { passive: false });
63
+ canvas.addEventListener('touchend', this.touchEnd, { passive: false });
64
+ canvas2.addEventListener('touchstart', this.touchStart, { passive: false });
65
+ canvas2.addEventListener('touchmove', this.touchMove, { passive: false });
66
+ canvas2.addEventListener('touchend', this.touchEnd, { passive: false });
67
+ }, 20);
68
+ var box=document.getElementById("imgLeft");
69
+ if(box){ //此处在加一层判断,更加严密,如果box存在的情况下获取
70
+ this.state.imgWidth = Math.round(Math.sqrt((box.offsetWidth * box.offsetHeight)/70)*10)/10
71
+ this.state.imgHeight = Math.round(Math.sqrt((box.offsetWidth * box.offsetHeight)/70)*10)/10
72
+ }
73
+ }
74
+ // 画背景字
75
+ drawText = (num=0) => {
76
+ if (num==0){
77
+ this.setState({mask2: true, mask1: false})
78
+ } else {
79
+ if (this.state.lastCanvasId === 'canvas2' || (!this.state.lastCanvasId && num ===1)){
80
+ this.setState({mask2: true, mask1: false})
81
+ } else {
82
+ this.setState({mask2: false, mask1: true})
83
+ }
84
+ }
85
+ if (this.state.pics.length + num >= this.props.item.subContent[0].desc.length) return;
86
+ let { ctx } = this.state;
87
+ let canvas = this.refs.canvas1;
88
+ if (this.state.lastCanvasId === 'canvas2' || (!this.state.lastCanvasId && num ===1)) {
89
+ ctx = this.state.ctx2;
90
+ canvas = this.refs.canvas2;
91
+ }
92
+ ctx.font = canvas.width/1.5 + 'px "微软雅黑"';
93
+ ctx.fillStyle = "#DADADA";
94
+ ctx.textAlign = "center";
95
+ ctx.textBaseline = "middle";
96
+ ctx.fillText(this.props.item.subContent[0].desc[this.state.pics.length + num], canvas.width/2, canvas.height/2);
97
+
98
+ }
99
+
100
+ // 清空画布
101
+ clearCanvas = () => {
102
+ clearTimeout(this.timer)
103
+ let canvas = this.refs.canvas1;
104
+ // 清除画布
105
+ this.state.ctx.clearRect(
106
+ 0,
107
+ 0,
108
+ canvas.width,
109
+ canvas.height,
110
+ );
111
+ let canvas2 = this.refs.canvas2;
112
+ // 清除画布2
113
+ this.state.ctx2.clearRect(
114
+ 0,
115
+ 0,
116
+ canvas2.width,
117
+ canvas2.height,
118
+ );
119
+ this.state.curCanvasId = ''
120
+ this.state.lastCanvasId = ''
121
+ this.drawText()
122
+ this.drawText(1)
123
+ }
124
+ resetTimer = () => {
125
+ clearTimeout(this.timer);
126
+ const curCanvasId = this.state.curCanvasId;
127
+ const ctx = curCanvasId ==='canvas1'?this.state.ctx : this.state.ctx2
128
+ this.timer = setTimeout(() => {
129
+ // 保存另一张图
130
+ if (this.state.curCanvasId) {
131
+ // 新增图片
132
+ this.state.pics.push(this.filterImgData(this.refs[curCanvasId]).toDataURL());
133
+ this.setState({
134
+ pics: this.state.pics
135
+ })
136
+ // 清除画布
137
+ ctx.clearRect(
138
+ 0,
139
+ 0,
140
+ this.refs[this.state.curCanvasId].width,
141
+ this.refs[this.state.curCanvasId].height,
142
+ );
143
+ }
144
+ this.state.lastCanvasId = this.state.curCanvasId
145
+ this.state.curCanvasId = '';
146
+ this.drawText(1)
147
+ }, 1000);
148
+ }
149
+ touchStart=(ev)=> {
150
+ this.state.isSignOk = true
151
+ ev = ev || event
152
+ ev.preventDefault()
153
+ if (ev.touches.length == 1) {
154
+ let obj = {
155
+ x: ev.targetTouches[0].clientX,
156
+ y: ev.targetTouches[0].clientY,
157
+ }
158
+ if (ev.target.id !== this.state.curCanvasId) {
159
+ let curCanvasId = this.state.curCanvasId;
160
+ if (curCanvasId) {
161
+ clearTimeout(this.timer)
162
+ // console.log(this.refs[this.state.curCanvasId].toDataURL()); // 签名img回传后台
163
+ // 新增图片
164
+ this.state.pics.push(this.filterImgData(this.refs[curCanvasId]).toDataURL());
165
+ this.setState({
166
+ pics: this.state.pics
167
+ })
168
+ const $div = document.getElementById('imgLeft');
169
+ $div.scrollTop = $div.scrollHeight;
170
+ // 清除画布
171
+ const ctx = curCanvasId === 'canvas1' ? this.state.ctx : this.state.ctx2;
172
+ ctx.clearRect(
173
+ 0,
174
+ 0,
175
+ this.refs[curCanvasId].width,
176
+ this.refs[curCanvasId].height,
177
+ );
178
+ }
179
+ this.state.lastCanvasId = this.state.curCanvasId
180
+ this.state.curCanvasId = ev.target.id;
181
+ if (curCanvasId) this.drawText(1)
182
+ }
183
+ let { ctx } = this.state;
184
+ let canvas = this.refs.canvas1;
185
+ if (ev.target.id === 'canvas2') {
186
+ ctx = this.state.ctx2;
187
+ canvas = this.refs.canvas2;
188
+ }
189
+
190
+ this.state.startX = obj.x;
191
+ this.state.startY = obj.y;
192
+ ctx.beginPath();
193
+ ctx.moveTo(this.state.startX - canvas.getBoundingClientRect().left, this.state.startY - canvas.getBoundingClientRect().top);
194
+ ctx.lineTo(obj.x - canvas.getBoundingClientRect().left, obj.y - canvas.getBoundingClientRect().top);
195
+ ctx.stroke();
196
+ ctx.closePath();
197
+ this.state.isDown = true;
198
+
199
+ if (this.state.pics.length + 1 >= this.props.item.subContent[0].desc.length) return
200
+ if(ev.target.id === 'canvas1'){
201
+ this.setState({mask2: false})
202
+ } else {
203
+ this.setState({mask1: false})
204
+ }
205
+
206
+ // this.resetTimer();
207
+
208
+ }
209
+ }
210
+ touchMove=(ev)=>{
211
+ ev = ev || event
212
+ ev.preventDefault()
213
+ if (ev.touches.length == 1) {
214
+ let obj = {
215
+ x: ev.targetTouches[0].clientX,
216
+ y: ev.targetTouches[0].clientY
217
+ }
218
+ if (this.state.isDown) {
219
+ if (ev.target.id != this.state.curCanvasId) return
220
+
221
+ let { ctx, stageInfo } = this.state
222
+ let canvas = this.refs.canvas1;
223
+ if (ev.target.id === 'canvas2') {
224
+ ctx = this.state.ctx2;
225
+ stageInfo = this.state.stageInfo2;
226
+ canvas = this.refs.canvas2;
227
+ }
228
+ if(obj.x - canvas.getBoundingClientRect().left<0 || obj.x - canvas.getBoundingClientRect().left> canvas.width || obj.y - canvas.getBoundingClientRect().top< 0 || obj.y - canvas.getBoundingClientRect().top> canvas.height) {
229
+ this.state.isDown = false;
230
+ }
231
+ ctx.beginPath();
232
+ ctx.moveTo(this.state.startX - canvas.getBoundingClientRect().left, this.state.startY - canvas.getBoundingClientRect().top);
233
+ ctx.lineTo(obj.x - canvas.getBoundingClientRect().left, obj.y - canvas.getBoundingClientRect().top);
234
+ ctx.stroke();
235
+ ctx.closePath();
236
+ this.state.startY = obj.y;
237
+ this.state.startX = obj.x;
238
+ // this.resetTimer();
239
+ }
240
+ clearTimeout(this.state.touchEndTimer)
241
+ this.state.touchEndTimer = setTimeout(() => {
242
+ console.log('触发touchEndTimer')
243
+ if (this.state.moveY == obj.y && this.state.moveX == obj.x) {
244
+ console.log('手动关闭')
245
+ this.touchEnd(ev)
246
+ }
247
+ }, 300)
248
+ this.state.moveY = obj.y;
249
+ this.state.moveX = obj.x;
250
+ }
251
+ }
252
+ touchEnd=(ev)=> {
253
+ ev = ev || event
254
+ ev.preventDefault()
255
+ if (ev.touches.length == 1) {
256
+ let obj = {
257
+ x: ev.targetTouches[0].clientX ,
258
+ y: ev.targetTouches[0].clientY
259
+ }
260
+ let { ctx, stageInfo } = this.state
261
+ let canvas = this.refs.canvas1;
262
+ if (ev.target.id === 'canvas2') {
263
+ ctx = this.state.ctx2;
264
+ stageInfo = this.state.stageInfo2;
265
+ canvas = this.refs.canvas2;
266
+ }
267
+
268
+ // ctx.beginPath();
269
+ // ctx.moveTo(this.state.startX - canvas.getBoundingClientRect().left, this.state.startY - canvas.getBoundingClientRect().top);
270
+ // ctx.lineTo(obj.x - canvas.getBoundingClientRect().left, obj.y - canvas.getBoundingClientRect().top);
271
+ // ctx.stroke();
272
+ // ctx.closePath();
273
+ this.state.isDown = false;
274
+
275
+ // this.resetTimer();
276
+ }
277
+ }
278
+ // pc
279
+ mouseDown=(ev) =>{
280
+ this.state.isSignOk = true
281
+ ev.preventDefault();
282
+ // console.log(ev)
283
+ // if (ev.touches.length === 1) {
284
+ // 保存另一张图
285
+ if (ev.target.id !== this.state.curCanvasId) {
286
+ let curCanvasId = this.state.curCanvasId;
287
+ if (curCanvasId) {
288
+ clearTimeout(this.timer)
289
+ // console.log(this.refs[this.state.curCanvasId].toDataURL()); // 签名img回传后台
290
+ // 新增图片
291
+ this.state.pics.push(this.filterImgData(this.refs[curCanvasId]).toDataURL());
292
+ this.setState({
293
+ pics: this.state.pics
294
+ })
295
+ const $div = document.getElementById('imgLeft');
296
+ $div.scrollTop = $div.scrollHeight;
297
+ // 清除画布
298
+ const ctx = curCanvasId === 'canvas1' ? this.state.ctx : this.state.ctx2;
299
+ ctx.clearRect(
300
+ 0,
301
+ 0,
302
+ this.refs[curCanvasId].width,
303
+ this.refs[curCanvasId].height,
304
+ );
305
+ }
306
+ this.state.lastCanvasId = this.state.curCanvasId
307
+ this.state.curCanvasId = ev.target.id;
308
+ if (curCanvasId) this.drawText(1)
309
+ }
310
+ let { ctx } = this.state;
311
+ let canvas = this.refs.canvas1;
312
+ if (ev.target.id === 'canvas2') {
313
+ ctx = this.state.ctx2;
314
+ canvas = this.refs.canvas2;
315
+ }
316
+ const obj = {
317
+ x: ev.pageX,
318
+ y: ev.pageY,
319
+ };
320
+ this.state.startX = obj.x;
321
+ this.state.startY = obj.y;
322
+ ctx.beginPath();
323
+ ctx.moveTo(this.state.startX - canvas.getBoundingClientRect().left, this.state.startY - canvas.getBoundingClientRect().top);
324
+ ctx.lineTo(obj.x - canvas.getBoundingClientRect().left, obj.y - canvas.getBoundingClientRect().top);
325
+ ctx.stroke();
326
+ ctx.closePath();
327
+ this.state.isDown = true;
328
+
329
+ if (this.state.pics.length + 1 >= this.props.item.subContent[0].desc.length) return
330
+ if(ev.target.id === 'canvas1'){
331
+ this.setState({mask2: false})
332
+ } else {
333
+ this.setState({mask1: false})
334
+ }
335
+
336
+ // this.resetTimer();
337
+ // }
338
+ }
339
+ mouseMove=(ev)=> {
340
+ ev.preventDefault();
341
+ if (this.state.isDown) {
342
+ if (ev.target.id != this.state.curCanvasId) return
343
+
344
+ let { ctx, stageInfo } = this.state
345
+ let canvas = this.refs.canvas1;
346
+ if (ev.target.id === 'canvas2') {
347
+ ctx = this.state.ctx2;
348
+ stageInfo = this.state.stageInfo2;
349
+ canvas = this.refs.canvas2;
350
+ }
351
+ const obj = {
352
+ x: ev.pageX,
353
+ y: ev.pageY,
354
+ };
355
+ if(obj.x - canvas.getBoundingClientRect().left<0 || obj.x - canvas.getBoundingClientRect().left> canvas.width || obj.y - canvas.getBoundingClientRect().top< 0 || obj.y - canvas.getBoundingClientRect().top> canvas.height) {
356
+ this.state.isDown = false;
357
+ }
358
+ ctx.beginPath();
359
+ ctx.moveTo(this.state.startX - canvas.getBoundingClientRect().left, this.state.startY - canvas.getBoundingClientRect().top);
360
+ ctx.lineTo(obj.x - canvas.getBoundingClientRect().left, obj.y - canvas.getBoundingClientRect().top);
361
+ ctx.stroke();
362
+ ctx.closePath();
363
+ this.state.startY = obj.y;
364
+ this.state.startX = obj.x;
365
+ // this.resetTimer();
366
+ clearTimeout(this.state.touchEndTimer)
367
+ this.state.touchEndTimer = setTimeout(() => {
368
+ console.log('触发mouseEndTimer')
369
+ if (this.state.moveY == obj.y && this.state.moveX == obj.x) {
370
+ console.log('手动关闭')
371
+ this.mouseUp(ev)
372
+ }
373
+ }, 300)
374
+ this.state.moveY = obj.y;
375
+ this.state.moveX = obj.x;
376
+ }
377
+ }
378
+ mouseUp=(ev)=> {
379
+ if (!this.state.isDown) return;
380
+ ev.preventDefault();
381
+ let { ctx, stageInfo } = this.state
382
+ let canvas = this.refs.canvas1;
383
+ if (ev.target.id === 'canvas2') {
384
+ ctx = this.state.ctx2;
385
+ stageInfo = this.state.stageInfo2;
386
+ canvas = this.refs.canvas2;
387
+ }
388
+ const obj = {
389
+ x: ev.pageX,
390
+ y: ev.pageY,
391
+ };
392
+ // ctx.beginPath();
393
+ // ctx.moveTo(this.state.startX - canvas.getBoundingClientRect().left, this.state.startY - canvas.getBoundingClientRect().top);
394
+ // ctx.lineTo(obj.x - canvas.getBoundingClientRect().left, obj.y - canvas.getBoundingClientRect().top);
395
+ // ctx.stroke();
396
+ // ctx.closePath();
397
+ this.state.isDown = false;
398
+
399
+ // this.resetTimer();
400
+ }
401
+ // 过滤掉背景文字
402
+ filterImgData(canvas, ctx) {
403
+ if (!ctx) ctx = canvas.getContext('2d');
404
+ var imgData=ctx.getImageData(0,0,canvas.width,canvas.height);
405
+ // invert colors
406
+ for (let k=0;k<imgData.data.length;k+=4) {
407
+ if(Math.abs(imgData.data[k]-218)<3 || Math.abs(imgData.data[k+1]-218)<3 ||Math.abs(imgData.data[k+2]-218)<3 ){
408
+ imgData.data[k+3] = 0
409
+ }
410
+ }
411
+ ctx.putImageData(imgData,0,0);
412
+ return canvas
413
+ }
414
+ // 提交
415
+ commit = async () =>{
416
+ if(this.state.pics.length + 1 >= this.props.item.subContent[0].desc.length) {
417
+
418
+
419
+ const curCanvasId = this.state.curCanvasId;
420
+ // 保存另一张图
421
+ if (this.state.curCanvasId) {
422
+ // 新增图片
423
+ this.state.pics.push(this.filterImgData(this.refs[curCanvasId]).toDataURL());
424
+ this.setState({
425
+ pics: this.state.pics
426
+ })
427
+ }
428
+
429
+ const file = await this.getFinalImage()
430
+ // console.log(file)
431
+ const item = this.props.item;
432
+ this.props.next({
433
+ type: item.type,
434
+ file: file, //.replace('data:image/png;base64,',''),
435
+ sequence: item.sequence
436
+ })
437
+ } else {
438
+ this.setState({
439
+ isModalVisibleSubmit: true
440
+ })
441
+ }
442
+ }
443
+ handleSubmit=()=>{
444
+ this.setState({
445
+ isModalVisibleSubmit: false
446
+ })
447
+ }
448
+ // 合成最终图片
449
+ getFinalImage = () => {
450
+ return new Promise(resolve => {
451
+ let canvas = document.createElement('canvas');
452
+ let ctx = canvas.getContext('2d');
453
+ const cell = this.props.item.subContent[0].cell
454
+ const row = this.props.item.subContent[0].row
455
+
456
+ // const blockWidthAndHeight = 40; // 单字宽高
457
+ const blockWidth = 80
458
+ const blockHeight = blockWidth * this.props.height * cell / (this.props.length * row * 2)
459
+ // console.log(blockWidth, blockHeight);
460
+ const wordsPerLine = cell || 10
461
+
462
+ let canvasWidth = blockWidth * wordsPerLine
463
+ let canvasHeight = blockHeight * this.props.item.subContent[0].row * 2 // canvasWidth / this.props.rate
464
+
465
+ canvas.width = canvasWidth;
466
+ canvas.height = canvasHeight;
467
+ // 画背景
468
+ // ctx.fillStyle = 'white';
469
+ // ctx.fillRect(0, 0, canvasWidth, canvasHeight);
470
+
471
+ // 拼接图片绘制
472
+ let pics = this.state.pics
473
+ for (let i = 0;i< this.props.item.subContent[0].desc.length; i++){
474
+
475
+ let rowIndex = Math.floor( i / wordsPerLine)
476
+ let colIndex = Math.floor( i % wordsPerLine)
477
+ // 画字
478
+ // ctx.font = blockWidth/2 + 'px "微软雅黑"';
479
+ // ctx.fillStyle = "#000000";
480
+ // ctx.textAlign = "center";
481
+ // ctx.textBaseline = "middle";
482
+ // ctx.fillText( this.props.item.subContent[0].desc[i], colIndex*blockWidth + blockWidth/2, 2*rowIndex*blockHeight + blockHeight/2 ); //填充文字
483
+
484
+ // 画格子,两条竖线三条横线
485
+ // ctx.beginPath();
486
+ // ctx.strokeStyle = "teal";
487
+ // ctx.moveTo(colIndex*blockWidth, 2*rowIndex*blockHeight); // 竖线
488
+ // ctx.lineTo(colIndex*blockWidth, (2*rowIndex+2)*blockHeight);
489
+ // ctx.stroke();
490
+
491
+ // ctx.moveTo((colIndex+1)*blockWidth, 2*rowIndex*blockHeight);
492
+ // ctx.lineTo((colIndex+1)*blockWidth, (2*rowIndex+2)*blockHeight);
493
+ // ctx.stroke();
494
+
495
+ // ctx.moveTo(colIndex*blockWidth, 2*rowIndex*blockHeight); // 横线
496
+ // ctx.lineTo((colIndex+1)*blockWidth, 2*rowIndex*blockHeight);
497
+ // ctx.stroke();
498
+
499
+ // ctx.moveTo(colIndex*blockWidth, (2*rowIndex+1)*blockHeight);
500
+ // ctx.lineTo((colIndex+1)*blockWidth, (2*rowIndex+1)*blockHeight);
501
+ // ctx.stroke();
502
+
503
+ // ctx.moveTo(colIndex*blockWidth, (2*rowIndex+2)*blockHeight);
504
+ // ctx.lineTo((colIndex+1)*blockWidth, (2*rowIndex+2)*blockHeight);
505
+ // ctx.stroke();
506
+
507
+ // 画图
508
+ let img = new Image()
509
+ img.src = pics[i]
510
+ img.onload = () =>{
511
+ ctx.drawImage(img, colIndex*blockWidth-1,(2*rowIndex+1)*blockHeight-1, blockWidth-2, blockHeight-2);
512
+ if(i===this.props.item.subContent[0].desc.length-1) {
513
+ // console.log(canvas.toDataURL())
514
+ console.log('output')
515
+ console.log(canvas.toDataURL())
516
+ resolve(canvas.toDataURL())
517
+ }
518
+ }
519
+
520
+ }
521
+ })
522
+ }
523
+ // 回退一个
524
+ back = () => {
525
+ if(this.state.isSignOk) {
526
+ this.state.isSignOk = false
527
+ this.clearCanvas()
528
+
529
+
530
+ } else {
531
+ this.state.pics.pop()
532
+ this.setState({
533
+ pics: this.state.pics
534
+ })
535
+ this.clearCanvas()
536
+ }
537
+ // this.state.pics.pop()
538
+ // this.setState({
539
+ // pics: this.state.pics
540
+ // })
541
+ // this.clearCanvas()
542
+ }
543
+ // 清屏
544
+ clearAll = () => {
545
+ this.state.pics = []
546
+ this.setState({
547
+ pics: this.state.pics
548
+ })
549
+ this.clearCanvas()
550
+ }
551
+ exit = () => {
552
+ this.setState({
553
+ isModalVisibleEnd: true
554
+ })
555
+ }
556
+ handleCancelEnd = () => {
557
+ this.setState({
558
+ isModalVisibleEnd: false
559
+ })
560
+ }
561
+ handleOkEnd = () => {
562
+ this.setState({
563
+ isModalVisibleEnd: false
564
+ })
565
+ this.props.exit()
566
+ }
567
+ render() {
568
+ const {item} = this.props;
569
+ return (
570
+ <div className="copyTwo">
571
+ <div className="thehead">
572
+ <div className="title">
573
+ <div className="title-color"></div>
574
+ <div className="title-text">{this.props.title}</div>
575
+ </div>
576
+
577
+ <div className="btns">
578
+ <div className="button gray" onClick={this.exit}><FormattedMessage id="exit" /></div>
579
+ <div className="button gray" onClick={this.clearAll} ><FormattedMessage id="reset" /></div>
580
+ </div>
581
+ </div>
582
+ <div className="contents">{item.subContent[0].desc}</div>
583
+ <div className="copy-area">
584
+ <div className="left" >
585
+ <div className='imgLeft' id="imgLeft" >
586
+ {
587
+ this.state.pics.map((pic,index)=>{
588
+ return (
589
+ <img key={index} className="pic" src={pic} style={{ width: this.state.imgWidth, height: this.state.imgHeight}}></img>
590
+ )
591
+ })
592
+ }
593
+
594
+ </div>
595
+ <div className="footTwo">
596
+ {/* {
597
+ this.state.pics.length + 1 >= item.subContent[0].desc.length? <div className="button" onClick={this.commit}><FormattedMessage id="commit" /></div>: null
598
+ } */}
599
+ <div className='footThree'>
600
+ <div className="button gray" onClick={this.back}><FormattedMessage id="clearScreen" /></div>
601
+ <div className="button" onClick={this.commit}><FormattedMessage id="commit" /></div>
602
+ </div>
603
+ </div>
604
+ </div>
605
+ <div className="right" ref="canvasHW">
606
+ {this.state.mask1 || this.state.pics.length >= item.subContent[0].desc.length?<div className='mask'></div>:null}
607
+ {/* <div className="current-text">{this.state.pics.length<item.subContent.length? item.subContent[this.state.pics.length] : ''}</div> */}
608
+ <canvas
609
+ style={{display : this.state.pics.length >= item.subContent[0].desc.length ? 'none' : ''}}
610
+ id="canvas1"
611
+ ref="canvas1"
612
+ onMouseDown={this.mouseDown}
613
+ onMouseMove={this.mouseMove}
614
+ onMouseUp={this.mouseUp}
615
+ onMouseLeave={() => { this.state.isDown = false }}
616
+ ></canvas>
617
+
618
+ </div>
619
+ <div className="right" ref="canvasHW2">
620
+ {this.state.mask2 || this.state.pics.length >= item.subContent[0].desc.length?<div className='mask'></div>:null}
621
+ {/* <div className="current-text">{this.state.pics.length<item.subContent.length? item.subContent[this.state.pics.length] : ''}</div> */}
622
+ <canvas
623
+ style={{display : this.state.pics.length >= item.subContent[0].desc.length ? 'none' : ''}}
624
+ id="canvas2"
625
+ ref="canvas2"
626
+ onMouseDown={this.mouseDown}
627
+ onMouseMove={this.mouseMove}
628
+ onMouseUp={this.mouseUp}
629
+ onMouseLeave={() => { this.state.isDown = false }}
630
+ ></canvas>
631
+ </div>
632
+ </div>
633
+ <Modal transitionName="" maskTransitionName="" getContainer={document.getElementById('multiModule')} destroyOnClose={true} closable={false} centered={true} visible={this.state.isModalVisibleEnd} footer={[<div key='end'>
634
+ <Button className="modelButtonCancel" onClick={this.handleCancelEnd}><FormattedMessage id="cancel" /></Button>
635
+ <Button className="modelButtonOk" type="primary" danger onClick={this.handleOkEnd}><FormattedMessage id="ok" /></Button>
636
+ </div>
637
+ ]}>
638
+ <div className='endModal'>
639
+ <div className='modalEndTitle'>
640
+ <FormattedMessage id="whether" />
641
+ </div>
642
+ <div className='modalEnd'>
643
+ <FormattedMessage id="progress" />
644
+ </div>
645
+ </div>
646
+ </Modal>
647
+ <Modal transitionName="" maskTransitionName="" getContainer={document.getElementById('multiModule')} destroyOnClose={true} closable={false} centered={true} visible={this.state.isModalVisibleSubmit} footer={[<div key='end'>
648
+ <Button className="modelButtonOk" type="primary" danger onClick={this.handleSubmit}><FormattedMessage id="ok" /></Button>
649
+ </div>
650
+ ]}>
651
+ <div className='endModal'>
652
+ <div className='modalEndTitle'>
653
+ <FormattedMessage id="message" />
654
+ </div>
655
+ <div className='modalEnd'>
656
+ <FormattedMessage id="signatureNot" />
657
+ </div>
658
+ </div>
659
+ </Modal>
660
+ </div>
661
+ );
662
+ }
663
+
664
+ }
665
+
666
+ export default Copy;