guhongwei 4 tahun lalu
induk
melakukan
0eefcb5b83
2 mengubah file dengan 20 tambahan dan 7 penghapusan
  1. 1 0
      src/components/chat.vue
  2. 19 7
      src/views/user/afterClassChat.vue

+ 1 - 0
src/components/chat.vue

@@ -53,6 +53,7 @@ export default {
     // 发言提交
     speak() {
       this.$emit('speak', this.contInput);
+      this.contInput = '';
     },
   },
   computed: {

+ 19 - 7
src/views/user/afterClassChat.vue

@@ -20,9 +20,10 @@ import chat from '@/components/chat.vue';
 import NavBar from '@/layout/common/topTitle.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: answerapply } = createNamespacedHelpers('answerapply');
+const { mapActions: chatroom } = createNamespacedHelpers('chatroom');
 const { mapActions: answerchat } = createNamespacedHelpers('answerchat');
 export default {
-  metaInfo: { title: '请假管理' },
+  metaInfo: { title: '答疑聊天' },
   name: 'afterClassChat',
   props: {},
   components: {
@@ -37,7 +38,8 @@ export default {
       navShow: true,
       // 聊天列表
       chatList: [],
-      // 房间信息
+      // 答疑详情
+      answerInfo: {},
       room: {},
     };
   },
@@ -46,21 +48,32 @@ export default {
     await this.search();
   },
   methods: {
+    ...chatroom({ chatroomCreate: 'create' }),
     ...answerchat(['query', 'fetch', 'create']),
     ...answerapply({ answerapplyFetch: 'fetch' }),
     async searchInfo() {
       if (this.id) {
-        // 房间详情
+        // 创建房间
         let res = await this.answerapplyFetch(this.id);
         if (this.$checkRes(res)) {
-          this.$set(this, `room`, res.data);
-          this.channel();
+          this.$set(this, `answerInfo`, res.data);
+          let data = {
+            teacherid: this.answerInfo.teacherid,
+            teacher: this.answerInfo.teacher,
+            studentid: this.user.userid,
+            student: this.user.name,
+          };
+          let createRoom = await this.chatroomCreate(data);
+          if (this.$checkRes(createRoom)) {
+            this.$set(this, `room`, createRoom.data);
+            this.channel();
+          }
         }
       }
     },
     // 房间聊天列表
     async search() {
-      let res = await this.query({ room: this.room._id });
+      let res = await this.query({ room: this.room.number });
       if (this.$checkRes(res)) {
         this.$set(this, `chatList`, res.data);
       }
@@ -95,7 +108,6 @@ export default {
       };
       let res = await this.create(data);
       if (this.$checkRes(res)) {
-        console.log(res.data);
       }
     },
   },