guhongwei 4 роки тому
батько
коміт
6d08b79ff1

+ 9 - 4
src/views/userCenter/message/index.vue

@@ -6,11 +6,11 @@
         <span v-if="view == 'room'">
           <rooms :list="list" @toChat="toChat"></rooms>
         </span>
-        <span v-else>
-          <chat :room="room" @toRoom="toRoom"></chat>
-        </span>
       </el-col>
     </el-row>
+    <el-dialog title="聊天" :visible.sync="dialogVisible" width="50%" :before-close="handleClose">
+      <chat :room="room" @toRoom="toRoom"></chat>
+    </el-dialog>
   </div>
 </template>
 
@@ -32,6 +32,7 @@ export default {
     return {
       view: 'room',
       list: [],
+      dialogVisible: false,
       room: {},
     };
   },
@@ -55,7 +56,7 @@ export default {
       let res = await this.fetch(data.id);
       if (this.$checkRes(res)) {
         this.$set(this, `room`, res.data);
-        this.view = 'chat';
+        this.dialogVisible = true;
       }
     },
     toRoom() {
@@ -80,6 +81,10 @@ export default {
         this.$set(this, `list`, arr);
       }
     },
+    // 关闭
+    handleClose(done) {
+      done();
+    },
   },
   computed: {
     ...mapState(['user']),

+ 4 - 9
src/views/userCenter/message/parts/chat.vue

@@ -1,9 +1,6 @@
 <template>
   <div id="chats">
     <el-row :span="24" class="chat">
-      <el-col :span="24" style="padding-bottom:5px;text-align: right;">
-        <el-button size="mini" @click="$emit('toRoom')" icon="el-icon-arrow-left" type="primary">返回</el-button>
-      </el-col>
       <el-col :span="24" class="chatInfo" id="chatBorder" ref="chatBorder">
         <template v-for="(i, index) in talk">
           <template v-if="isSender(i, index)">
@@ -22,8 +19,8 @@
         </template>
       </el-col>
       <el-col :span="24" class="chatBtn">
-        <wang-editor v-model="content" style="height:130px;padding-bottom:120px" ref="editor"></wang-editor>
-        <el-button type="primary" @click="chatClick">发送</el-button>
+        <el-input v-model="content" type="textarea"></el-input>
+        <el-button type="primary" @click="chatClick" style="margin:10px 0;">发送</el-button>
       </el-col>
     </el-row>
   </div>
@@ -39,9 +36,7 @@ export default {
   props: {
     room: { type: Object, default: () => {} },
   },
-  components: {
-    wangEditor,
-  },
+  components: {},
   data: () => {
     return {
       content: '',
@@ -71,7 +66,7 @@ export default {
         obj.receiver_id = fres === 'buyer_id' ? this.room['seller_id'] : this.room['buyer_id'];
         obj.receiver_name = fres === 'buyer_id' ? this.room['seller_name'] : this.room['buyer_name'];
         let res = await this.create(obj);
-        this.$refs.editor.setContent();
+        // this.$refs.editor.setContent();
         this.$set(this, `content`, '');
         this.$forceUpdate();
         if (this.$checkRes(res, null, res.errmsg || '发言失败')) {