react_hsbc_teller 2.0.24 → 2.0.25

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 (26) hide show
  1. package/lib/hsbc.js +1 -1
  2. package/package.json +1 -1
  3. package/packages/api/api.js +91 -0
  4. package/packages/assets/mp3/ipad_leave_error.mp3 +0 -0
  5. package/packages/assets/mp3/ipad_low_power.mp3 +0 -0
  6. package/packages/demo/demo.js +2 -0
  7. package/packages/pages/foot/foot.jsx +2 -2
  8. package/packages/pages/multiModule/components/copy/agree.jsx +115 -0
  9. package/packages/pages/multiModule/components/copy/agree.less +105 -0
  10. package/packages/pages/multiModule/components/copy/copyTwo.jsx +663 -0
  11. package/packages/pages/multiModule/components/copy/copyTwo.less +180 -0
  12. package/packages/pages/multiModule/components/copy/copy_en.jsx +365 -0
  13. package/packages/pages/multiModule/components/copy/copy_en.less +145 -0
  14. package/packages/pages/multiModule/components/copy/copylist.jsx +291 -0
  15. package/packages/pages/multiModule/components/copy/copylist.less +83 -0
  16. package/packages/pages/multiModule/components/copy/risk.jsx +294 -0
  17. package/packages/pages/multiModule/components/copy/risk.less +123 -0
  18. package/packages/pages/multiModule/components/sign/signMy.jsx +306 -0
  19. package/packages/pages/multiModule/components/sign/signMy.less +128 -0
  20. package/packages/pages/multiModule/components/subscribe/subscribe.jsx +113 -0
  21. package/packages/pages/multiModule/components/subscribe/subscribe.less +82 -0
  22. package/packages/pages/multiModule/multiModule.jsx +26 -0
  23. package/packages/pages/multiModule/multiModule.less +20 -0
  24. package/packages/pages/video/video.jsx +388 -148
  25. package/packages/utils/asrController.js +242 -0
  26. package/packages/utils/recorder.js +289 -0
@@ -0,0 +1,663 @@
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
+ ev.preventDefault();
380
+ let { ctx, stageInfo } = this.state
381
+ let canvas = this.refs.canvas1;
382
+ if (ev.target.id === 'canvas2') {
383
+ ctx = this.state.ctx2;
384
+ stageInfo = this.state.stageInfo2;
385
+ canvas = this.refs.canvas2;
386
+ }
387
+ const obj = {
388
+ x: ev.pageX,
389
+ y: ev.pageY,
390
+ };
391
+ // ctx.beginPath();
392
+ // ctx.moveTo(this.state.startX - canvas.getBoundingClientRect().left, this.state.startY - canvas.getBoundingClientRect().top);
393
+ // ctx.lineTo(obj.x - canvas.getBoundingClientRect().left, obj.y - canvas.getBoundingClientRect().top);
394
+ // ctx.stroke();
395
+ // ctx.closePath();
396
+ this.state.isDown = false;
397
+
398
+ // this.resetTimer();
399
+ }
400
+ // 过滤掉背景文字
401
+ filterImgData(canvas, ctx) {
402
+ if (!ctx) ctx = canvas.getContext('2d');
403
+ var imgData=ctx.getImageData(0,0,canvas.width,canvas.height);
404
+ // invert colors
405
+ for (let k=0;k<imgData.data.length;k+=4) {
406
+ if(Math.abs(imgData.data[k]-218)<3 || Math.abs(imgData.data[k+1]-218)<3 ||Math.abs(imgData.data[k+2]-218)<3 ){
407
+ imgData.data[k+3] = 0
408
+ }
409
+ }
410
+ ctx.putImageData(imgData,0,0);
411
+ return canvas
412
+ }
413
+ // 提交
414
+ commit = async () =>{
415
+ if(this.state.pics.length + 1 >= this.props.item.subContent[0].desc.length) {
416
+
417
+
418
+ const curCanvasId = this.state.curCanvasId;
419
+ // 保存另一张图
420
+ if (this.state.curCanvasId) {
421
+ // 新增图片
422
+ this.state.pics.push(this.filterImgData(this.refs[curCanvasId]).toDataURL());
423
+ this.setState({
424
+ pics: this.state.pics
425
+ })
426
+ }
427
+
428
+ const file = await this.getFinalImage()
429
+ // console.log(file)
430
+ const item = this.props.item;
431
+ this.props.next({
432
+ type: item.type,
433
+ file: file, //.replace('data:image/png;base64,',''),
434
+ sequence: item.sequence
435
+ })
436
+ } else {
437
+ this.setState({
438
+ isModalVisibleSubmit: true
439
+ })
440
+ }
441
+ }
442
+ handleSubmit=()=>{
443
+ this.setState({
444
+ isModalVisibleSubmit: false
445
+ })
446
+ }
447
+ // 合成最终图片
448
+ getFinalImage = () => {
449
+ return new Promise(resolve => {
450
+ let canvas = document.createElement('canvas');
451
+ let ctx = canvas.getContext('2d');
452
+ const cell = this.props.item.subContent[0].cell
453
+ const row = this.props.item.subContent[0].row
454
+
455
+ // const blockWidthAndHeight = 40; // 单字宽高
456
+ const blockWidth = 80
457
+ const blockHeight = blockWidth * this.props.height * cell / (this.props.length * row * 2)
458
+ // console.log(blockWidth, blockHeight);
459
+ const wordsPerLine = cell || 10
460
+
461
+ let canvasWidth = blockWidth * wordsPerLine
462
+ let canvasHeight = blockHeight * this.props.item.subContent[0].row * 2 // canvasWidth / this.props.rate
463
+
464
+ canvas.width = canvasWidth;
465
+ canvas.height = canvasHeight;
466
+ // 画背景
467
+ // ctx.fillStyle = 'white';
468
+ // ctx.fillRect(0, 0, canvasWidth, canvasHeight);
469
+
470
+ // 拼接图片绘制
471
+ let pics = this.state.pics
472
+ for (let i = 0;i< this.props.item.subContent[0].desc.length; i++){
473
+
474
+ let rowIndex = Math.floor( i / wordsPerLine)
475
+ let colIndex = Math.floor( i % wordsPerLine)
476
+ // 画字
477
+ // ctx.font = blockWidth/2 + 'px "微软雅黑"';
478
+ // ctx.fillStyle = "#000000";
479
+ // ctx.textAlign = "center";
480
+ // ctx.textBaseline = "middle";
481
+ // ctx.fillText( this.props.item.subContent[0].desc[i], colIndex*blockWidth + blockWidth/2, 2*rowIndex*blockHeight + blockHeight/2 ); //填充文字
482
+
483
+ // 画格子,两条竖线三条横线
484
+ // ctx.beginPath();
485
+ // ctx.strokeStyle = "teal";
486
+ // ctx.moveTo(colIndex*blockWidth, 2*rowIndex*blockHeight); // 竖线
487
+ // ctx.lineTo(colIndex*blockWidth, (2*rowIndex+2)*blockHeight);
488
+ // ctx.stroke();
489
+
490
+ // ctx.moveTo((colIndex+1)*blockWidth, 2*rowIndex*blockHeight);
491
+ // ctx.lineTo((colIndex+1)*blockWidth, (2*rowIndex+2)*blockHeight);
492
+ // ctx.stroke();
493
+
494
+ // ctx.moveTo(colIndex*blockWidth, 2*rowIndex*blockHeight); // 横线
495
+ // ctx.lineTo((colIndex+1)*blockWidth, 2*rowIndex*blockHeight);
496
+ // ctx.stroke();
497
+
498
+ // ctx.moveTo(colIndex*blockWidth, (2*rowIndex+1)*blockHeight);
499
+ // ctx.lineTo((colIndex+1)*blockWidth, (2*rowIndex+1)*blockHeight);
500
+ // ctx.stroke();
501
+
502
+ // ctx.moveTo(colIndex*blockWidth, (2*rowIndex+2)*blockHeight);
503
+ // ctx.lineTo((colIndex+1)*blockWidth, (2*rowIndex+2)*blockHeight);
504
+ // ctx.stroke();
505
+
506
+ // 画图
507
+ let img = new Image()
508
+ img.src = pics[i]
509
+ img.onload = () =>{
510
+ ctx.drawImage(img, colIndex*blockWidth-1,(2*rowIndex+1)*blockHeight-1, blockWidth-2, blockHeight-2);
511
+ if(i===this.props.item.subContent[0].desc.length-1) {
512
+ // console.log(canvas.toDataURL())
513
+ console.log('output')
514
+ console.log(canvas.toDataURL())
515
+ resolve(canvas.toDataURL())
516
+ }
517
+ }
518
+
519
+ }
520
+ })
521
+ }
522
+ // 回退一个
523
+ back = () => {
524
+ if(this.state.isSignOk) {
525
+ this.state.isSignOk = false
526
+ this.clearCanvas()
527
+
528
+
529
+ } else {
530
+ this.state.pics.pop()
531
+ this.setState({
532
+ pics: this.state.pics
533
+ })
534
+ this.clearCanvas()
535
+ }
536
+ // this.state.pics.pop()
537
+ // this.setState({
538
+ // pics: this.state.pics
539
+ // })
540
+ // this.clearCanvas()
541
+ }
542
+ // 清屏
543
+ clearAll = () => {
544
+ this.state.pics = []
545
+ this.setState({
546
+ pics: this.state.pics
547
+ })
548
+ this.clearCanvas()
549
+ }
550
+ exit = () => {
551
+ this.setState({
552
+ isModalVisibleEnd: true
553
+ })
554
+ }
555
+ handleCancelEnd = () => {
556
+ this.setState({
557
+ isModalVisibleEnd: false
558
+ })
559
+ }
560
+ handleOkEnd = () => {
561
+ this.setState({
562
+ isModalVisibleEnd: false
563
+ })
564
+ this.props.exit()
565
+ }
566
+ render() {
567
+ const {item} = this.props;
568
+ return (
569
+ <div className="copyTwo">
570
+ <div className="thehead">
571
+ <div className="title">
572
+ <div className="title-color"></div>
573
+ <div className="title-text">{this.props.title}</div>
574
+ </div>
575
+
576
+ <div className="btns">
577
+ <div className="button gray" onClick={this.exit}><FormattedMessage id="exit" /></div>
578
+ <div className="button gray" onClick={this.clearAll} ><FormattedMessage id="reset" /></div>
579
+ </div>
580
+ </div>
581
+ <div className="contents">{item.subContent[0].desc}</div>
582
+ <div className="copy-area">
583
+ <div className="left" >
584
+ <div className='imgLeft' id="imgLeft" >
585
+ {
586
+ this.state.pics.map((pic,index)=>{
587
+ return (
588
+ <img key={index} className="pic" src={pic} style={{ width: this.state.imgWidth, height: this.state.imgHeight}}></img>
589
+ )
590
+ })
591
+ }
592
+
593
+ </div>
594
+ <div className="footTwo">
595
+ {/* {
596
+ this.state.pics.length + 1 >= item.subContent[0].desc.length? <div className="button" onClick={this.commit}><FormattedMessage id="commit" /></div>: null
597
+ } */}
598
+ <div className='footThree'>
599
+ <div className="button gray" onClick={this.back}><FormattedMessage id="clearScreen" /></div>
600
+ <div className="button" onClick={this.commit}><FormattedMessage id="commit" /></div>
601
+ </div>
602
+ </div>
603
+ </div>
604
+ <div className="right" ref="canvasHW">
605
+ {this.state.mask1 || this.state.pics.length >= item.subContent[0].desc.length?<div className='mask'></div>:null}
606
+ {/* <div className="current-text">{this.state.pics.length<item.subContent.length? item.subContent[this.state.pics.length] : ''}</div> */}
607
+ <canvas
608
+ style={{display : this.state.pics.length >= item.subContent[0].desc.length ? 'none' : ''}}
609
+ id="canvas1"
610
+ ref="canvas1"
611
+ onMouseDown={this.mouseDown}
612
+ onMouseMove={this.mouseMove}
613
+ onMouseUp={this.mouseUp}
614
+ ></canvas>
615
+
616
+ </div>
617
+ <div className="right" ref="canvasHW2">
618
+ {this.state.mask2 || this.state.pics.length >= item.subContent[0].desc.length?<div className='mask'></div>:null}
619
+ {/* <div className="current-text">{this.state.pics.length<item.subContent.length? item.subContent[this.state.pics.length] : ''}</div> */}
620
+ <canvas
621
+ style={{display : this.state.pics.length >= item.subContent[0].desc.length ? 'none' : ''}}
622
+ id="canvas2"
623
+ ref="canvas2"
624
+ onMouseDown={this.mouseDown}
625
+ onMouseMove={this.mouseMove}
626
+ onMouseUp={this.mouseUp}
627
+ ></canvas>
628
+ </div>
629
+ </div>
630
+ <Modal transitionName="" maskTransitionName="" getContainer={document.getElementById('multiModule')} destroyOnClose={true} closable={false} centered={true} visible={this.state.isModalVisibleEnd} footer={[<div key='end'>
631
+ <Button className="modelButtonCancel" onClick={this.handleCancelEnd}><FormattedMessage id="cancel" /></Button>
632
+ <Button className="modelButtonOk" type="primary" danger onClick={this.handleOkEnd}><FormattedMessage id="ok" /></Button>
633
+ </div>
634
+ ]}>
635
+ <div className='endModal'>
636
+ <div className='modalEndTitle'>
637
+ <FormattedMessage id="whether" />
638
+ </div>
639
+ <div className='modalEnd'>
640
+ <FormattedMessage id="progress" />
641
+ </div>
642
+ </div>
643
+ </Modal>
644
+ <Modal transitionName="" maskTransitionName="" getContainer={document.getElementById('multiModule')} destroyOnClose={true} closable={false} centered={true} visible={this.state.isModalVisibleSubmit} footer={[<div key='end'>
645
+ <Button className="modelButtonOk" type="primary" danger onClick={this.handleSubmit}><FormattedMessage id="ok" /></Button>
646
+ </div>
647
+ ]}>
648
+ <div className='endModal'>
649
+ <div className='modalEndTitle'>
650
+ <FormattedMessage id="message" />
651
+ </div>
652
+ <div className='modalEnd'>
653
+ <FormattedMessage id="signatureNot" />
654
+ </div>
655
+ </div>
656
+ </Modal>
657
+ </div>
658
+ );
659
+ }
660
+
661
+ }
662
+
663
+ export default Copy;