websocket onopen 提示

This commit is contained in:
unknown
2022-05-10 17:41:08 +08:00
parent 5884ac7299
commit c453250a31

View File

@ -93,6 +93,23 @@ const conversation = (props) => {
msgAlert && msgAlert()
}
}
// const sendToCs = (msg)=>{
// let params = {
// "clientNo": staffId,
// "contentType": 5,
// "custType": kfType == 2? 2 : 1,
// "message": '',
// "questionType": 2,
// "supplierNo": kfType==1?'EMPTY':agentNumber
// }
// API.sendToCs(params).then(res => {
// if (res && !res.data) {
// }else{
// message.warn(res && res.message)
// }
// })
// }
const connect = () =>{
let serverAvatar = user
const msg = {
@ -118,7 +135,23 @@ const conversation = (props) => {
console.log("Connection open ...");
//记录ws
setShow(true) //连接建立后,才可以显示弹窗、收发消息
if(sendMsg && sendMsg.length>0) setIsSend(true) //连接建立后sendMsg有值才可以发即时消息用户不点击发送打开窗口即发送
if(sendMsg && sendMsg.length>0) { //连接建立后sendMsg有值才可以发即时消息用户不点击发送打开窗口即发送
setIsSend(true)
}else{
//发空消息给websocket
let serverAvatar = user
const msg = {
_id: Math.floor(Math.random() * 1000)+new Date(),
date: new Date(),
user: {
id: serverNo,
avatar: serverAvatar,
name: '供应链客服',
},
message: { type: 'text', content: '您好,欢迎使用供应链客服' },
}
setMsgList([...msgList, msg])
}
setWsObj(ws)
};