Explorar el Código

直播间修改

yuhongqi hace 12 horas
padre
commit
0ed7e46228
Se han modificado 1 ficheros con 40 adiciones y 11 borrados
  1. 40 11
      src/views/live/liveConsole/LiveConsole.vue

+ 40 - 11
src/views/live/liveConsole/LiveConsole.vue

@@ -129,6 +129,7 @@
                     <a style="cursor: pointer;color: #ff0000;padding: 8px 8px 0 0;font-size: 12px;" @click.stop="blockUser(m)">拉黑</a>
                     <a v-if="m.singleVisible === 1" style="cursor: pointer;color: #ff0000;padding: 8px 8px 0 0;font-size: 12px;" @click.stop="singleVisible(m)">解除用户自见</a>
                     <a v-else style="cursor: pointer;color: #ff0000;padding: 8px 8px 0 0;font-size: 12px;" @click.stop="singleVisible(m)">用户自见</a>
+                    <a style="cursor: pointer;color: #ff0000;padding: 8px 8px 0 0;font-size: 12px;" @click.stop="replyUser(m)">回复</a>
                     <a style="cursor: pointer;color: #ff0000;padding: 8px 8px 0 0;font-size: 12px;" @click.stop="deleteMsg(m)">删除</a>
                   </el-col>
                 </el-row>
@@ -184,7 +185,7 @@
         <div class="message-actions">
           <button @click="sendMessage">发送消息</button>
           <button @click="sendPopMessage">弹窗消息</button>
-          <button @click="showTopMsgDialog">顶部消息</button>
+          <button @click="showTopMsgDialog">官方消息</button>
         </div>
       </div>
     </div>
@@ -230,8 +231,8 @@
       </div>
     </div>
 
-    <!-- 顶部消息对话框 -->
-    <el-dialog title="发送顶部消息" :visible.sync="topMsgDialogVisible" width="500px">
+    <!-- 官方消息对话框 -->
+    <el-dialog title="发送官方消息" :visible.sync="topMsgDialogVisible" width="500px">
       <el-form :model="topMsgForm" label-width="100px">
         <el-form-item label="消息内容">
           <el-input
@@ -530,6 +531,25 @@ export default {
       }
       this.socket.send(JSON.stringify(msg))
     },
+    replyUser(m) {
+      this.$prompt('请输入回复内容', '回复 ' + (m.nickName || m.userId), {
+        confirmButtonText: '发送',
+        cancelButtonText: '取消',
+        inputPattern: /\S+/,
+        inputErrorMessage: '回复内容不能为空'
+      }).then(({ value }) => {
+        const msg = {
+          liveId: this.liveId,
+          userId: m.userId,
+          userType: 1,
+          cmd: 'replyUser',
+          msg: value.trim(),
+          avatar: this.$store.state.user.user.avatar,
+          nickName: this.$store.state.user.user.nickName
+        }
+        this.socket.send(JSON.stringify(msg))
+      }).catch(() => {})
+    },
     deleteMsg(m){
       // 1. 弹出确认对话框
       this.$confirm('此操作将永久删除该消息, 是否继续?', '提示', {
@@ -649,13 +669,13 @@ export default {
 
       this.newMsg = '';
     },
-    // 显示顶部消息对话框
+    // 显示官方消息对话框
     showTopMsgDialog() {
       this.topMsgForm.msg = '';
       this.topMsgForm.duration = 5;
       this.topMsgDialogVisible = true;
     },
-    // 发送顶部消息
+    // 发送官方消息
     sendTopMessage() {
       // 发送前简单校验
       if (this.topMsgForm.msg.trim() === '') {
@@ -682,7 +702,7 @@ export default {
       this.socket.send(JSON.stringify(msg))
 
       this.topMsgDialogVisible = false;
-      this.$message.success('顶部消息发送成功');
+      this.$message.success('官方消息发送成功');
     },
     sendMessage() {
       // 发送前简单校验
@@ -705,10 +725,20 @@ export default {
       this.newMsg = '';
     },
     handleWsMessage(event) {
-      let { code, data } = JSON.parse(event.data)
-      if (code === 200) {
-        let { cmd } = data
-        if (cmd === 'sendMsg') {
+      const res = JSON.parse(event.data)
+      const { code, data, msg } = res
+      if (code !== 200) {
+        this.$message.error(msg || '操作失败')
+        return
+      }
+      if (!data) {
+        if (msg) {
+          this.$message.success(msg)
+        }
+        return
+      }
+      let { cmd } = data
+      if (cmd === 'sendMsg') {
           let message = JSON.parse(data.data)
 
           let user = this.alDisplayList.find(u => u.userId === message.userId)
@@ -782,7 +812,6 @@ export default {
         } else if (cmd === 'live_end') {
 
         }
-      }
     },
     getLive(){
       getLive(this.liveId).then(res => {