Browse Source

聊天记录没判断undefined错误

PC-202203201608\Administrator\gaopeng 1 year ago
parent
commit
0d6e2e7b9b
1 changed files with 22 additions and 10 deletions
  1. 22 10
      src/views/chat/index.vue

+ 22 - 10
src/views/chat/index.vue

@@ -438,11 +438,21 @@ export default {
   },
   computed: {
     canChat() {
-      console.log(this.sceneId, 'this.sceneId');
+      console.log(this.info, 'this.info');
       if (!this.sceneId) {
-        return this.info.isDelete == 0
+        if (this.info.isDelete == 1) {
+          console.log(1);
+          return false
+        } else {
+          console.log(2);
+          return true
+        }
       } else {
-        return this.sceneInfo.isDelete == 0
+        if (this.sceneInfo.isDelete == 1) {
+          return false
+        } else {
+          return true
+        }
       }
     },
     showNodata() {
@@ -745,15 +755,17 @@ export default {
     async getChatCharacterRecords() {
       let res = await getChatCharacterRecordsApi()
       console.log(res, '聊天记录');
-      for (let i = 0; i < res.data.length; i++) {
-        const element = res.data[i];
-        if(this.info.id == element.id) {
-          element.open = true
-        } else {
-          element.open = false
+      if (res.data) {
+        for (let i = 0; i < res.data.length; i++) {
+          const element = res.data[i];
+          if(this.info.id == element.id) {
+            element.open = true
+          } else {
+            element.open = false
+          }
         }
+        this.allRecords = res.data
       }
-      this.allRecords = res.data
     },
     // 新增对话记录
     async addChat() {