From b049ff3be233ce9bb7b0febba18b17f0b23eac4d Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Fri, 8 Nov 2019 19:32:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/baseUrl.js | 4 +- src/views/trainRoom/e-roles.vue | 3 -- src/views/trainRoom/index.vue | 66 ++++++++++++++++++++------------- 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/utils/baseUrl.js b/src/utils/baseUrl.js index 469782cec..7d8b3150c 100644 --- a/src/utils/baseUrl.js +++ b/src/utils/baseUrl.js @@ -5,9 +5,9 @@ export function getBaseUrl() { // BASE_API = 'https://joylink.club/jlcloud'; // BASE_API = 'https://test.joylink.club/jlcloud'; // BASE_API = 'http://192.168.3.5:9000'; // 袁琪 - // BASE_API = 'http://192.168.3.6:9000'; // 旭强 + BASE_API = 'http://192.168.3.6:9000'; // 旭强 // BASE_API = 'http://192.168.3.41:9000'; // 杜闪 - BASE_API = 'http://192.168.3.82:9000'; // 杜康 + // BASE_API = 'http://192.168.3.82:9000'; // 杜康 } else { BASE_API = process.env.VUE_APP_BASE_API; } diff --git a/src/views/trainRoom/e-roles.vue b/src/views/trainRoom/e-roles.vue index 8401c846a..a765cb632 100644 --- a/src/views/trainRoom/e-roles.vue +++ b/src/views/trainRoom/e-roles.vue @@ -344,9 +344,6 @@ export default { this.loading = true; const res = await putJointTrainingSimulation(this.group); this.mapId = res.data.mapId; - if (res.data.state == '01') { - this.starting = false; - } this.loading = false; }, async handleExit() { diff --git a/src/views/trainRoom/index.vue b/src/views/trainRoom/index.vue index aef539d00..cb00bdd47 100644 --- a/src/views/trainRoom/index.vue +++ b/src/views/trainRoom/index.vue @@ -163,15 +163,15 @@ export default { const index = this.members.findIndex(elem => { return user.id == elem.id; }); if (user.userRole) { if (index >= 0) { + this.checkUserState(user, this.members[index]); this.members.splice(index, 1, Object.assign(this.members[index], this.transformUser(user))); - this.checkUserState(user, 'upd'); } else { + this.checkUserState(user, null); this.members.push(this.transformUser(user)); - this.checkUserState(user, 'add'); } } else { + this.checkUserState(user, this.members[index]); this.members.splice(index, 1); - this.checkUserState(user, 'del'); } }); }, @@ -189,32 +189,48 @@ export default { // 清空房间信息 this.$store.dispatch('socket/setJointRoomInfo'); }, - async checkUserState(user, operate) { - switch (operate) { - case 'add': - this.$store.dispatch('socket/setChatContent', {roomTip: `${user.nickName}进入房间`}); - break; - case 'upd': - if (!user.inRoom) { - this.$store.dispatch('socket/setChatContent', {roomTip: `${user.nickName}退出房间`}); + async checkUserState(user, old) { + const message = { + join: true, + id: user.id, + userName: user.nickName, + userRole: user.userRole, + name: user.name, + roomTip: '', + chatInfo: true, + inSimulation: user.inSimulation, + inRoom: user.inRoom, + session: 'session', + oneself: user.id === this.$store.state.user.id + }; + + if (old) { + if (old.userRole) { + if (!user.inRoom) { + this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}退出房间`}); + if (this.userId == user.id) { + this.jumpOutRoom(); + } + } + + if (!old.inRoom && user.inRoom) { + this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}进入房间`}); + } + + if (user.inSimulation) { + this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}进入仿真`}); + if (this.userId == user.id) { + this.jumpInSimulation(); + } + } + } else { + this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}被提出房间`}); if (this.userId == user.id) { this.jumpOutRoom(); } } - - if (user.inSimulation) { - this.$store.dispatch('socket/setChatContent', {roomTip: `${user.nickName}进入仿真`}); - if (this.userId == user.id) { - this.jumpInSimulation(); - } - } - break; - case 'del': - this.$store.dispatch('socket/setChatContent', {roomTip: `${user.nickName}被提出房间`}); - if (this.userId == user.id) { - this.jumpOutRoom(); - } - break; + } else { + this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}进入房间`}); } }, async jumpInSimulation() {