SanHQin 5 месяцев назад
Родитель
Сommit
c262486dbd

+ 19 - 3
src/components/classRoomHelper/component/dialogArea.vue

@@ -440,7 +440,8 @@ export default {
       saveUid: "",
       aiTalkList: [],
       aiIsTalk: false,
-      aiTalkUid: ""
+      aiTalkUid: "",
+			userName:"",
     };
   },
   computed: {
@@ -829,13 +830,13 @@ export default {
       };
     },
     //保存消息
-    insertChat(_uid) {
+    async insertChat(_uid) {
       if (_uid == "") return;
       let _data = this.chatList.find(i => i.uid == _uid);
       if (!_data) return;
       let params = {
         userId: this.userid,
-        userName: "qgt",
+        userName: this.userName?this.userName:await this.getUser(this.userid),
         groupId: "602def61-005d-11ee-91d8-005056b8q12w",
         answer: _data.aiContent,
         problem: _data.content,
@@ -849,6 +850,21 @@ export default {
       this.ajax
         .post("https://gpt4.cocorobo.cn/insert_chat", params)
         .then(res => {});
+    },
+		getUser(uid) {
+      return new Promise(resolve => {
+        let params = { uid: uid };
+        this.ajax
+          .get(this.$store.state.api + "getUser", params)
+          .then(res => {
+            let data = res.data[0][0];
+						this.userName = data.username;
+						resolve(data.username)
+          })
+          .catch(err => {
+            console.error(err);
+          });
+      });
     },
     // 获取对应的聊天记录
     getChatList() {

+ 18 - 2
src/components/classRoomHelper/component/searchArea.vue

@@ -1507,6 +1507,7 @@ export default {
       showTips: false,
 			showTipsList:[],
 			languageSetting:0,
+			userName:"",
     };
   },
   computed: {
@@ -2507,13 +2508,13 @@ ${_atList
       };
     },
     //保存消息
-    insertChat(_uid) {
+    async insertChat(_uid) {
       if (_uid == "") return;
       let _data = this.chatList.find(i => i.uid == _uid);
       if (!_data) return;
       let params = {
         userId: this.userid,
-        userName: "qgt",
+        userName: this.userName?this.userName:await this.getUser(this.userid),
         groupId: "602def61-005d-11ee-91d8-005056b8q12w",
         answer: _data.aiContent,
         problem: _data.content,
@@ -2527,6 +2528,21 @@ ${_atList
       this.ajax
         .post("https://gpt4.cocorobo.cn/insert_chat", params)
         .then(res => {});
+    },
+		getUser(uid) {
+      return new Promise(resolve => {
+        let params = { uid: uid };
+        this.ajax
+          .get(this.$store.state.api + "getUser", params)
+          .then(res => {
+            let data = res.data[0][0];
+						this.userName = data.username;
+						resolve(data.username)
+          })
+          .catch(err => {
+            console.error(err);
+          });
+      });
     },
     // 获取对应的聊天记录
     getChatList() {