lrf402788946 5 years ago
parent
commit
4dcff9dc18
1 changed files with 10 additions and 21 deletions
  1. 10 21
      src/views/hall/hallDetail.vue

+ 10 - 21
src/views/hall/hallDetail.vue

@@ -51,8 +51,8 @@
               </el-col>
               <el-col :span="24" class="info">
                 <template v-for="(i, index) in mainTalk">
-                  <span :key="`${index + new Date().getTime() + 1}`">[{{ i.send_time }}]</span>
-                  <span v-html="i.content" :key="`${index + new Date().getTime() + 2}`"></span>
+                  <span :key="`sellTime${i.id}`">[{{ i.send_time }}]</span>
+                  <span v-html="i.content" :key="`sellContent${i.id}${index}`"></span>
                 </template>
               </el-col>
             </el-col>
@@ -62,8 +62,8 @@
               </el-col>
               <el-col :span="24" class="info">
                 <template v-for="(i, index) in otherTalk">
-                  <span :key="`${index + new Date().getTime() + 3}`">[{{ i.send_time }}]</span>
-                  <span v-html="i.content" :key="`${index + new Date().getTime() + 4}`"></span>
+                  <span :key="`buyTime${i.id}${index}`">[{{ i.send_time }}]</span>
+                  <span v-html="i.content" :key="`buyContent${i.id}${index}`"></span>
                 </template>
               </el-col>
             </el-col>
@@ -112,20 +112,8 @@ export default {
   components: { wangEditor },
   data: () => ({
     content: '',
-    mainTalk: [
-      {
-        sender_name: 'test main',
-        content: '<p>test test</p>',
-        send_time: '10:29:20',
-      },
-    ],
-    otherTalk: [
-      {
-        sender_name: 'test others',
-        content: '<p>test others</p>',
-        send_time: '11:05:10',
-      },
-    ],
+    mainTalk: [],
+    otherTalk: [],
     info: {},
     buyerList: [],
     sellerList: [],
@@ -155,7 +143,7 @@ export default {
         this.$message.error('游客不能发言,请先注册');
         return;
       }
-      if (this.text != '') {
+      if (this.content != '') {
         let object = { number: this.id, sender_name: this.user.name, content: this.content };
         if (this.user.uid) object.sender_id = this.user.uid;
         let res = await this.create(object);
@@ -173,8 +161,9 @@ export default {
       if (body) {
         body = JSON.parse(body);
         let is_seller = this.sellerList.find(f => f.user_id == body.sender_id);
-        if (is_seller) this.mainTalk.push({ sender_name: body.sender_name, send_time: body.send_time, content: body.content });
-        else this.otherTalk.push({ sender_name: body.sender_name, send_time: body.send_time, content: body.content });
+        if (is_seller) this.mainTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
+        else this.otherTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
+        this.content = '';
       }
     },
   },