{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xq-web-bpm\\src\\components\\instantMessag\\IM.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\src\\components\\instantMessag\\IM.vue","mtime":1675071992178},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n\nexport default {\n name: \"IM\",\n data() {\n return {\n currentUser: this.$store.state.login.currentUser,\n onlineAdress: \"\",\n wimadress: \"\",\n user: \"\",\n uname: \"\",\n websocket: null,\n layer: null\n }\n },\n mounted() {\n this.$nextTick(() => {\n // TODO 接口未搬迁暂时隐藏\n // this.getInfo();\n })\n },\n destroyed() {\n layer.closeAll();\n },\n methods: {\n // TODO 接口未搬迁暂时隐藏\n getInfo() {\n const _this = this;\n const userInfo = _this.currentUser;\n if(!userInfo) return ;\n this.$http.post('${uc}/head/getInfo',{},{tm: new Date().getTime()}).then(({data}) => {\n _this.onlineAdress = data.onlineAdress//在线管理地址\n _this.wimadress = data.wimadress //即时聊天地址\n _this.user = data.USERNAME //用户名\n _this.uname = data.NAME\n\n window.user = data.USERNAME\n _this.initLayim();\n })\n },\n initLayim() {\n const _this = this;\n const userInfo = _this.currentUser;\n layui.use(['layim', 'readyMenu','layer'], function (layim) {\n this.layer = layui.layer;\n let f = setInterval(function () {\n if (\"\" != _this.wimadress) {\n clearInterval(f);\n if (window.WebSocket) {\n window.webSocket = new WebSocket(encodeURI('ws://' + _this.wimadress)); //wimadress参数在 assets/js-v/sys/index.js 中定义并赋值\n // window.webSocket = _@this.websocket;\n window.webSocket.onopen = function () {\n console.log(_this.user)\n window.webSocket.send(',fhadmin-join,' + _this.user); \t//发送上线消息(把上线状态发送给好友,对方好友栏目本头像从黑白色变彩色)(前提条件:本身在线状态设置为在线状态,否则对方看到的依然是离线状态)\n _this.$notify({\n title: '提示',\n message: '即时通讯已连接成功',\n duration: 1500\n });\n };\n window.webSocket.onerror = function () { \t\t\t//连接失败\n _this.$notify({\n title: '提示',\n message: '连接发生错误,刷新或者更换浏览器试试',\n duration: 1500\n });\n };\n window.webSocket.onclose = function () {\t\t\t//连接断开\n _this.$notify({\n title: '提示',\n message: '已经断开连接',\n duration: 1500\n });\n window.webSocket.send(',fhadmin-leave,');\t\t//发送下线消息\n };\n window.webSocket.onmessage = function (message) {\t//消息接收\n message = JSON.parse(message.data);\n console.log(message)\n if ('friend' == message.type || 'group' == message.type) { //接收好友或群发送的消息\n getFHMessage(message);\n } else if ('user_join' == message.type) {\n friendOnline(message.user);\n _this.$notify({\n title: '消息',\n message: '好友'+message.name+'上线了',\n duration: 1500\n });\n } else if ('user_leave' == message.type) {\n friendOffline(message.user);\n _this.$notify({\n title: '消息',\n message: '好友'+message.name+'下线了',\n duration: 1500\n });\n } else if ('user_online' == message.type) {\n friendOnline(message.user);\t\t//好友设置在线状态\n } else if ('user_hide' == message.type) {\n friendOffline(message.user);\t//好友设置隐身状态\n } else if ('user_applyfriend' == message.type) {\n applyIFriend();\t\t\t\t\t//申请加好友\n } else if ('user_emove' == message.type) {\n removeFriend(message.user);\t\t//删除好友(被动删,被拉黑)\n } else if ('agreefriend' == message.type) {\n addFriend(message);\t\t\t\t//对方同意添加好友\n } else if ('applyqgroup' == message.type) {\n applyIQgroup();\t\t\t\t\t//申请加群申请\n } else if ('agreeqgroup' == message.type) {\n addIQgroup(message);\t\t\t//对方同意群申请\n } else if ('kickoutqgroup' == message.type) {\n kickoutIQgroup(message.id);\t\t//踢出群\n } else if ('delqgroup' == message.type) {\n delQgroup(message.QGROUP_ID);\t//群解散\n _this.$notify({\n title: '消息',\n message: message.CONTENT,\n duration: 2000\n });\n }\n };\n } else {\n _this.$notify({\n title: '消息',\n message: '此浏览器不支持websocket,请用支持HTML5的浏览器或者使用最新谷歌、火狐、360等浏览器',\n duration: 2000\n });\n }\n ;\n _this.$http.post('${uc}/iminterface/getImsign',{},{tm: new Date().getTime()}).then(({data}) => {\n layim.config({\n init: {\n url: window.httpurl + '/iminterface/getList'//初始化接口\n , type: 'post'\n , data: {}\n }\n , members: {\n url: window.httpurl + '/iminterface/getMembers'\t\t\t//查看群员接口\n , data: {}\n , type: 'post'\n }\n , uploadImage: {\n url: window.httpurl + '/iminterface/updateImg'\t\t\t//上传图片接口\n , type: 'post' \t\t\t\t\t\t\t\t//默认post\n ,headers: {\n Authorization: \"Bearer \" + JSON.parse(window.sessionStorage.currentUser).token\n },\n }\n\n , uploadFile: {\n url: window.httpurl + '/iminterface/updateFile'\t\t\t//上传文件接口\n , type: 'post' \t\t\t\t\t\t\t\t//默认post\n }\n , isAudio: true \t\t\t\t\t\t\t\t\t//开启聊天工具栏音频\n , isVideo: true \t\t\t\t\t\t\t\t\t//开启聊天工具栏视频\n /**扩展工具栏*/\n , tool: [{\n alias: 'code'\n , title: '代码'\n , icon: ''\n }]\n //,brief: true \t\t\t\t\t\t//是否简约模式(若开启则不显示主面板)\n , title: '我的通讯' \t\t\t\t\t//自定义主面板最小化时的标题\n //,right: '100px' \t\t\t\t\t//主面板相对浏览器右侧距离\n //,minRight: '90px' \t\t\t\t//聊天面板最小化时相对浏览器右侧距离\n , initSkin: data ? data.imsign : \"\"\t\t//1-5 设置初始背景 res.imsign\n //,skin: ['aaa.jpg'] \t\t\t\t//新增皮肤\n //,isfriend: false \t\t\t\t\t//是否开启好友\n ,isgroup: true \t\t\t\t\t//是否开启群组\n //,min: true \t\t\t\t\t\t//是否始终最小化主面板,默认false\n , notice: true \t\t\t\t\t\t//是否开启桌面消息提醒,默认false\n //,voice: false \t\t\t\t\t//声音提醒,默认开启,声音文件为:default.mp3\n , msgbox: window.pageurl + \"/static/IM/messageBox.html\" \t\t\t\t//消息盒子页面地址,若不开启,剔除该项即可\n , find: window.pageurl + \"/static/IM/addFrined.html\" \t//发现页面地址,若不开启,剔除该项即可\n , chatLog: '/static/IM/hismsg_list.html' \t//聊天记录页面地址,若不开启,剔除该项即可\n\n });\n /*基础配置*/\n })\n }\n }, 1000);\n\n layim.on('online', function (data) {\t\t\t//监听在线状态的切换事件\n window.webSocket.send(',fhadmin-' + data + ',' + _this.user);\t//发送在线隐身消息\n $.ajax({\n xhrFields: {\n withCredentials: false\n },\n headers: {\n Authorization: \"Bearer \" + userInfo.token\n },\n type: \"POST\",\n url: window.httpurl + '/iminterface/editState',\n data: {ONLINE: data, TYPE: \"online\", tm: new Date().getTime()},\n dataType: 'json',\n success: function (data) {\n }\n });\n });\n\n layim.on('sign', function (data) {\t\t\t\t//监听签名修改\n $.ajax({\n xhrFields: {\n withCredentials: false\n },\n headers: {\n Authorization: \"Bearer \" + userInfo.token\n },\n type: \"POST\",\n url: window.httpurl + '/iminterface/editState',\n data: {AUTOGRAPH: data, TYPE: \"auto\", tm: new Date().getTime()},\n dataType: 'json',\n success: function (data) {\n }\n });\n });\n\n layim.on('setSkin', function (filename, src) {\t//监听更换背景皮肤\n $.ajax({\n xhrFields: {\n withCredentials: false\n },\n headers: {\n Authorization: \"Bearer \" + userInfo.token\n },\n type: \"POST\",\n url: window.httpurl + '/iminterface/editState',\n data: {SIGN: filename, TYPE: \"sign\", tm: new Date().getTime()},\n dataType: 'json',\n success: function (data) {\n }\n });\n });\n\n layim.on('tool(code)', function (insert) {\t\t//监听自定义工具栏点击,以添加代码为例\n layer.prompt({\n title: '插入代码'\n , formType: 2\n , shade: 0\n }, function (text, index) {\n layer.close(index);\n insert('[pre class=layui-code]' + text + '[/pre]'); //将内容插入到编辑器\n });\n });\n\n /*监听layim建立就绪*/\n layim.on('ready', function (res) {\n layui.readyMenu.init(); \t\t\t\t\t//更新右键点击事件\n $.ajax({\n xhrFields: {\n withCredentials: false\n },\n headers: {\n Authorization: \"Bearer \" + userInfo.token\n },\n type: \"POST\",\n url: window.httpurl + '/iminterface/getMsgCount',\t\t\t//未读消息(加好友群等)总数\n data: {tm: new Date().getTime()},\n dataType: 'json',\n success: function (data) {\n if ('01' == data.result) {\n layim.msgbox(data.count); \t\t//消息盒子有新消息\n }\n }\n });\n $.ajax({\n xhrFields: {\n withCredentials: false\n },\n headers: {\n Authorization: \"Bearer \" + userInfo.token\n },\n type: \"POST\",\n url: window.httpurl + '/iminterface/getNoreadMsg',\t\t//未读消息(离线消息)接口\n data: {tm: new Date().getTime()},\n dataType: 'json',\n success: function (data) {\n if ('has' == data.result) {\n $.each(data.list, function (i, list) {\n layim.getMessage({\n username: list.NAME \t\t//消息来源用户名\n , avatar: list.PHOTO \t\t//消息来源用户头像\n , id: list.USERNAME \t\t//消息的来源ID(如果是私聊,则是用户id,如果是群聊,则是群组id)\n , type: \"friend\" \t\t\t//聊天窗口来源类型,从发送消息传递的to里面获取\n , content: list.CONTENT \t//消息内容\n , timestamp: list.CTIME\n });\n });\n }\n }\n });\n\n });\n\n //接收到好友或群的消息\n function getFHMessage(data){\n console.log(data)\n layim.getMessage(data);\n }\n\n //接收到好友上线消息,头像取消置灰\n function friendOnline(id){\n layim.setFriendStatus(id, 'online'); //设置指定好友在线,即头像取消置灰\n }\n\n //接收到好友下线消息,头像置灰\n function friendOffline(id){\n layim.setFriendStatus(id, 'offline'); //设置指定好友下线,即头像置灰\n }\n\n //申请好友消息\n function applyIFriend(){\n layim.msgbox('新');\n $(\"#fhsmsobj\").html('');\n }\n\n //申请加群消息\n function applyIQgroup(){\n layim.msgbox('新');\n $(\"#fhsmsobj\").html('');\n }\n\n //踢出消息\n function kickoutIQgroup(QGROUP_ID){\n layui.layim.removeList({\n type: 'group'\n ,id: QGROUP_ID //群ID\n });\n layim.msgbox('新');\n $(\"#fhsmsobj\").html('');\n }\n\n //删除好友(被对方拉黑)\n function removeFriend(FUSERNAME){\n layim.removeList({\n type: 'friend' //或者group\n ,id: FUSERNAME //好友用户名\n });\n }\n\n //对方同意添加好友(加入好友栏目)\n function addFriend(message) {\n layim.addList({\n type: 'friend' \t\t\t\t//列表类型,只支持friend和group两种\n ,avatar: message.avatar \t\t//好友头像\n ,username: message.username\t//好友昵称\n ,groupid: message.groupid\t\t//所在的分组id\n ,id: message.id \t\t\t\t//好友id\n ,status: message.status \t\t//在线状态\n ,sign: message.sign\t\t \t//好友签名\n });\n layim.msgbox('新');\n $(\"#fhsmsobj\").html('');\n layui.readyMenu.init(); \t\t\t//更新右键点击事件\n }\n\n //对方同意添群(加入群组栏目)\n function addIQgroup(message) {\n layim.addList({\n type: 'group' \t\t\t\t\t//列表类型,只支持friend和group两种\n ,avatar: message.avatar\t\t\t//群组头像\n ,groupname: message.groupname \t//群组名称\n ,id: message.id \t\t\t\t\t//群组id\n });\n layim.msgbox('新');\n $(\"#fhsmsobj\").html('');\n }\n\n //群解散\n function delQgroup(QGROUP_ID) {\n layui.layim.removeList({\n type: 'group'\n ,id: QGROUP_ID //群ID\n });\n layim.msgbox('新');\n $(\"#fhsmsobj\").html('');\n }\n\n //监听发送消息\n layim.on('sendMessage', function (data) {\n layer.closeAll('loading');\n let To = data.to;\t\t//当前用户资料\n let mine = data.mine; \t//发送者数据(消息内容以及发送者资料)\n /**\n * user:发送者用户名\n * uname:发送者用户姓名\n * To.id:对方用户名\n * To.type:消息类型 group or friend\n * mine.avatar:发送者用户头像\n * mine.content:消息内容\n */\n window.webSocket.send(\",fhadmin-msg,\" + user + \",fh,\" + _this.uname + \",fh,\" + To.id + \",fh,\" + To.type + \",fh,\" + mine.avatar + \",fh,\" + mine.content + ',fh,' +mine.id);\n });\n\n //监听群员\n layim.on('members', function (data) {\n console.log(data);\n });\n\n //监听聊天窗口的切换\n layim.on('chatChange', function (res) {\n let type = res.data.type;\n if (type === 'friend') {\n } else if (type === 'group') {\n }\n });\n\n });\n }\n }\n}\n",null]}