index.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="btn">
  6. <el-button type="primary" size="mini" @click="openBtn">在线客服</el-button>
  7. </el-col>
  8. </el-col>
  9. </el-row>
  10. <el-dialog title="在线聊天" :visible.sync="show" width="40%" :before-close="close" :close-on-click-modal="false" :close-on-press-escape="false">
  11. <chat-frame :userInfo="userInfo"></chat-frame>
  12. </el-dialog>
  13. </div>
  14. </template>
  15. <script>
  16. import chatFrame from '@c/chat.vue';
  17. import { mapState, createNamespacedHelpers } from 'vuex';
  18. var moment = require('moment');
  19. export default {
  20. name: 'index',
  21. props: {},
  22. components: {
  23. chatFrame,
  24. },
  25. data: function () {
  26. return {
  27. show: false,
  28. userInfo: {},
  29. };
  30. },
  31. created() {},
  32. methods: {
  33. // 打开在线聊天
  34. openBtn() {
  35. // 创建用户
  36. let data = {
  37. _tenant: 'platform',
  38. client_id: '5fa34a8e3849fd0eecf7f1c6',
  39. client_name: '顾红伟',
  40. };
  41. this.$set(this, `userInfo`, data);
  42. this.show = true;
  43. },
  44. // 关闭在线聊天
  45. close() {
  46. this.show = false;
  47. },
  48. },
  49. computed: {
  50. ...mapState(['user']),
  51. },
  52. metaInfo() {
  53. return { title: this.$route.meta.title };
  54. },
  55. watch: {
  56. test: {
  57. deep: true,
  58. immediate: true,
  59. handler(val) {},
  60. },
  61. },
  62. };
  63. </script>
  64. <style lang="less" scoped>
  65. /deep/.el-dialog__body {
  66. padding: 10px;
  67. height: 500px;
  68. overflow: hidden;
  69. }
  70. </style>