react_hsbc_teller 1.9.19 → 1.9.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react_hsbc_teller",
3
- "version": "1.9.19",
3
+ "version": "1.9.21",
4
4
  "description": "React",
5
5
  "private": false,
6
6
  "main": "lib/hsbc.js",
@@ -21,6 +21,7 @@ roomId
21
21
  // mtoken: '',
22
22
  // imRoomId: '',
23
23
  // sessionId: '',
24
+ pdfRendering: false,
24
25
  isVideo: false,
25
26
  tellerAccount: 'wmzTeller',
26
27
  // callbackUrl: 'http://182.92.184.31:8720/hsbc/callback',
@@ -142,6 +143,17 @@ shareMaskClick=()=>{
142
143
  }
143
144
 
144
145
  }
146
+ pdfRenderingClick=()=>{
147
+ if(this.state.pdfRendering) {
148
+ this.setState({
149
+ pdfRendering: false
150
+ })
151
+ } else {
152
+ this.setState({
153
+ pdfRendering: true
154
+ })
155
+ }
156
+ }
145
157
  createRoomCallback=(data)=>{
146
158
  console.log('createRoomCallback', data)
147
159
  this.setState({roomId: data.data.roomId});
@@ -195,6 +207,7 @@ userExit =(val)=>{
195
207
  <div>
196
208
  <HSBC
197
209
  shareMask={this.state.shareMask}
210
+ pdfRendering={this.state.pdfRendering}
198
211
  roomId={this.state.roomId}
199
212
  mtoken={this.state.mtoken}
200
213
  sessionId={this.state.sessionId}
@@ -219,6 +232,7 @@ userExit =(val)=>{
219
232
  createRoomCallback={this.createRoomCallback}
220
233
  joinRoomCallback={this.joinRoomCallback}
221
234
  imgCallback={this.imgCallback}
235
+ sfpCallback={()=>{console.log('sfpCallback success')}}
222
236
  userExit={this.userExit}
223
237
  staffPermission={this.staffPermission}
224
238
  >
@@ -226,6 +240,7 @@ userExit =(val)=>{
226
240
  <Pdf></Pdf>
227
241
  </HSBC>
228
242
  <button onClick={this.shareMaskClick.bind(this)}>遮罩层</button>
243
+ <button onClick={this.pdfRenderingClick.bind(this)}>{this.state.pdfRendering?'继续':'暂停'}渲染</button>
229
244
  </div>
230
245
  :
231
246
  <div>
@@ -2,6 +2,7 @@ import React, { Component } from "react";
2
2
 
3
3
  class pdf extends Component {
4
4
  state = {
5
+ testTime: '',
5
6
  isVideo: false,
6
7
  tellerAccount: '',
7
8
  callbackUrl: 'http://47.102.126.132:8720/hsbc/callback',
@@ -11,6 +12,12 @@ class pdf extends Component {
11
12
  baseURL:'https://counter-web.leimondata.cn:18082/api/leimon-counter-api',
12
13
  resourcePath:'https://counter-web.leimondata.cn:7199',
13
14
  }
15
+ componentDidMount () {
16
+ this.countTimer()
17
+ }
18
+ componentWillUnmount() {
19
+ clearInterval(this.state.timer)
20
+ }
14
21
  startVideo = () => {
15
22
  this.setState({
16
23
  isVideo: true
@@ -53,6 +60,13 @@ handleResourcePath = (event) => {
53
60
  resourcePath: event.target.value
54
61
  })
55
62
  }
63
+ countTimer = () => {
64
+ this.state.timer = setInterval(() => {
65
+ this.setState({
66
+ testTime: new Date().toString()
67
+ })
68
+ }, 1000);
69
+ }
56
70
 
57
71
  render() {
58
72
  console.log('22',this.props)
@@ -68,6 +82,7 @@ handleResourcePath = (event) => {
68
82
  阿里资源服务地址:<input placeholder="请输入阿里资源服务地址" value={this.state.resourcePath} onChange={e => this.handleResourcePath(e)}></input>
69
83
 
70
84
  <button className="button" onClick={this.startVideo.bind(this)}>开启视频</button>
85
+ <div>{this.state.testTime}</div>
71
86
  </div>
72
87
  }
73
88
  </div>
@@ -6,6 +6,7 @@ import API from '../../api/api';
6
6
  import { initWebSocket, joinRoom, disconnect } from '../../common/websocket';
7
7
  import { BoardOperate } from '../../common/index.esm.js';
8
8
  import './video.less'
9
+ import { compressImage } from '../../utils/utils'
9
10
  import Header from '../header/header.jsx'
10
11
  import Foot from '../foot/foot.jsx'
11
12
  import voiceImgOpen from '../../assets/img/icon_Mute.png'
@@ -287,6 +288,7 @@ class Video extends Component {
287
288
  cardFailReason: '',
288
289
  videoType: '',
289
290
  certificateValidityType: true,
291
+ drawCanvasInterval: null,
290
292
  };
291
293
  // eslint-disable-next-line no-undef
292
294
  test_controller = '';
@@ -294,7 +296,7 @@ class Video extends Component {
294
296
  saveLog = (val) => {
295
297
  axios({
296
298
  method: 'get',
297
- baseURL: this.props.logUrl + '&message=' + encodeURIComponent(val) + '&react_hsbc_teller=1.9.19&logTime=' + Date.now() + '&mtoken=' + encodeURIComponent(this.state.rtoken) + '&roomId=' + encodeURIComponent(this.state.channelId) + '&sessionId=' + encodeURIComponent(this.state.sessionId) + '&appointmentID=' + this.props.businessNumber,
299
+ baseURL: this.props.logUrl + '&message=' + encodeURIComponent(val) + '&react_hsbc_teller=1.9.21&logTime=' + Date.now() + '&mtoken=' + encodeURIComponent(this.state.rtoken) + '&roomId=' + encodeURIComponent(this.state.channelId) + '&sessionId=' + encodeURIComponent(this.state.sessionId) + '&appointmentID=' + this.props.businessNumber,
298
300
 
299
301
  }).then(res => {
300
302
 
@@ -1361,6 +1363,9 @@ class Video extends Component {
1361
1363
  if (Mival.type == 1) {
1362
1364
  this.switchExternal()
1363
1365
  this.saveLog('whiteboard start, typeId=1218,')
1366
+ if (typeof this.props.sfpCallback === 'function'){
1367
+ this.props.sfpCallback()
1368
+ }
1364
1369
  } else if (Mival.type == 2) {
1365
1370
  if (streamShare) {
1366
1371
  streamShare.getTracks().forEach(track => track.stop());
@@ -1374,6 +1379,7 @@ class Video extends Component {
1374
1379
  } else {
1375
1380
  if (document.getElementById('video20').name) {
1376
1381
  this.test_controller.UnPublish(document.getElementById('video20').name)
1382
+ if(this.state.drawCanvasInterval) clearInterval(this.state.drawCanvasInterval)
1377
1383
  }
1378
1384
  this.setState({
1379
1385
  isWhiteboard: false
@@ -1427,47 +1433,6 @@ class Video extends Component {
1427
1433
  this.tabTitlesClick('customerScreen', 'delect')
1428
1434
  this.saveLog('app stop sharing screen, typeId=4001, ')
1429
1435
 
1430
- } else if (Mival.typeId == 4004) {
1431
- // 线下demo静音处理
1432
- if (Mival.data.sessionId == this.state.sessionId && this.isFileSuccuse()) {
1433
- if (!this.state.voiceStatue) {
1434
- // 静音本地
1435
- this.setState({
1436
- voiceStatue: true,
1437
- voiceImg: voiceImgCloe,
1438
- voiceName: '解除静音'
1439
- });
1440
- let sid = document.getElementById('publish_video1').name || document.getElementById('publish_streamId1').name;
1441
- this.test_controller.SetLocalAudioEnable(0, parseInt(sid, 10));
1442
- callNimIM('sendCustomCmdMsg', {
1443
- customId: this.state.imRoomId,
1444
- content: JSON.stringify({
1445
- 'typeId': 1013,
1446
- 'muteStatus': 1,
1447
- 'data': {
1448
- 'sessionId': this.state.sessionId,
1449
- 'userId': this.props.tellerAccount
1450
- }
1451
- })
1452
- }, function (code, message, data) {
1453
- // console.log(data)
1454
- })
1455
- }
1456
- document.getElementById('audio1').muted = true
1457
- console.log('音频流静音')
1458
- console.log(document.getElementById('audio1').muted)
1459
- setTimeout(() => {
1460
- callNimIM('sendCustomCmdMsg', {
1461
- customId: this.state.imRoomId,
1462
- content: JSON.stringify({
1463
- 'typeId': 1223,
1464
- 'state': 1, // app解除静音
1465
- 'sessionId': this.state.sessionId,
1466
- 'userId': Mival.data.userId //this.seeList(this.state.roomCustomerList, 'feedId', document.getElementById('feedId1').innerText).uid
1467
- })
1468
- });
1469
- }, 1000);
1470
- }
1471
1436
  } else if (Mival.typeId == 1401) {
1472
1437
  // 用户修改名字
1473
1438
  if (Mival.sessionId == this.state.sessionId) {
@@ -1787,48 +1752,6 @@ class Video extends Component {
1787
1752
  this.customerFaceClick(this.state.customerList[this.state.customerSelect - 1])
1788
1753
  }
1789
1754
  }
1790
- // 线下demo静音处理
1791
- if (JSON.parse(msg).typeId == 4004 && this.state.sessionId == JSON.parse(msg).data.sessionId) {
1792
- if (this.isFileSuccuse()) {
1793
- if (!this.state.voiceStatue) {
1794
- // 静音本地
1795
- this.setState({
1796
- voiceStatue: true,
1797
- voiceImg: voiceImgCloe,
1798
- voiceName: '解除静音'
1799
- });
1800
- let sid = document.getElementById('publish_video1').name || document.getElementById('publish_streamId1').name;
1801
- this.test_controller.SetLocalAudioEnable(0, parseInt(sid, 10));
1802
- callNimIM('sendCustomCmdMsg', {
1803
- customId: this.state.imRoomId,
1804
- content: JSON.stringify({
1805
- 'typeId': 1013,
1806
- 'muteStatus': 1,
1807
- 'data': {
1808
- 'sessionId': this.state.sessionId,
1809
- 'userId': this.props.tellerAccount
1810
- }
1811
- })
1812
- }, function (code, message, data) {
1813
- // console.log(data)
1814
- })
1815
- }
1816
- document.getElementById('audio1').muted = true
1817
- console.log('音频流静音')
1818
- console.log(document.getElementById('audio1').muted)
1819
- setTimeout(() => {
1820
- callNimIM('sendCustomCmdMsg', {
1821
- customId: this.state.imRoomId,
1822
- content: JSON.stringify({
1823
- 'typeId': 1223,
1824
- 'state': 1, // app解除静音
1825
- 'sessionId': this.state.sessionId,
1826
- 'userId': uid //this.seeList(this.state.roomCustomerList, 'feedId', document.getElementById('feedId1').innerText).uid
1827
- })
1828
- });
1829
- }, 1000);
1830
- }
1831
- }
1832
1755
  this.saveLog('mrtc OnReceiveTextMsg info:' + msg)
1833
1756
  }
1834
1757
  this.test_controller.StreamFilterHandler = async (publish_tag, stream, stream_type, publish_device, media_type) => {
@@ -1922,10 +1845,8 @@ class Video extends Component {
1922
1845
  }
1923
1846
  }
1924
1847
  return newStream1
1925
- } else {
1926
- return stream
1927
1848
  }
1928
-
1849
+ return stream
1929
1850
  }
1930
1851
  // 发布媒体流成功
1931
1852
  this.test_controller.OnPublishSucc = (sid) => {
@@ -2296,9 +2217,16 @@ class Video extends Component {
2296
2217
  })
2297
2218
  }
2298
2219
  }
2299
- if (!document.getElementById("video1").name) {
2300
- document.getElementById('audio1').muted = false
2301
- }
2220
+ // if (!document.getElementById("video1").name) {
2221
+ // this.state.isPIBIntranet[0].type = false
2222
+ // this.setState({
2223
+ // videoOneName: '',
2224
+ // voiceVideoOne: false,
2225
+ // noVideoOne: false
2226
+ // },()=>{
2227
+ // this.videoListClick()
2228
+ // })
2229
+ // }
2302
2230
  this.state.analyserData.delete(sid)
2303
2231
  if (this.state.isPictureInPicture) {
2304
2232
  this.pictureInPicture('Refresh')
@@ -2822,6 +2750,7 @@ class Video extends Component {
2822
2750
  disconnect();
2823
2751
  }
2824
2752
  message.destroy()
2753
+ clearInterval(this.state.drawCanvasInterval)
2825
2754
  }
2826
2755
  finishSession = () => {
2827
2756
  // clearInterval(this.state.OnVolumeAnalyserMap.get(sid))
@@ -3012,7 +2941,7 @@ class Video extends Component {
3012
2941
  }
3013
2942
  }
3014
2943
  componentWillMount() {
3015
- console.log('hsbc_teller_sdk', '1.9.19')
2944
+ console.log('hsbc_teller_sdk', '1.9.21')
3016
2945
  let arr = []
3017
2946
  for(let i=1;i<=12;i++){
3018
2947
  arr.push({
@@ -3695,6 +3624,7 @@ class Video extends Component {
3695
3624
  })
3696
3625
  // this.messageClick('识别失败', 'error')
3697
3626
  this.errorCodeClick('ocr',result.code)
3627
+ this.saveLog('OCR failed, error code=' + result.code)
3698
3628
  }
3699
3629
  } catch (err) {
3700
3630
  this.setState({
@@ -4034,19 +3964,25 @@ class Video extends Component {
4034
3964
  }
4035
3965
  }
4036
3966
  sgsinImage = () => {
4037
- if (this.state.IDtypeFrontOrBack == IDtypeFront) {
4038
- this.setState({
4039
- facialImg: this.test_controller.TakePicture(1, undefined, undefined, this.state.customOcrSid, 'png'),
4040
- isFaceImage: true,
4041
- facialImgFront: this.test_controller.TakePicture(1, undefined, undefined, this.state.customOcrSid, 'png'),
4042
- })
4043
- } else if (this.state.IDtypeFrontOrBack == IDtypeBack) {
4044
- this.setState({
4045
- facialImg: this.test_controller.TakePicture(1, undefined, undefined, this.state.customOcrSid, 'png'),
4046
- isFaceImage: true,
4047
- facialImgBack: this.test_controller.TakePicture(1, undefined, undefined, this.state.customOcrSid, 'png'),
4048
- })
4049
- }
3967
+ const imgBase64 = this.test_controller.TakePicture(1, undefined, undefined, this.state.customOcrSid, 'png')
3968
+ // console.log(imgBase64)
3969
+
3970
+ compressImage(imgBase64, (compressedImg)=>{
3971
+ // console.log(compressedImg)
3972
+ if (this.state.IDtypeFrontOrBack == IDtypeFront) {
3973
+ this.setState({
3974
+ facialImg: compressedImg,
3975
+ isFaceImage: true,
3976
+ facialImgFront: compressedImg,
3977
+ })
3978
+ } else if (this.state.IDtypeFrontOrBack == IDtypeBack) {
3979
+ this.setState({
3980
+ facialImg: compressedImg,
3981
+ isFaceImage: true,
3982
+ facialImgBack: compressedImg,
3983
+ })
3984
+ }
3985
+ })
4050
3986
 
4051
3987
  }
4052
3988
  handleChangeOcr = (val) => {
@@ -4209,6 +4145,21 @@ class Video extends Component {
4209
4145
  })
4210
4146
  }
4211
4147
  }
4148
+ changePdfRendering = () => {
4149
+ if (this.props.pdfRendering) {
4150
+ // 暂停绘制
4151
+ clearInterval(this.state.drawCanvasInterval)
4152
+ } else {
4153
+ // 继续绘制
4154
+ if (!this.drawFunction) {
4155
+ console.log('未开始远程签署')
4156
+ return
4157
+ }
4158
+ clearInterval(this.state.drawCanvasInterval)
4159
+ this.state.drawCanvasInterval = setInterval(this.drawFunction, 1000 / 20);
4160
+ }
4161
+
4162
+ }
4212
4163
  navigatorClick = () => {
4213
4164
  const that = this
4214
4165
  const publish_config = {};
@@ -4250,20 +4201,21 @@ class Video extends Component {
4250
4201
  canvas.width = this.state.whiteboardWidth
4251
4202
  }
4252
4203
  console.log('addEventListener', !$this.paused, !$this.ended, x, y, width, height)
4253
- loop()
4254
- function loop() {
4255
- if (!$this.paused && !$this.ended) {
4256
- // if(!that.state.tabTitles.find(el=>el.value == 'customerScreen')) {
4257
- cobj.drawImage(videoMedia, x, y, width, height, 0, 0, 960, 540);
4258
- // } else {
4259
- // cobj.fillStyle = 'rgb(0 0 0)'
4260
- // cobj.fillRect(0,0,960,540)
4261
- // }
4262
-
4263
- setTimeout(loop, 1000 / 20); // drawing at 30fps
4264
- }
4204
+
4205
+ if (this.state.drawCanvasInterval) clearInterval(this.state.drawCanvasInterval)
4206
+ $this.drawFunction = () => {
4207
+ if (!$this.paused && !$this.ended) {
4208
+ // if(!that.state.tabTitles.find(el=>el.value == 'customerScreen')) {
4209
+ cobj.drawImage(videoMedia, x, y, width, height, 0, 0, 960, 540);
4210
+ // } else {
4211
+ // cobj.fillStyle = 'rgb(0 0 0)'
4212
+ // cobj.fillRect(0,0,960,540)
4213
+ // }
4214
+ }
4265
4215
  }
4266
4216
 
4217
+ this.state.drawCanvasInterval = setInterval($this.drawFunction , 1000/ 20);
4218
+
4267
4219
  if (document.getElementById('video20').name) {
4268
4220
  // 代表已经有了进行切流
4269
4221
  publish_config.publish_device = 5
@@ -4764,6 +4716,9 @@ class Video extends Component {
4764
4716
  if (this.props.shareMask != prevProps.shareMask) {
4765
4717
  this.sendNotification()
4766
4718
  }
4719
+ if (this.props.pdfRendering != prevProps.pdfRendering) {
4720
+ this.changePdfRendering()
4721
+ }
4767
4722
  }
4768
4723
  onChangeOCRCustomer = (e) => {
4769
4724
  console.log(e)
@@ -5721,6 +5676,7 @@ Video.defaultProps = {
5721
5676
  customers: ['--'],
5722
5677
  otherAttendees: undefined
5723
5678
  },
5679
+ pdfRendering: false,
5724
5680
  isTranscribing: false,
5725
5681
  shareMask: false,
5726
5682
  isOpenSound: false, // true开启进出音效 false不开启
@@ -0,0 +1,36 @@
1
+ function compressImage(base64, callback) {
2
+ var targSize = 1024 * 1024 * 1.45 //1024KB
3
+ if (base64.length <= targSize) {
4
+ callback(base64);
5
+ // console.log("直接返回")
6
+ return
7
+ }
8
+ var newImage = new Image();
9
+ newImage.src = base64;
10
+ console.log('压缩前'+base64.length)
11
+ newImage.setAttribute("crossOrigin", 'Anonymous'); //url为外域时需要
12
+ newImage.onload = function () {
13
+ var quality = 0.95; //压缩系数0-1之间
14
+ var canvas = document.createElement("canvas");
15
+ var ctx = canvas.getContext("2d");
16
+ canvas.width = 720
17
+ canvas.height = 405
18
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
19
+ ctx.drawImage(newImage, 0, 0, canvas.width, canvas.height);
20
+ var base64 = canvas.toDataURL("image/png", quality); //压缩语句
21
+ // 如想确保图片压缩到自己想要的尺寸,如要求在5-10kb之间,请加以下语句,quality初始值根据情况自定
22
+ // console.log(base64.length + "循环1压缩" + (base64.length / 1024 > 512))
23
+
24
+ // while (base64.length > targSize) {
25
+ // quality -= 0.03;
26
+ // // console.log(base64.length + "循环压缩" + quality)
27
+ // base64 = canvas.toDataURL("image/png", quality);
28
+ // }
29
+ console.log('压缩后'+base64.length)
30
+ callback(base64); //必须通过回调函数返回,否则无法及时拿到该值
31
+ }
32
+ }
33
+
34
+ export {
35
+ compressImage
36
+ }