提交 18fc33af 编写于 作者: xiaoping.di's avatar xiaoping.di

hope

上级 bc118aa6
const roundCard = { import io from 'socket.io-client';
const socket = {
namespaced: true, namespaced: true,
state: { state: {
socketClient: null, socketClient: null,
}, },
actions: { actions: {
initCard(context, payload) { initSocket(context, payload) {
const { rootState } = context; const { rootState } = context;
console.log(context, payload, 'context, payload111', rootState); console.log(context, payload, 'context, payload111');
// const { list, allSize, countRespList } = socket; const socketClient = io.connect(payload.url, {
// console.log('-rootState', rootState, socket); query: {
// const { currentTabStatus } = rootState.main; loginUserNum: `diagnose_list_socket_${payload.userId}`,
// context.commit('main/updateCurrentCalList', countRespList, { },
// root: true, // reconnection: false,
// }); });
// context.commit('main/updateAllSize', allSize, { root: true }); context.commit('SET_SOCKET', socketClient, rootState);
// if (list) { socketClient.on('connect', (socket) => {
// const l = list[0] || []; console.log('socket 链接成功', socket, socketClient);
// if (currentTabStatus == 99) { });
// context.commit('main/updateCurrentDiagList', list, { root: true }); socketClient.on('connect_error', (err) => {
// } else { console.log('socket connect_error', err);
// if (currentTabStatus == l.returnStatus) { // state.socketClient.connect();
// context.commit('main/updateCurrentDiagList', list, { });
// root: true, socketClient.on('disconnect', (socket) => {
// }); console.log('socket disconnect----', socket);
// } // state.socketClient.connect();
// if (l.length == 0) { });
// context.commit('main/updateCurrentDiagList', list, { socketClient.on('diagnose_push_event', (socket) => {
// root: true, const { list, allSize, countRespList } = socket;
// }); console.log('-rootState', rootState, socket);
// } const { currentTabStatus } = rootState.main;
// } context.commit('main/updateCurrentCalList', countRespList, {
// } else { root: true,
// context.commit('main/updateCurrentDiagList', [], { root: true }); });
// } context.commit('main/updateAllSize', allSize, { root: true });
if (list) {
const l = list[0] || [];
if (currentTabStatus == 99) {
context.commit('main/updateCurrentDiagList', list, { root: true });
} else {
if (currentTabStatus == l.returnStatus) {
context.commit('main/updateCurrentDiagList', list, {
root: true,
});
}
if (l.length == 0) {
context.commit('main/updateCurrentDiagList', list, {
root: true,
});
}
}
} else {
context.commit('main/updateCurrentDiagList', [], { root: true });
}
});
socketClient.on('diagnose_call_push_event', (socket) => {
console.log(
socket,
'socketsocket',
window._VM.$store.state.main.soketQuest
);
const l = window._VM.$store.state.main.noticeList;
if (l.length >= 5) {
l.shift();
}
l.push(socket);
const n = { notifyIndex: l.length, ...socket };
context.commit('main/updateNoticeList', l, { root: true });
const { path } = window._VM.$route;
const operateUserId = window._VM.$store.state.main.soketQuest
.operateUserId
? window._VM.$store.state.main.soketQuest.operateUserId
: '';
if (
path &&
String(path).indexOf('workbench') > -1 &&
n.operateUserId == operateUserId
) {
const ni = { notifyInfo: n, rootState: rootState };
context.commit('SET_NOTIFY', ni);
}
});
socketClient.on('ping', function () {
console.log('[E] 心跳请求已发出 →', socketClient);
});
// 收到
socketClient.on('pong', function (socket) {
console.log('[E] 心跳响应已收到 ←', socket, socketClient);
});
socketClient.io.on('reconnect_attempt', (socket) => {
console.log('--reconnect_attempt', socket);
// ...
});
socketClient.on('reconnect', (socket) => {
console.log('--reconnect', socket);
// ...
});
socketClient.on('reconnecting', (attemptNumber) => {
// ...
console.log('--reconnecting', attemptNumber);
});
}, },
}, },
mutations: { mutations: {
SET_SOCKET: (state, payload) => {
window.socketClient = payload;
state.socketClient = payload;
},
SET_NOTIFY: (state, payload) => {
const doms = document.getElementsByClassName('el-notification');
if (doms.length >= 5) return;
const h = window._VM.$createElement;
const { notifyInfo, rootState } = payload;
const t = notifyInfo.department
? `问诊单${notifyInfo.diagnoseLogId}(${notifyInfo.department})`
: `问诊单${notifyInfo.diagnoseLogId}`;
// userCallKfStatus 医助呼叫
// doctorCallKfStatus 医生呼叫
const name =
notifyInfo.userCallKfStatus == 1
? notifyInfo.userName
: notifyInfo.doctorName;
const cn = window._VM.$notify({
title: t,
message: h('p', [
h('i', { style: 'color: teal;' }, `${name}正在呼叫你`),
h(
'el-button',
{
style: `float:right;margin-top:${30}px;`,
on: {
click: function () {
console.log('----state', rootState);
if (rootState.main.showChat) {
window._VM.$message({
message:
'不可同时进入多个诊室,请先退出已进入的诊室,再试。',
type: 'warning',
duration: 1000,
});
} else {
window._VM.$store.dispatch('main/gotoInquiry', notifyInfo);
}
cn.close();
},
},
},
'进入诊室'
),
]),
onClose: function () {
console.log('--onClose', notifyInfo);
},
duration: 5000,
position: 'top-right',
});
},
}, },
}; };
export default roundCard; export default socket;
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册