当前位置:   article > 正文

web 语音通话 jssip

jssip

先把封装好的地址安上(非本人封装):webrtc-webphone: 基于JsSIP开发的webrtc软电话

jssip中文文档:jssip中文开发文档(完整版) - 简书

jssip使用文档:(我没有运行过,但是他写的很清楚,反正比我好)jssip+webrtc+freeswitch实现电话网页及遇到的488状态码问题_freeswitch 488_weixin_39715323的博客-CSDN博客

正常使用由于web限制应该在https上使用,但是http也不是不可以,我放到下一篇文章了,这就说怎么使用

我这用的是webrtc+jssip

webrtc-webphone已经实现了我的需求,所以我没有使用原生jssip

特主要实现的功能有:注册,拨叫,接听,保持,恢复

我的项目中需要静音(指我不能说话,通话人可以讲话)

所以我将hold(保持)和unhold(恢复)改成了mute和unmute

 下面是完整代码和方法说明:

1.init(注册citbar)config中需要使用ip地址、端口号、extNo拨号人、extPwd密码

2.handleAgentBarBtnClick(通话状态更改)

        makecall(拨号)

        hangup(挂断)

        hold(静音)

        unhold(取消静音)

3.onbeforeunload (通话中刷新对讲群组中没有退出,导致群组中有多个同一个人)

4.beforeDestroy(切换页面后没有退出群组,刷新不走这个方法)

注意:

1.不要重复拨号,状态卡住后就能同一个设备对话了bug

2.如果想切换页面还能通话就不要beforeDestroy,但是在其他页面在回来时会导致状态不一致,而且容易出现卡状态,所以我将通话操作放在index最顶层里面

  1. <template>
  2. <div class="top">
  3. <div style="padding: 0 30px;">
  4. <div style="display: flex;padding-top: 3px;">
  5. <!-- 设备树插件 -->
  6. <organizationTree ref="organizationTree"></organizationTree>
  7. <div style="width:77vw;height:80vh; margin-top: 5px;">
  8. <div class="photo_date" style="position:relative">
  9. <div style="display:flex;min-width:30%">
  10. <div class="text_type photo_deviceName " v-show="groupName" style="text-align: center;">
  11. {{groupName}}</div>
  12. <div class="text_type" :class="meetingStatus==2?' meetingName1':' meetingName'"
  13. style="width: 125px;text-align: center;">
  14. {{meetingStatus==2?meetingName:meetingName1}}</div>
  15. </div>
  16. <div style="position: absolute;right: 0;" v-show="createBy==userName">
  17. <div v-show="meetingStatus==2" class="btn_type photo_meeting_btn" @click="meetingAll"
  18. style="position:absolute; right:135px;width: 140px;height: 35px;line-height: 35px;">
  19. 邀请全部成员</div>
  20. <div class="bg_btn_type photo_meeting_btn" @click="meeting"
  21. style="position:absolute; right:0;width: 125px;height: 35px;line-height: 35px;">
  22. {{meetingStatus==1?'开始会议':'结束会议'}}</div>
  23. </div>
  24. </div>
  25. <div class="">
  26. <div class="deviceList_title">
  27. <div class="deviceList_title_text" style="width:15%">名称</div>
  28. <div class="deviceList_title_text" style="width:15%">imei</div>
  29. <div class="deviceList_title_text" style="width:15%">类型</div>
  30. <div class="deviceList_title_text" style="width:15%">状态</div>
  31. <div class="deviceList_title_text" style="width:15%">会议状态</div>
  32. <div class="deviceList_title_text" style="width:24%">操作</div>
  33. <!-- <div class="deviceList_title_text">操作</div> -->
  34. </div>
  35. <div v-show="deviceList" class="deviceList">
  36. <div class="deviceList_list" :class="item.id==itemId?'deviceList_list1':''"
  37. v-for="(item,index) in deviceList" :key="item.id" @mouseover="mouseover(item.id)"
  38. @mouseleave="mouseout()">
  39. <!-- <el-tooltip :content="item.name" placement="bottom" effect="light"> -->
  40. <div class="deviceList_title_text" style="width:15%">{{item.devName}}</div>
  41. <!-- </el-tooltip> -->
  42. <div class="deviceList_title_text" style="width:15%">{{item.imei}}</div>
  43. <div class="deviceList_title_text" style="width:15%">{{item.devTypeName}}
  44. </div>
  45. <div class="deviceList_title_text" style="width:15%">
  46. {{dictionary(item.devStatus,'dev_status',item.imei)}}
  47. </div>
  48. <div class="deviceList_title_text" style="width:15%">
  49. {{dictionary(item.memberStatus,'meeting_member_status')}}
  50. </div>
  51. <div style="width:24%;">
  52. <div v-if="meetingStatus==2">
  53. <div v-if="item.imei == createBy&&item.imei == userName">
  54. <div v-if="item.devStatus==3||item.devStatus==4||item.devStatus==5||item.devStatus==1">
  55. <div style="width:100%;justify-content: center;" class="deviceList_operate">
  56. <div class="deviceList_title_text1" @click="speak('request')"
  57. v-if="item.memberStatus!=3&&item.memberStatus!=1&&item.memberStatus!=4&&item.memberStatus!=5">
  58. <div>开始发言</div>
  59. </div>
  60. <div class="deviceList_title_text1" @click="speak('request')" v-if="item.memberStatus==3">
  61. <div>结束发言</div>
  62. </div>
  63. <div class="deviceList_title_text1" @click="outMeeting" v-if="item.memberStatus==2">离开会议
  64. </div>
  65. <div class="deviceList_title_text1" @click="inMeeting" v-if="item.memberStatus==1">进入会议
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <div v-if="item.imei != createBy">
  71. <div v-if="item.devStatus==3||item.devStatus==4||item.devStatus==5||item.devStatus==1">
  72. <div style="width:100%;justify-content: center;" class="deviceList_operate"
  73. v-show="createBy==userName&&isInOrOutMeeting&&deviceList[0].memberStatus==2">
  74. <div class="deviceList_title_text1" @click="speak('call',item.imei,'start')"
  75. v-if="item.memberStatus!=3&&item.memberStatus!=1&&item.memberStatus!=4&&item.memberStatus!=5">
  76. <div>点名发言</div>
  77. </div>
  78. <div class="deviceList_title_text1" @click="speak('call',item.imei,'end')"
  79. v-if="item.memberStatus==3">
  80. <div>结束发言</div>
  81. </div>
  82. <div class="deviceList_title_text1" @click="inOrOut('out',item.imei)"
  83. v-if="item.memberStatus==2">请离会议</div>
  84. <div class="deviceList_title_text1" @click="inOrOut('in',item.imei)"
  85. v-if="item.memberStatus==1">拉入会议</div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import Header from "../home/header/index";
  101. import Footer from "../home/footer/index";
  102. import webSocketClass from "@/utils/webSocket";
  103. import { postWarnStatus } from "@/api/AlarmRecord";
  104. import organizationTree from "./deviceTree/organizationTree"
  105. import { devicetree } from "@/api/system/deviceTree";
  106. import { timestampToTime } from "../../../utils/time.js"
  107. import { addGroup, delGroup, getGroup, listGroup, updateGroup, updateMeetingStatus, selectDeviceGroupDetailList, deviceRequestTalking, inOrOutMeeting } from "@/api/system/group";
  108. import { listData } from "@/api/system/dict/data";
  109. import Ctibar from './AgentBar/ctibar.js';
  110. var audio = document.getElementById('audio');
  111. var constraints = {
  112. audio: true,
  113. video: true,
  114. mandatory: {
  115. maxWidth: 640,
  116. maxHeight: 360
  117. }
  118. };
  119. URL = window.URL || window.webkitURL;
  120. var eventHandlers = {
  121. 'progress': function (e) {
  122. console.log('call is in progress');
  123. },
  124. 'failed': function (e) {
  125. console.log('call failed: ', e);
  126. },
  127. 'ended': function (e) {
  128. console.log('call ended : ', e);
  129. },
  130. 'confirmed': function (e) {
  131. console.log('call confirmed');
  132. }
  133. };
  134. export default {
  135. dicts: ["warn_type"],
  136. components: {
  137. Header,
  138. Footer,
  139. organizationTree
  140. },
  141. data() {
  142. return {
  143. // 以下群组
  144. isGroup: false,
  145. createBy: '',
  146. isInOrOutMeeting: false,
  147. isSpeak: false,
  148. itemId: '',
  149. meetingStatus: '',
  150. groupDetail: {},
  151. isMike: false,
  152. deviceList: null,
  153. meetingName1: "会议未开始",
  154. meetingName: "会议中",
  155. groupName: "",
  156. dataList: null,
  157. userId: JSON.parse(sessionStorage.getItem("userInfo")).userId,
  158. userName: JSON.parse(sessionStorage.getItem("userInfo")).userName,
  159. // 查询参数
  160. queryParams: {
  161. pageNum: 1,
  162. pageSize: 10,
  163. deptId: null,
  164. planName: null,
  165. status: null,
  166. },
  167. total: 0,
  168. deviceTreeList: [],
  169. title: "",
  170. num: 1,
  171. groupId: '',
  172. dictionaryList: [],
  173. websocket: null,
  174. //初始化SDK所需要的配置
  175. config: {
  176. host: '39.152.2.103',
  177. port: '5066',
  178. proto: false,
  179. extNo: '',
  180. extPwd: '20181231',
  181. autoRegister: true,
  182. debug: true,
  183. //stunServer: 'stun.1.google.com', 可自行修改使用stun服务器地址
  184. stateEventListener: this.stateEventListener
  185. },
  186. //坐席分机号
  187. agentNo: '',
  188. //客户号码
  189. customerNo: '',
  190. //拨号弹窗
  191. showDial: false,
  192. //转接弹窗
  193. showTransferDial: false,
  194. //转接号码
  195. transNum: '',
  196. numList: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '0', '#',],
  197. agentStatus: 'DISCONNECTED',
  198. statusMap: {
  199. CONNECTED: '已连接',
  200. DISCONNECTED: '网络断开',
  201. REGISTERED: '已注册',
  202. UNREGISTERED: '未注册',
  203. REGISTER_FAILED: '注册失败',
  204. IN_CALL: '通话中',
  205. INCOMING_CALL: '来电振铃',
  206. OUTGOING_CALL: '外呼振铃',
  207. HOLD: '保持中',
  208. CALL_END: '通话结束'
  209. },
  210. timer: null,
  211. timerString: '00:00:00',
  212. outNum: '',
  213. isHold: true
  214. };
  215. },
  216. computed: {
  217. classObject() {
  218. const bool1 = this.alarmArr.length > 1;
  219. const bool2 = this.alarmArr.length === 1;
  220. return {
  221. tanchuangbox: true,
  222. "tanchuangbox-height-multi": bool1,
  223. "tanchuangbox-height-single": bool2,
  224. };
  225. },
  226. },
  227. mounted() {
  228. this.init()
  229. },
  230. methods: {
  231. // 以下群组
  232. inMeeting() {
  233. this.loadingFun()
  234. var body = {
  235. devImei: this.userName,
  236. flag: 'in',
  237. groupId: this.groupId,
  238. }
  239. inOrOutMeeting(body).then(response => {
  240. if (response.data.success) {
  241. } else {
  242. this.$modal.msgError(response.data.message);
  243. }
  244. this.loading.close();
  245. },
  246. error => {
  247. this.loading.close();
  248. });
  249. },
  250. outMeeting() {
  251. this.loadingFun()
  252. var body = {
  253. devImei: this.userName,
  254. flag: 'out',
  255. groupId: this.groupId,
  256. }
  257. inOrOutMeeting(body).then(response => {
  258. if (response.data.message == '已离开!') {
  259. } else {
  260. this.$modal.msgError(response.data.message);
  261. }
  262. this.loading.close();
  263. },
  264. error => {
  265. this.loading.close();
  266. });
  267. },
  268. inOrOut(flag, devImei) {
  269. this.loadingFun()
  270. var body = {
  271. devImei: devImei,
  272. flag: flag,
  273. groupId: this.groupId,
  274. }
  275. inOrOutMeeting(body).then(response => {
  276. console.log("123123123", response)
  277. if (response.data.success) {
  278. this.$modal.msgSuccess(response.data.message);
  279. } else {
  280. this.$modal.msgError(response.data.message);
  281. }
  282. this.loading.close();
  283. },
  284. error => {
  285. this.loading.close();
  286. });
  287. },
  288. loadingFun() {
  289. this.loading = this.$loading({
  290. lock: true,
  291. text: 'Loading',
  292. spinner: 'el-icon-loading',
  293. background: 'rgba(0, 0, 0, 0.7)'
  294. });
  295. },
  296. speak(type, devImei, flag) {
  297. this.loadingFun()
  298. var flagg = ''
  299. if (type == 'request') {
  300. flagg = !this.isSpeak ? 'start' : 'end'
  301. devImei = this.userName
  302. } else {
  303. flagg = flag
  304. }
  305. var body = {
  306. devImei: devImei,
  307. flag: flagg,
  308. groupId: this.groupId,
  309. type: type,
  310. }
  311. deviceRequestTalking(body).then(response => {
  312. if (response.data.success) {
  313. if (type == 'request') {
  314. }
  315. this.$modal.msgSuccess(response.data.message);
  316. //恢复发言
  317. } else {
  318. this.$modal.msgError(response.data.message);
  319. this.hold()
  320. }
  321. this.loading.close();
  322. },
  323. error => {
  324. this.loading.close();
  325. });
  326. },
  327. // 1、进入元素
  328. mouseover(index) {
  329. this.itemId = index
  330. },
  331. // 4、离开元素
  332. mouseout() {
  333. this.itemId = ''
  334. },
  335. ws() {
  336. console.log('{"groupId":' + this.groupId + '}')
  337. this.websocket.webSocketSendMsg('{"groupId":' + this.groupId + '}')
  338. },
  339. devStatus(devStatus) {
  340. for (const i in this.deviceList) {
  341. if (this.deviceList[i].devStatus == devStatus) {
  342. this.deviceList[i].devStatus = devStatus
  343. }
  344. }
  345. },
  346. dictionary(e, type, imei) {
  347. for (const i in this.dictionaryList) {
  348. if (this.createBy == imei && e == 4) {
  349. return '在线'
  350. }
  351. if (this.dictionaryList[i].dictValue == e && this.dictionaryList[i].dictType == type) {
  352. return this.dictionaryList[i].dictLabel
  353. }
  354. }
  355. },
  356. handleAdd() {
  357. // this.reset();
  358. // this.open = true;
  359. this.title = "添加群组";
  360. },
  361. tableRowClassName({ row, rowIndex }) {
  362. return 'photo';
  363. },
  364. rowClass({ row, rowIndex }) {
  365. return 'text-align: center;background-color: #1A1D30;color: #fff'
  366. },
  367. meetingAll() {
  368. var meetingStatusAll = 2
  369. var params = {
  370. groupId: this.groupId,
  371. meetingStatus: meetingStatusAll
  372. }
  373. updateMeetingStatus(params).then(response => {
  374. if (response.code == 200) {
  375. this.$modal.msgSuccess(response.msg);
  376. } else {
  377. this.$modal.msgError(response.msg);
  378. }
  379. });
  380. },
  381. meeting() {
  382. this.loadingFun()
  383. if (this.deviceList != null) {
  384. console.log('meetingStatusmeetingStatus', this.meetingStatus)
  385. var params = {
  386. groupId: this.groupId,
  387. meetingStatus: this.meetingStatus == 1 ? 2 : 1
  388. }
  389. updateMeetingStatus(params).then(response => {
  390. setTimeout(() => {
  391. if (response.code == 200) {
  392. if (this.meetingStatus == 1) {
  393. if (sessionStorage.getItem('groupId') == this.groupId) {
  394. this.handleAgentBarBtnClick('hangup')
  395. sessionStorage.setItem('groupId', '')
  396. }
  397. this.isInOrOutMeeting = false
  398. this.isHold = true
  399. this.loading.close()
  400. }
  401. }
  402. }, 5000);
  403. });
  404. }
  405. },
  406. //孙组件向父组件传递数据
  407. wsMeetingStatus(isInterface) {
  408. console.log('isMeeting状态:', isInterface)
  409. this.meetingStatus = isInterface
  410. },
  411. groupDeviceItemClick(item) {
  412. // this.handleAgentBarBtnClick('hangup')
  413. this.isSpeak = false
  414. this.deviceList = []
  415. this.groupId = item.id
  416. this.meetingStatus = item.meetingStatus
  417. this.groupName = item.groupName
  418. this.createBy = item.createBy
  419. this.item = item
  420. var params = { groupInfoId: item.id, pageNum: 0, pageSize: 0, }
  421. selectDeviceGroupDetailList(params).then(response => {
  422. this.deviceList = response.rows
  423. this.total = this.deviceList.length
  424. this.ws()
  425. if (this.deviceList[0].memberStatus == 3 &&
  426. this.deviceList[0].imei == this.userName) {
  427. this.isSpeak = true;
  428. }
  429. if (
  430. this.deviceList[0].memberStatus == 2 &&
  431. this.deviceList[0].imei == this.userName
  432. ) {
  433. if (sessionStorage.getItem("groupId") == this.groupId) {
  434. this.isInOrOutMeeting = true
  435. return
  436. }
  437. if (sessionStorage.getItem("groupId")) {
  438. } else {
  439. this.call()
  440. }
  441. }
  442. });
  443. },
  444. onClickDialOutside(event) {
  445. console.log(event)
  446. this.showDial = false
  447. },
  448. onClickTransDialOutside(event) {
  449. this.showTransferDial = false;
  450. },
  451. handleAgentBarBtnClick(name) {
  452. console.log(name + '当前')
  453. if (name === 'login') {
  454. this.login();
  455. } else if (name === 'logout') {
  456. this.logout();
  457. } else if (name === 'answer') {
  458. this.answer();
  459. } else if (name === 'hangup') {
  460. this.hangup();
  461. } else if (name === 'makecall') {
  462. this.makeCall('9*' + this.groupId)
  463. } else if (name === 'hold') {
  464. this.hold();
  465. } else if (name === 'unhold') {
  466. this.unhold();
  467. } else if (name === 'transfer') {
  468. this.transfer(this.transNum)
  469. }
  470. },
  471. login() {
  472. this.init()
  473. Ctibar.register()
  474. },
  475. logout() {
  476. Ctibar.unregister()
  477. },
  478. makeCall(phone) {
  479. if (phone === "" || phone === undefined) {
  480. console.error('无效的号码,请重新输入!');
  481. return
  482. }
  483. Ctibar.makecall(phone);
  484. },
  485. hold() {
  486. Ctibar.hold();
  487. },
  488. unhold() {
  489. Ctibar.unhold();
  490. },
  491. answer() {
  492. Ctibar.answer();
  493. },
  494. hangup() {
  495. Ctibar.hangup();
  496. },
  497. transfer(phone) {
  498. console.info("触发转接", phone)
  499. Ctibar.transfer(phone);
  500. },
  501. //外呼拨号盘
  502. handleDialBtnClick(val) {
  503. this.outNum += val;
  504. this.$refs.outNumInput.focus();
  505. },
  506. //转接拨号盘
  507. handleTransDialBtnClick(val) {
  508. this.transNum += val;
  509. this.$refs.transNumInput.focus();
  510. },
  511. //参数为时间差秒数,返回这两个时间差并格式化
  512. computeTimeDiff(diff) {
  513. diff = Math.round(diff / 1000);
  514. let hour = Math.floor(diff / 3600).toString().padStart(2, '0');
  515. let min = Math.floor((diff - hour * 3600) / 60).toString().padStart(2, '0');
  516. let sec = (diff % 60).toString().padStart(2, '0');
  517. return hour + ':' + min + ':' + sec;
  518. },
  519. //重置时间
  520. restoreTime(origin) {
  521. clearInterval(this.timer);
  522. this.timerString = '00:00:00';
  523. this.timer = setInterval(() => {
  524. this.timerString = this.computeTimeDiff(new Date().getTime() - origin);
  525. }, 1000);
  526. },
  527. //状态变更回调
  528. stateEventListener(event, data) {
  529. //debug使用
  530. console.log('当前event为: ' + event + ', 当前data为: ' + JSON.stringify(data))
  531. this.agentStatus = event
  532. let origin = new Date().getTime();
  533. switch (event) {
  534. case "CONNECTED":
  535. this.agentNo = data.localAgent
  536. this.restoreTime(origin);
  537. break;
  538. case "DISCONNECTED":
  539. this.restoreTime(origin);
  540. break;
  541. case "UNREGISTERED":
  542. this.restoreTime(origin);
  543. break;
  544. case "OUTGOING_CALL":
  545. this.customerNo = data.otherLegNumber;
  546. this.restoreTime(origin);
  547. break;
  548. case "INCOMING_CALL":
  549. this.customerNo = data.otherLegNumber;
  550. //播放来电振铃音
  551. this.playRingMedia();
  552. this.restoreTime(origin);
  553. break;
  554. case "IN_CALL":
  555. this.stopPlayRingMedia();
  556. this.restoreTime(origin);
  557. // this.timer = setInterval(() => {
  558. // }, 1000);
  559. console.log('当前是否hold', this.isHold)
  560. if (this.isHold) {
  561. setTimeout(() => {
  562. this.handleAgentBarBtnClick('hold')
  563. this.isHold = false
  564. // 方法区
  565. }, 500);
  566. }
  567. break;
  568. case "CALL_END":
  569. this.stopPlayRingMedia();
  570. //挂机铃声
  571. this.playHangupMedia()
  572. this.restoreTime(origin);
  573. break;
  574. default:
  575. }
  576. },
  577. //播放挂机铃声
  578. playHangupMedia() {
  579. const _this = this;
  580. var hangupAudio = document.getElementById("hangupMediaAudioId")
  581. if (!hangupAudio) {
  582. hangupAudio = document.createElement('audio');
  583. hangupAudio.id = 'hangupMediaAudioId';
  584. hangupAudio.hidden = true;
  585. hangupAudio.src = 'wav/hangup.wav'
  586. document.body.appendChild(hangupAudio);
  587. }
  588. hangupAudio.play();
  589. },
  590. //播放来电振铃
  591. playRingMedia() {
  592. const _this = this;
  593. _this.stopPlayRingMedia();
  594. var ringAudio = document.getElementById("ringMediaAudioId")
  595. if (!ringAudio) {
  596. ringAudio = document.createElement('audio');
  597. ringAudio.id = 'ringMediaAudioId';
  598. ringAudio.hidden = true;
  599. ringAudio.src = 'wav/ring.wav';
  600. ringAudio.loop = 'loop';
  601. document.body.appendChild(ringAudio);
  602. }
  603. ringAudio.play();
  604. },
  605. //停止播放来电振铃
  606. stopPlayRingMedia() {
  607. const _this = this;
  608. var ringAudio = document.getElementById("ringMediaAudioId");
  609. if (ringAudio) {
  610. document.body.removeChild(ringAudio);
  611. }
  612. },
  613. //初始化方法
  614. init() {
  615. this.config.extNo = this.userName
  616. if (sessionStorage.getItem("freeSwitchWs") != null) {
  617. this.config.host = sessionStorage.getItem("freeSwitchWs").split(":")[0]
  618. this.config.port = sessionStorage.getItem("freeSwitchWs").split(":")[1]
  619. }
  620. Ctibar.initSDK(this.config)
  621. let url = `/ws/` + this.userId + '/group/device/push';
  622. this.websocket = new webSocketClass(url)
  623. this.websocket.getWebSocketMsg(evt => {
  624. // 客户端接收服务端返回的数据
  625. var data = JSON.parse(evt.data);
  626. console.log("websocket返回的数据123:", data);
  627. switch (data.flag) {
  628. case "group"://会议状态
  629. this.$refs.organizationTree.setGroupList(data, this.groupId)
  630. console.log("websocket返回的数据123:", data);
  631. break
  632. case "memberStatus"://成员状态
  633. for (const i in this.deviceList) {
  634. console.log('123123132', data.member);
  635. if (this.deviceList[i].imei == data.member) {
  636. this.deviceList[i].devStatus = data.memberStatus;
  637. }
  638. }
  639. break
  640. case "memberMeetingStatus"://成员会议状态
  641. for (const i in this.deviceList) {
  642. if (this.deviceList[i].imei == data.member) {
  643. this.deviceList[i].memberStatus = data.memberMeetingStatus;
  644. }
  645. }
  646. if (this.groupId == data.groupId && this.userName == data.member && this.createBy == data.member) {
  647. if (data.memberMeetingStatus == 3) {
  648. this.isSpeak = true;
  649. this.unhold()
  650. console.log('数据this.isInOrOutMeeting1111', this.isSpeak)
  651. } else {
  652. this.isSpeak = false;
  653. this.hold()
  654. }
  655. }
  656. if (data.memberMeetingStatus == 4) {
  657. this.loading.close()
  658. }
  659. if (!this.isInOrOutMeeting && this.groupId == data.groupId && this.userName == data.member && this.createBy == data.member && data.memberMeetingStatus == 2) {
  660. this.hold()
  661. if (sessionStorage.getItem("groupId") &&
  662. sessionStorage.getItem("groupId") !== this.groupId) {
  663. } else {
  664. console.log('this.isInOrOutMeeting1111', data.memberMeetingStatus)
  665. this.call()
  666. }
  667. }
  668. if (this.createBy == data.member && data.memberMeetingStatus == 1 && this.userName == data.member) {
  669. this.handleAgentBarBtnClick('hangup')
  670. sessionStorage.setItem("groupId", '')
  671. this.isInOrOutMeeting = false
  672. this.isSpeak = false
  673. this.isHold = true
  674. }
  675. break
  676. }
  677. })
  678. },
  679. setGroup(group) {
  680. this.isGroup = group
  681. },
  682. call() {
  683. this.handleAgentBarBtnClick('makecall')
  684. sessionStorage.setItem("groupId", this.groupId)
  685. this.isInOrOutMeeting = true
  686. if (this.deviceList[0].imei != this.createBy) {
  687. // this.groupDeviceItemClick(this.item)
  688. }
  689. var that = this
  690. window.onbeforeunload = (e) => {
  691. console.log('this.isInOrOutMeeting', that.isInOrOutMeeting)
  692. if (that.isInOrOutMeeting) {
  693. that.handleAgentBarBtnClick('hangup')
  694. sessionStorage.setItem("groupId", '')
  695. that.websocket.closeSocket()
  696. window.onbeforeunload = null
  697. }
  698. }
  699. this.loading.close()
  700. this.isInOrOutMeeting = true
  701. this.isHold = true
  702. }
  703. },
  704. beforeDestroy() { //进行监听销毁
  705. console.log('1231232131232132131,', this.isInOrOutMeeting)
  706. if (this.isInOrOutMeeting) {
  707. this.handleAgentBarBtnClick('hangup')
  708. sessionStorage.setItem("groupId", '')
  709. this.websocket.closeSocket()
  710. window.onbeforeunload = null
  711. }
  712. },
  713. };
  714. </script>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/685694
推荐阅读
相关标签
  

闽ICP备14008679号