lrf402788946 5 năm trước cách đây
mục cha
commit
cb67c10ffe
2 tập tin đã thay đổi với 11 bổ sung5 xóa
  1. 5 0
      src/components/wang-editor.vue
  2. 6 5
      src/views/hall/hallDetail.vue

+ 5 - 0
src/components/wang-editor.vue

@@ -38,6 +38,7 @@ export default {
   data() {
     return {
       editorContent: this.value,
+      editor: undefined,
     };
   },
   mounted() {
@@ -67,11 +68,15 @@ export default {
     };
     editor.create();
     editor.txt.html(this.value);
+    this.$set(this, `editor`, editor);
   },
   methods: {
     getContent: function() {
       return this.editorContent;
     },
+    setContent() {
+      this.editor.txt.clear();
+    },
   },
 };
 </script>

+ 6 - 5
src/views/hall/hallDetail.vue

@@ -51,7 +51,7 @@
               </el-col>
               <el-col :span="24" class="info" style="height: 402px;overflow: auto;">
                 <template v-for="(i, index) in mainTalk">
-                  <span :key="`sellTime${i.id}`">[{{ i.send_time }}]</span>
+                  <span :key="`sellTime${i.id}`">[{{ i.send_time }}] {{ i.sender_name }}</span>
                   <span v-html="i.content" :key="`sellContent${i.id}${index}`"></span>
                 </template>
               </el-col>
@@ -62,14 +62,13 @@
               </el-col>
               <el-col :span="24" class="info" style="height: 402px;overflow: auto;">
                 <template v-for="(i, index) in otherTalk">
-                  <span :key="`buyTime${i.id}${index}`">[{{ i.send_time }}]</span>
+                  <span :key="`buyTime${i.id}${index}`">[{{ i.send_time }}] {{ i.sender_name }}</span>
                   <span v-html="i.content" :key="`buyContent${i.id}${index}`"></span>
                 </template>
               </el-col>
             </el-col>
             <el-col :span="24" class="hallDetailInput" style="text-align:center">
-              <wang-editor v-model="content" style="height:130px;padding-bottom:120px" v-if="sending"></wang-editor>
-              <wang-editor v-model="text" style="height:130px;padding-bottom:120px" v-else></wang-editor>
+              <wang-editor v-model="content" style="height:130px;padding-bottom:120px" ref="editor"></wang-editor>
               <el-button type="primary" @click="sendMessage">发送</el-button>
             </el-col>
           </el-col>
@@ -142,7 +141,7 @@ export default {
       }
     },
     async sendMessage() {
-      // this.$set(this, `sending`, false);
+      this.$set(this, `sending`, false);
       if (!this.user.uid) {
         this.$message.error('游客不能发言,请先注册');
         return;
@@ -151,6 +150,8 @@ export default {
         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);
+        console.log(this.$refs.editor);
+        this.$refs.editor.setContent();
         this.$set(this, `content`, '');
         this.$forceUpdate();
         this.$checkRes(res, null, res.errmsg || '发言失败');