作者 小范

AI客服

@@ -27,7 +27,8 @@ Vue.filter('datefmt',function(input,fmtstring){ @@ -27,7 +27,8 @@ Vue.filter('datefmt',function(input,fmtstring){
27 return moment(input).format(fmtstring) 27 return moment(input).format(fmtstring)
28 28
29 }); 29 });
30 - 30 +import Chat from 'vue-beautiful-chat'
  31 +Vue.use(Chat)
31 // 注册websocket组件到VUE 32 // 注册websocket组件到VUE
32 // Vue.prototype.socketApi = socketApi 33 // Vue.prototype.socketApi = socketApi
33 34
@@ -155,8 +155,8 @@ import matter from './views/airtransport/matter.vue' @@ -155,8 +155,8 @@ import matter from './views/airtransport/matter.vue'
155 //国际转运 155 //国际转运
156 import transfer from './views/airtransport/transfer.vue' 156 import transfer from './views/airtransport/transfer.vue'
157 // import transpour from './views/airtransport/transpour.vue' 157 // import transpour from './views/airtransport/transpour.vue'
158 -  
159 - 158 +//对话框
  159 +import dialogs from './views/dialogBox/dialogs.vue'
160 160
161 // 场站管理 161 // 场站管理
162 import Yard from './views/station_manage/Yard.vue' 162 import Yard from './views/station_manage/Yard.vue'
@@ -260,7 +260,15 @@ let routes = [ @@ -260,7 +260,15 @@ let routes = [
260 { path: '/airlift', component: airlift, name: '空运专线' }, 260 { path: '/airlift', component: airlift, name: '空运专线' },
261 ] 261 ]
262 }, 262 },
263 - 263 + {
  264 + path: '/dialogName',
  265 + component: HomeNew,
  266 + name: '对话框',
  267 + iconCls: 'el-icon-delete-location',
  268 + children: [
  269 + { path: '/dialogs', component: dialogs, name: '对话框' },
  270 + ]
  271 + },
264 272
265 273
266 274
  1 +<template>
  2 + <div>
  3 + <beautiful-chat
  4 + :participants="participants"
  5 + :titleImageUrl="titleImageUrl"
  6 + :onMessageWasSent="onMessageWasSent"
  7 + :messageList="messageList"
  8 + :newMessagesCount="newMessagesCount"
  9 + :isOpen="isChatOpen"
  10 + :close="closeChat"
  11 + :open="openChat"
  12 + :showEmoji="true"
  13 + :showFile="true"
  14 + :showEdition="true"
  15 + :showDeletion="true"
  16 + :showTypingIndicator="showTypingIndicator"
  17 + :showLauncher="true"
  18 + :showCloseButton="true"
  19 + :colors="colors"
  20 + :alwaysScrollToBottom="alwaysScrollToBottom"
  21 + :disableUserListToggle="false"
  22 + :messageStyling="messageStyling"
  23 + @onType="handleOnType"
  24 + @edit="editMessage" />
  25 +<!-- :icons="icons"-->
  26 + </div>
  27 +</template>
  28 +
  29 +<script>
  30 +
  31 + export default {
  32 + name: "dialogs",
  33 + data() {
  34 + return {
  35 + // socket: null,
  36 + // icons: {
  37 + // open: {
  38 + // img: OpenIcon,
  39 + // name: "default",
  40 + // },
  41 + // close: {
  42 + // img: CloseIcon,
  43 + // name: "default",
  44 + // },
  45 + // file: {
  46 + // img: FileIcon,
  47 + // name: "default",
  48 + // },
  49 + // closeSvg: {
  50 + // img: CloseIconSvg,
  51 + // name: "default",
  52 + // },
  53 + // },
  54 + participants: [
  55 + {
  56 + id: 'user1',
  57 + name: 'Matteo',
  58 + imageUrl: 'https://avatars3.githubusercontent.com/u/1915989?s=230&v=4'
  59 + },
  60 + {
  61 + id: 'user2',
  62 + name: 'Support',
  63 + imageUrl: 'https://avatars3.githubusercontent.com/u/37018832?s=200&v=4'
  64 + }
  65 + ], // 对话的所有参与者的列表。' name '是用户名,' id '用于建立消息的作者,' imageUrl '应该是用户头像。
  66 + titleImageUrl: 'https://a.slack-edge.com/66f9/img/avatars-teams/ava_0001-34.png',
  67 + messageList: [
  68 + { type: 'text', author: `me`, data: { text: `Say yes!` } },
  69 + { type: 'text', author: `user1`, data: { text: `No.` } }
  70 + ], // // 要显示的消息列表可以动态地分页和调整
  71 + newMessagesCount: 0,
  72 + isChatOpen: false, // 确定聊天窗口应该打开还是关闭
  73 + showTypingIndicator: '', // 当设置为匹配参与者的值时。它显示特定用户的输入指示
  74 + colors: {
  75 + header: {
  76 + bg: '#4e8cff',
  77 + text: '#ffffff'
  78 + },
  79 + launcher: {
  80 + bg: '#4e8cff'
  81 + },
  82 + messageList: {
  83 + bg: '#ffffff'
  84 + },
  85 + sentMessage: {
  86 + bg: '#4e8cff',
  87 + text: '#ffffff'
  88 + },
  89 + receivedMessage: {
  90 + bg: '#eaeaea',
  91 + text: '#222222'
  92 + },
  93 + userInput: {
  94 + bg: '#f4f7f9',
  95 + text: '#565867'
  96 + }
  97 + }, // specifies the color scheme for the component
  98 + alwaysScrollToBottom: false, // 当设置为true时,当有新事件发生时(新消息,用户开始输入…),总是将聊天滚动到底部。
  99 + messageStyling: true // 启用*bold* /emph/ _underline_等(更多信息请访问github.com/mattezza/msgdown)
  100 + }
  101 + },
  102 + methods: {
  103 + sendMessage (text) {
  104 + if (text.length > 0) {
  105 + this.newMessagesCount = this.isChatOpen ? this.newMessagesCount : this.newMessagesCount + 1
  106 + this.onMessageWasSent({ author: 'support', type: 'text', data: { text } })
  107 + }
  108 + },
  109 + onMessageWasSent (message) {
  110 + // 当用户发送消息时调用
  111 + this.messageList = [ ...this.messageList, message ]
  112 + },
  113 + openChat () {
  114 + // 当用户单击fab按钮打开聊天时调用
  115 + this.isChatOpen = true
  116 + this.newMessagesCount = 0
  117 + },
  118 + closeChat () {
  119 + // // 当用户单击按钮关闭聊天时调用
  120 + this.isChatOpen = false
  121 + },
  122 + handleScrollToTop () {
  123 +
  124 + // 当用户将消息列表滚动到顶部时调用
  125 +// 利用分页来加载另一个消息页面
  126 +
  127 + },
  128 + handleOnType () {
  129 + console.log('Emit typing event')
  130 + },
  131 + editMessage(message){
  132 + const m = this.messageList.find(m=>m.id === message.id);
  133 + m.isEdited = true;
  134 + m.data.text = message.data.text;
  135 + }
  136 + }
  137 + }
  138 +</script>
  139 +
  140 +<style>
  141 + .sc-chat-window[data-v-08d4c038]{
  142 + width: 500px !important;
  143 + padding-right: 50px;
  144 + }
  145 + .sc-header[data-v-61edfd75]{
  146 + margin-top: 50px;
  147 + width: 500px;
  148 + }
  149 + .sc-user-input{
  150 + width: 500px;
  151 + }
  152 + .sc-message-list[data-v-36bb2cf7]{
  153 + width: 500px;
  154 + }
  155 +</style>