| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- <template>
- <div>
- <div class="header row allAlignment">
- <div class="row item-center box_div" style="color:#666;font-size:14px;font-weight:bold;">
- <img style="width:38px;height:38px;margin: 0 10px;" :src="img_http + user_info.user_avatar">
- 你好,<span>{{user_info.user_name}}--{{user_info.group}}</span>
- </div>
- <div class="row item-center rightAlignment msg box_div" style="padding: 0 30px;font-size:12px;color:#999">
- <div>
- <el-dropdown @command="handleCommand">
- <span class="el-span-1" v-if="value == '在线'" style="color: #00eb00">
- <i class="el-icon-user"></i>
- {{value}}
- </span>
- <span class="el-span-1" v-if="value == '隐身'" style="color: gray">
- <i class="el-icon-user"></i>
- {{value}}
- </span>
- <span class="el-span-1" v-if="value == '休息'" style="color: #f4f400">
- <i class="el-icon-user"></i>
- {{value}}
- </span>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command=0>在线</el-dropdown-item>
- <el-dropdown-item command=1>隐身</el-dropdown-item>
- <el-dropdown-item command=2>休息</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- <!-- 会话总览 -->
- <el-badge class="item">
- <!-- el-icon-menu -->
- <el-button @click="getInnerDrawer()">
- <i style="font-size:14px; color:#5aa0fbbd ;" class="el-icon-menu"> </i>会话总览
- </el-button>
- <el-drawer
- id="huihua"
- title="会话总览"
- :modal="false"
- :show-close="true"
- size="90%"
- style="margin-top: 7vh"
- :before-close="handleClose"
- :visible.sync="innerDrawer">
- <div class="session_overview">
- <!-- 会话列表 -->
- <el-col :span="6">
- <el-tree class="session_list"
- :data="dataTree"
- :props="defaultProps"
- default-expand-all
- @node-click="handleNodeClick">
- </el-tree>
- </el-col>
- <!-- 会话消息 -->
- <el-col class="session_box" :span="12">
- <div class="session_box_title">{{session_litle ? session_litle :'未选择会话'}}</div>
- <div class="session_box_content">
- <!-- <div class="chatWindow" > -->
- <div v-for="(item,index) in dataList " :key="index">
- <!-- 模拟用户 -->
- <div v-if="item.to_id.startsWith('KF')" style="padding-top:10px;">
- <div class="title_time">
- <span>{{item.time_line}}</span>
- </div>
- <div v-if="item.content.text" class=" row wrap" >
- <div class="left_session item-center" v-html="item.content.text"></div>
- </div>
- <div v-if="item.content.img" class="row " >
- <div class="left_session item-center " >
- <el-image
- :src="img_http+item.content.img"
- @click="handlePictureCardPreview(img_http+item.content.img)">
- </el-image>
- </div>
- </div>
- </div>
- <!-- 模拟客户 -->
- <div v-else style="padding-top:10px;">
- <div class="row rightAlignment title_time" style="width: 100%;">
- <span>{{item.time_line}}</span>
- </div>
- <div v-if="item.content.text" class="row rightAlignment">
- <div class="right_session item-center wrap" v-html="item.content.text"></div>
- </div>
- <div v-if="item.content.img" class="row rightAlignment" >
- <div class="right_session item-center ">
- <el-image
- :src="img_http+item.content.img"
- @click="handlePictureCardPreview(img_http+item.content.img)">
- </el-image>
- </div>
- </div>
- </div>
- </div>
- </div>
- </el-col>
- <!-- 用户信息 -->
- <el-col class="user_info" :span="6">
- <!-- 用户信息展示框 -->
- <div>
- <ul style="padding-inline-start:0px; margin-block-start:0; margin-top:30px;">
- <li style="font-weight:bold;font-weight:bold; color:#666666;">访问信息</li>
- <li>IP地址:{{visitorsInfo.user_ip}}</li>
- <li>来源终端:{{visitorsInfo.system}}-{{visitorsInfo.browse}}</li>
- </ul>
- <ul style="padding-inline-start:0px; margin-block-start: 0; margin-top:30px;">
- <li style="font-weight:bold;font-weight:bold; color:#666666;">用户信息</li>
- <li>账号:{{visitorsInfo.account_name}}</li>
- <li>标签:{{visitorsInfo.label}}</li>
- <li>昵称:{{visitorsInfo.nick_name}}</li>
- <li>手机:{{visitorsInfo.visitorsInfo_phone}}</li>
- <li>邮箱:{{visitorsInfo.visitorsInfo_email}}</li>
- <li>地址:{{visitorsInfo.address}}</li>
- <li>备注:{{visitorsInfo.remark}}</li>
- </ul>
- </div>
-
- </el-col>
- </div>
- </el-drawer>
- </el-badge>
- <!-- 点击图片放大 -->
- <el-dialog :visible.sync="dialogVisible">
- <img width="100%" :src="dialogImageUrl" alt="">
- </el-dialog>
- <!-- 消息中心 -->
- <el-badge :value="unreadNum" class="item">
- <el-button @click="openDrawer">
- <i style="font-size:14px; color:#5399F5;" class="el-icon-chat-dot-square"> </i>消息中心
- </el-button>
- </el-badge>
- <span @click="isExit()" class="el-span-1"><i style="font-size:13px; margin-right: 3px; color:#5399F5;" class="el-icon-switch-button"></i>退出</span>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Vue from 'vue';
- import '@/css/index.css'
- export default {
- name: 'hader',
- data() {
- return {
- state: true,//在线状态
- announcement: true,//公告
- network: true,
- HeadPortrait: '',
- loginTo: false,//登录状态
- options: ['在线', '隐身', '休息'],
- value: '在线',
- user_info: '',//
- userID:null,
- unreadNum:null, // 未读数量
- img_http:'http://manage.281570.com',//图片路径域
- innerDrawer:false,//会话总览抽屉开关
- // img_http: 'http://192.168.2.187:8090',//图片路径域
- dataTree: [],
- defaultProps: {
- children: 'children',
- label: 'label',
- },
- interval:'',//列表循环定时器
- ession_int:'',//会话信息循环定时器
- visitorsInfo:{},//访客信息
- dataList:[],//会话信息列表
- servicelog:'',//当前会话工单信息
- session_litle:'',//会话标题
- newTime:'',//本次最新时间
- isGetList:false,//点击获取会话信息
- dialogVisible: false, //图片放大
- dialogImageUrl: '', // 放大的图片
- serverList:[],
- }
- },
- mounted() {
- if (this.$store.getters.get_stateValue) {
- this.value = this.$store.getters.get_stateValue;
- }
- if(typeof this.$store.getters.get_user_info != 'string'){
- this.user_info = this.$store.getters.get_user_info
- }else if(this.$store.getters.get_user_info!= ""){
- this.user_info = JSON.parse(this.$store.getters.get_user_info)
- }
- this.userID = this.$store.getters.get_user_info.id;
- this.unreadnotice();
- let _this = this;
- let get = setTimeout(function(){
- _this.unreadnotice();
- },1000)
- },
- computed: {
- get_drawer() {
- return this.$store.getters.get_drawer;
- },
- },
- watch: {
- get_drawer(data) {
- this.unreadnotice();
- },
- },
- methods: {
- /***************图片放大*************** */
- handlePictureCardPreview(url) {
- this.dialogImageUrl = url;
- this.dialogVisible = true;
- },
- openDrawer() {
- this.$store.dispatch("SET_DRAWER", true);
- },
- /**********************************************/
- //切换用户状态
- handleCommand(e) {
- console.log(e,"切换用户状态");
- this.websocketsend(JSON.stringify({
- type: 'kfOnline',
- data: {
- uid: 'KF' + this.user_info.id,
- status: e * 1 + 1,
- }
- }));
- //Vue.prototype.$stateValue = this.options[e];
- this.$store.dispatch("SET_STATEVALUE", this.options[e]);
- this.value = this.options[e];
- },
- /************************************************/
- //退出系统
- isExit() {
- this.$store.dispatch("SET_STATEVALUE", '在线');
- this.$store.dispatch("SET_SESSION",[]);//会话列表
- this.$store.dispatch("SET_USER",'');//用户退出
- this.$store.dispatch("SET_OFFLINE",[]);//离线列表
- this.$store.dispatch("SET_TYPE",1);//选择类型(会话/离线)
- this.$store.dispatch("SET_NUM",0);//列表下标
- this.$store.dispatch("SET_CURRENT",[]);//当前会话数据
- this.$store.dispatch("SET_SESSION_NAME",'');//当前会话对象名
- this.$store.dispatch("SET_SESSION_MESSAGE",{});
- this.$store.dispatch("SET_SOCKET_OPEN",false);//列表下标
- this.$store.dispatch("SET_NAVSTATE", 'TheCurrentSession');
- this.$websocket.close();
- // this.$socket_open = false;
-
- // console.log(this.$socket_open)
- this.$token = '';
- this.$router.push({path:'/login',query: { pid:escape("这就是一个编码没有什么用啊") }})
- },
- /**************************************/
- //数据发送
- websocketsend(Data) {
- this.$websocket.send(Data);
- },
-
- /****************未读信息**************/
- unreadnotice(){
- let str = "unreadnotice" + "customer-service" + "index" + "service";
- let obj = {
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- apiToken: this.$md5(str),
- userToken: this.user_info.token
- },
- };
- this.$http.post(this.$ports.center.unreadnotice,{
- user_id: this.userID
- },obj).then(res => {
- if(res.data.code === 1){
- // console.log(res.data.data)
- this.unreadNum = res.data.data.length;
- }
- });
- },
- /************获取客服和用户会话信息************/
- handleNodeClick(data,i,j){
- if(!data.children){
- if(this.isGetList) return false
- clearInterval(this.ession_int);
- this.servicelog = data;
- console.log(this.servicelog)
- this.init();
- this.get_session_lise();
- this.ession_int = setInterval(()=>{
- this.get_session_lise(this.newTime);
- },1000*5)
- }
- },
- /***************会话总览关闭前回掉处理************/
- handleClose(){
- this.innerDrawer = false;
- //清除列表定时请求
- clearInterval(this.interval);
- //
- clearInterval(this.ession_int);
- this.init();
- },
- /*************获取会话总览数据************/
- getInnerDrawer(){
- if(this.innerDrawer) return false;
- this.innerDrawer = true;
- let obj = {
- headers: {
- apiToken: this.$md5("allconversation" + "customer-service" + "history" + "service"),
- userToken: this.user_info.token
- }
- };
- this.$http.post(this.$ports.overview.allConversation,'',obj).then(res => {
- if(res.data.code === 1){
- // console.log('会话',res.data)
- this.dataTree = res.data.data;
- this.interval = setInterval(()=>{
- this.$http.post(this.$ports.overview.allConversation,'',obj).then(res => {
- if(res.data.code === 1){
- this.serverList = res.data.serverList;
- this.dataTree = res.data.data;
- //this.unreadNum = res.data.data.length;
- let step;
- for (let i = 0; i < this.serverList.length; i++) {
- if (this.servicelog.servicelog_id == this.serverList) {
- step = false;
- break;
- } else {
- step = true;
- }
- }
- if (step == true) {
- this.init();
- }
- }
- });
- },1000*60);
- }
- });
- },
- /******************会话详情列表******************/
- get_session_lise(time){
- // if() return false
- let str ="chatbytime" + "customer-service" + "history" + "service";
- this.$http.get(this.$ports.overview.chatByTime,{
- params:{
- servicelog_id:this.servicelog.servicelog_id,
- lastTime:time,
- },
- headers:{
- 'apiToken': this.$md5(str),
- 'userToken': this.user_info.token
- }
- }).then(res => {
- if(res.data.code == 1){
- res.data.data.list = res.data.data.list.reverse();
- // console.log(res.data.data.list,'详情列表')
- this.isGetList = false;
- //本次最新时间
- // console.log(res.data.data.list.length, res.data.data.list)
- if(res.data.data.list.length > 0){
- this.newTime = res.data.data.list[res.data.data.list.length -1].time_line;
- }
- this.alarm = res.data.data.alarm;
- //访客信息
- this.visitorsInfo = res.data.data.account;
- let name = this.visitorsInfo.nick_name ? this.visitorsInfo.nick_name : this.visitorsInfo.account_name
- this.session_litle = '(组)'+res.data.data.groupName +'->(客服)'+ res.data.data.serverName +'->(会话)'+name
- res.data.data.list.forEach(e => {
- //时间戳转时间
- e.time_line = this.$public.customFormatDateTime(e.time_line);
- //字符串转换成对象
- e.content =JSON.parse(e.content);
- //文字转表情符号
- e.content.text = this.$public.turnFace(e.content.text,this.$frce);
- this.dataList.push(e)
- });
- }
- });
- },
- /*******************会话总览数据初始化****************/
- init(){
- this.visitorsInfo = {};//访客信息
- this.dataList = [];//会话信息列表
- this.servicelog_id = '';//会话工单号
- this.session_litle = '';//会话标题
- this.newTime = '';
- }
- }
- }
- </script>
- <style scoped>
- .header {
- width: 90vw;
- height: 7vh;
- border-bottom: 1px solid #D5E5FF;
- }
- .box_div {
- width: 50%;
- height: 100%;
- background: #ECF4FF;
- }
- .msg p {
- margin-left: 30px;
- display: flex;
- align-items: center;
- }
- .msg p img {
- margin-right: 6px;
- }
- .el-span-1 {
- margin-left: 14px;
- margin-right: 14px;
- font-size: 14px;
- color: #666;
- }
- .el-span-1:hover {
- color: #5399f5;
- cursor: pointer;
- font-weight: 400;
- }
- button {
- outline: none;
- /* border: 1px solid #ECF4FF; */
- }
- .el-button {
- background: #ECF4FF;
- font-size: 14px;
- color: #666;
- }
- .el-button:hover {
- color: #5399f5;
- }
- .msg_left {
- width: 360px;
- height: 400px !important
- }
- .msg_right {
- width: 440px;
- }
- .el-popover {
- height: 700px !important;
- }
- /* 会话总览 */
- .session_overview{
- /* padding:0 20px; */
- border: 1px solid #d5e5ff !important;
- /* border-top:1px solid #d5e5ff; */
- height: 92vh;
- }
- .session_list{
- /* margin-top: 10px; */
- padding: 10px 20px;
- height: 92vh;
- }
- .session_box{
- border-left: 1px solid #d5e5ff !important;
- border-right: 1px solid #d5e5ff !important;
- height: 92vh;
- padding:10px 0;
- }
- .session_box_title{
- padding: 0 20px;
- padding-bottom:10px;
- border-bottom: 1px solid #d5e5ff !important;
- font-size: 14px;
- font-weight:400;
- color:rgba(102,102,102,1);
- }
- .session_box_content{
- padding: 10px 20px;
- height: 70vh;
- border-bottom: 1px solid #d5e5ff !important;
- font-size: 14px;
- font-weight:400;
- color:rgba(102,102,102,1);
- overflow:auto
- }
- .user_info{
- padding:10px 20px;
- height: 92vh;
- font-size:14px;
- color:rgba(153,153,153,1);
- font-weight:400;
- }
- .user_info li{
- margin: 5px 0;
- }
- .title_time{
- font-size:12px;
- font-weight:400;
- color:rgba(187,187,187,1);
- }
- .left_session{
- border:1px solid rgba(221,221,221,1);
- margin-right: 50px;
- max-width: 100%;
- min-height: 20px;
- padding: 6px;
- background:rgba(245,245,245,1);
- border-radius:0px 10px 10px 10px;
- margin-top:6px;
- word-wrap: break-word;
- }
- .right_session{
- margin-top:6px;
- border:1px solid rgba(221,221,221,1);
- margin-left: 50px;
- max-width: 100%;
- min-height: 20px;
- padding: 6px;
- background:rgba(223,240,255,1);
- justify-content: flex-end;
- border-radius:10px 0px 10px 10px;
- word-wrap: break-word;
- }
- </style>
- <style>
- .el-badge__content.is-fixed {
- top: 8px !important;
- right: 20px !important;
- }
- </style>
|