接入客服消息
This commit is contained in:
parent
372ca89f07
commit
483554e361
@ -10,20 +10,20 @@
|
||||
<div class="bodyMain">
|
||||
<el-scrollbar>
|
||||
<div class="tagList">
|
||||
<div class="tagItem" v-for="(item,index) in tagList" :key="index">{{item.name}}</div>
|
||||
<div class="tagItem" v-for="(item,index) in tagList" :key="index" @click="typeActive(item)">{{item.label}}</div>
|
||||
</div>
|
||||
<div class="msgList">
|
||||
<div class="msgItem" :class="item.type === 2?'msgRightItem':''" v-for="(item,index) in msgList" :key="index">
|
||||
<div class="avatar" v-if="item.type === 1">
|
||||
<el-avatar :size="36" :src="item.avatar" fit="contain">
|
||||
<div class="msgItem" :class="user_id != item.to_user_id?'msgRightItem':''" v-for="(item,index) in msgList" :key="index">
|
||||
<div class="avatar" v-if="user_id === item.to_user_id">
|
||||
<el-avatar :size="36" :src="item.from_user.avatar" fit="contain">
|
||||
<img src="https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png"/>
|
||||
</el-avatar>
|
||||
</div>
|
||||
<div class="msgText">
|
||||
<div class="msgTitle">{{item.title}}</div>
|
||||
<div class="textCom">{{item.msg}}</div>
|
||||
<div class="msgTitle">{{item.from_user && item.from_user.name?item.from_user.name:'匿名'}}</div>
|
||||
<div class="textCom">{{item.to_message}}</div>
|
||||
</div>
|
||||
<div class="avatar" v-if="item.type === 2">
|
||||
<div class="avatar" v-if="user_id != item.to_user_id">
|
||||
<el-avatar :size="36" :src="item.avatar" fit="contain">
|
||||
<img src="https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png"/>
|
||||
</el-avatar>
|
||||
@ -33,8 +33,8 @@
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<el-input class="customTextarea" v-model="params.text" resize="none" type="textarea" :row="2" placeholder="请简短描述您的问题"></el-input>
|
||||
<div class="saveBtn" :class="params.text!==''?'saveActive':''">发 送</div>
|
||||
<el-input class="customTextarea" v-model="params.to_message" resize="none" type="textarea" :row="2" placeholder="请简短描述您的问题"></el-input>
|
||||
<div class="saveBtn" :class="params.to_message!==''?'saveActive':''" @click="sendCustomer">发 送</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -42,40 +42,88 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {eventBus} from "@/utils/eventBus";
|
||||
|
||||
export default {
|
||||
name: "index",
|
||||
data(){
|
||||
return{
|
||||
customerShow:false,
|
||||
params:{
|
||||
text:''
|
||||
type:"",
|
||||
to_user_id:"",
|
||||
to_message:"",
|
||||
|
||||
},
|
||||
tagList:[
|
||||
{name:'搜索引擎和数据查询'},
|
||||
{name:'用户体验和设计'},
|
||||
{name:'技术和兼容性'},
|
||||
{name:'质量问题'},
|
||||
{name:'其他'},
|
||||
],
|
||||
msgList:[
|
||||
{type:1,avatar:"https://dm-auto.oss-cn-shanghai.aliyuncs.com/xw_cloud/image/login_logo.png",title:"在线客服",msg:"您好,请问您需要什么帮助?"},
|
||||
{type:1,avatar:"https://dm-auto.oss-cn-shanghai.aliyuncs.com/xw_cloud/image/login_logo.png",title:"在线客服",msg:"我是您的智能在线客服,您可以把你的问题告诉我,我会尽我所能帮助您。"},
|
||||
{type:2,avatar:"https://dm-auto.oss-cn-shanghai.aliyuncs.com/xw_cloud/5.gif",title:"龙隆",msg:"怎么能快速的挣够一百万"}
|
||||
]
|
||||
tagList:[],
|
||||
msgList:[],
|
||||
user_id:0,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let token = this.$TOOL.cookie.get('TOKEN');
|
||||
if (token && token != null) {
|
||||
// 获取新消息
|
||||
eventBus.$on('sockBack', this.getWsResult);
|
||||
|
||||
const userInfo = this.$TOOL.data.get("USER_INFO");
|
||||
this.user_id = userInfo.id;
|
||||
}
|
||||
},
|
||||
unmounted() {
|
||||
eventBus.$off('sockBack', this.getWsResult);
|
||||
},
|
||||
methods:{
|
||||
getWsResult(res){
|
||||
if(res.data && (res.data.type == 36 || res.data.type == 37)){
|
||||
switch(res.data.type) {
|
||||
case 36:
|
||||
this.msgList = res.data.rows;
|
||||
break;
|
||||
case 37:
|
||||
this.params.to_user_id = res.data.user.uid;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
openCustomer(){
|
||||
this.customerShow = !this.customerShow;
|
||||
if(this.customerShow){
|
||||
this.getAssign();
|
||||
this.getRecordList();
|
||||
this.customerType();
|
||||
}
|
||||
},
|
||||
closeCustomer(){
|
||||
this.customerShow = false;
|
||||
},
|
||||
|
||||
|
||||
async getAssign() {
|
||||
await this.$API.customer.customer.post();
|
||||
},
|
||||
async getRecordList() {
|
||||
await this.$API.customer.list.post();
|
||||
},
|
||||
async sendCustomer() {
|
||||
if(this.params.to_message =="") return
|
||||
const res = await this.$API.customer.send.post(this.params);
|
||||
if(res.code == 200){
|
||||
this.tagList.push({});
|
||||
this.params.to_message = "";
|
||||
}
|
||||
},
|
||||
async customerType() {
|
||||
const res = await this.$API.customer.typeList.post();
|
||||
if (res.code == 200) {
|
||||
this.tagList = res.data;
|
||||
}
|
||||
},
|
||||
typeActive(item){
|
||||
this.params.type = item.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -91,8 +139,8 @@ export default {
|
||||
height: 56px;
|
||||
}
|
||||
.customerView{
|
||||
width: 300px;
|
||||
height: 430px;
|
||||
width: 380px;
|
||||
height: 580px;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 70px;
|
||||
|
||||
@ -75,6 +75,9 @@
|
||||
return false
|
||||
}
|
||||
if(user.data.user.company_id === 0){
|
||||
// 登录成功连接ws
|
||||
let global_callback = function () {};
|
||||
this.$socketApi.createWebSocket(global_callback);
|
||||
this.$router.replace({
|
||||
path: '/maintenance'
|
||||
})
|
||||
|
||||
@ -123,7 +123,8 @@ export default {
|
||||
bubble.style.background = `${item.color}`;
|
||||
bubble.innerText =`${item.name}`;
|
||||
return bubble
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user