guhongwei 3 年 前
コミット
8b13d8ca3a

+ 3 - 0
src/store/index.js

@@ -23,6 +23,8 @@ import dockUser from '@common/src/store/dock/dock_user';
 import dockVip from '@common/src/store/dock/dockVip';
 import dockVip from '@common/src/store/dock/dockVip';
 // 交易记录
 // 交易记录
 import dockTranscation from '@common/src/store/dock/dockTranscation';
 import dockTranscation from '@common/src/store/dock/dockTranscation';
+// 公共聊天
+import dockChat from '@common/src/store/dock/dockChat';
 // 培训问诊
 // 培训问诊
 import trainLive from '@common/src/store/trainLive';
 import trainLive from '@common/src/store/trainLive';
 import trainchat from '@common/src/store/trainchat';
 import trainchat from '@common/src/store/trainchat';
@@ -77,6 +79,7 @@ export default new Vuex.Store({
     dockUser,
     dockUser,
     dockVip,
     dockVip,
     dockTranscation,
     dockTranscation,
+    dockChat,
     trainLive,
     trainLive,
     trainchat,
     trainchat,
     channel,
     channel,

+ 29 - 4
src/views/achieveLive/detail/chatData.vue

@@ -46,6 +46,7 @@
 
 
 <script>
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: dockChat } = createNamespacedHelpers('dockChat');
 var moment = require('moment');
 var moment = require('moment');
 export default {
 export default {
   name: 'chatData',
   name: 'chatData',
@@ -66,20 +67,37 @@ export default {
       textList: [{ name: '欢迎欢迎' }, { name: '科技创新' }, { name: '大咖云集' }],
       textList: [{ name: '欢迎欢迎' }, { name: '科技创新' }, { name: '大咖云集' }],
     };
     };
   },
   },
-  created() {},
+  created() {
+    if (this.dock_id) this.search();
+  },
+  mounted() {
+    this.scrollToBottom();
+  },
+  //每次页面渲染完之后滚动条在最底部
+  updated() {
+    this.scrollToBottom();
+  },
   methods: {
   methods: {
+    ...dockChat(['query', 'create']),
+    async search() {
+      let res = await this.query({ dock_id: this.dock_id });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+      }
+    },
     async send() {
     async send() {
       let data = {
       let data = {
         dock_id: this.dock_id,
         dock_id: this.dock_id,
         content: this.text,
         content: this.text,
         sender_id: this.user ? this.user.id : this.getData(),
         sender_id: this.user ? this.user.id : this.getData(),
         sender_name: this.user ? this.user.name : this.getData() + '游客',
         sender_name: this.user ? this.user.name : this.getData() + '游客',
+        send_time: moment().format('yyyy-MM-DD HH:mm:ss'),
       };
       };
       if (data.content != '') {
       if (data.content != '') {
-        console.log(data);
-        // const res = await this.create(data);
-        // this.$checkRes(res, null, '发言成功' || '发言失败');
+        const res = await this.create(data);
+        this.$checkRes(res, null, '发言成功' || '发言失败');
         this.$set(this, 'text', '');
         this.$set(this, 'text', '');
+        this.search();
       } else this.$message.error('请输入信息后发送');
       } else this.$message.error('请输入信息后发送');
     },
     },
     textBtn(text) {
     textBtn(text) {
@@ -91,6 +109,13 @@ export default {
       let date = moment(new Date()).valueOf();
       let date = moment(new Date()).valueOf();
       if (date) return date;
       if (date) return date;
     },
     },
+    // 整理滚动条
+    scrollToBottom: function() {
+      this.$nextTick(() => {
+        var container = this.$el.querySelector('.first_1');
+        container.scrollTop = container.scrollHeight;
+      });
+    },
   },
   },
   computed: {
   computed: {
     ...mapState(['user']),
     ...mapState(['user']),

+ 14 - 0
src/views/achieveLive/detail/imgtextData.vue

@@ -93,6 +93,13 @@ export default {
   created() {
   created() {
     if (this.dock_id) this.search();
     if (this.dock_id) this.search();
   },
   },
+  mounted() {
+    this.scrollToBottom();
+  },
+  //每次页面渲染完之后滚动条在最底部
+  updated() {
+    this.scrollToBottom();
+  },
   methods: {
   methods: {
     ...dockImgtxt(['query']),
     ...dockImgtxt(['query']),
     ...dockTranscation({ transQuery: 'query' }),
     ...dockTranscation({ transQuery: 'query' }),
@@ -123,6 +130,13 @@ export default {
       else if (val == '3') return '交易完成';
       else if (val == '3') return '交易完成';
       else if (val == '4') return '交易失败';
       else if (val == '4') return '交易失败';
     },
     },
+    // 整理滚动条
+    scrollToBottom: function() {
+      this.$nextTick(() => {
+        var container = this.$el.querySelector('.first');
+        container.scrollTop = container.scrollHeight;
+      });
+    },
   },
   },
   computed: {
   computed: {
     ...mapState(['user']),
     ...mapState(['user']),