diff --git a/public/im/im.js b/public/im/im.js index abfedc6..5b6509e 100644 --- a/public/im/im.js +++ b/public/im/im.js @@ -1,48 +1,57 @@ +var currentUser_id = 0 + //扩展对象方法 $.extend({ //为对象新增ajaxPost方法 request: function (ajaxOpts) { var opts = { - type: "POST", - dataType: "json", + type: 'POST', + dataType: 'json', timeout: 50000, loading: true, data: { - typ: 'json'}, - success: function (data, status) { + typ: 'json', }, + success: function (data, status) {}, error: function (err, status) { - Public.tipMsg(__('操作无法成功,请稍后重试!')); + Public.tipMsg(__('操作无法成功,请稍后重试!')) }, beforeSend: function (request) { // 规范写法 不可随意自定义 - if (localStorage.getItem("ukey")) { - request.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("ukey")); + if (localStorage.getItem('ukey')) { + request.setRequestHeader( + 'Authorization', + 'Bearer ' + localStorage.getItem('ukey') + ) } - } - }; + }, + } - $.extend(true, opts, ajaxOpts); + $.extend(true, opts, ajaxOpts) - if (opts.loading) { //loading + if (opts.loading) { + //loading //var $this = $(this); - var loading; + var loading //var myTimer; //var preventTooFast = 'ui-btn-dis'; $.extend(true, opts, { beforeSend: function (request) { // 规范写法 不可随意自定义 - if (localStorage.getItem("ukey")) { - request.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("ukey")); + if (localStorage.getItem('ukey')) { + request.setRequestHeader( + 'Authorization', + 'Bearer ' + localStorage.getItem('ukey') + ) } }, complete: function () { //loading.close(); - } - }); + }, + }) /* if ($this.hasClass(preventTooFast)) @@ -52,9 +61,8 @@ $.extend({ */ } - - var successCallback = opts.success; - var errorCallback = opts.error; + var successCallback = opts.success + var errorCallback = opts.error opts.success = function (data, status) { /*if(data.status != 200){ @@ -67,120 +75,126 @@ $.extend({ defaultPage.Public.tips({type:1, content:errorStr}); return; }*/ - successCallback && successCallback(data, status); + if (data && data.status == 200) { + let _data = data.data + currentUser_id = _data.user_info.user_id + } + successCallback && successCallback(data, status) } opts.error = function (err, ms) { var content = __('服务端响应错误!') if (ms === 'timeout') { - content = __('请求超时!'); + content = __('请求超时!') } - Public.tipMsg(content); - errorCallback && errorCallback(err); + Public.tipMsg(content) + errorCallback && errorCallback(err) } - $.ajax(opts); - } -}); - + $.ajax(opts) + }, +}) $.extend({ //为对象新增ajaxPost方法 send: function (url, data, callback, type) { // shift arguments if data argument was omitted if (jQuery.isFunction(data)) { - type = type || callback; - callback = data; - data = undefined; + type = type || callback + callback = data + data = undefined } // The url can be an options object (which then must have .url) - return $.request(jQuery.extend({ - url: url, - type: 'GET', - dataType: type, - data: data, - loading: false, - success: callback - }, jQuery.isPlainObject(url) && url)); - } -}); + return $.request( + jQuery.extend( + { + url: url, + type: 'GET', + dataType: type, + data: data, + loading: false, + success: callback, + }, + jQuery.isPlainObject(url) && url + ) + ) + }, +}) -var socket_connect = 0;//连接状态 -var socket_handle = null; +var socket_connect = 0 //连接状态 +var socket_handle = null -var vid = 10001; //固定用户调试使用 - -if (localStorage.getItem("ukey")) { +var vid = 10001 //固定用户调试使用 +if (localStorage.getItem('ukey')) { } else { //临时用户 - vid = parseInt(Math.random() * (99999999999 - 10000000000 + 1) + 10000000000, 10); + vid = parseInt( + Math.random() * (99999999999 - 10000000000 + 1) + 10000000000, + 10 + ) } window.initIm = function () { //$.send(sprintf("%s/account.php?ctl=%s&met=%s&typ=json", SYS.CONFIG.base_url, 'Index', 'getConfig'), {uid:vid}, function (res) - $.send(SYS.CONFIG.im_config, {uid: vid}, function (res) { - + $.send(SYS.CONFIG.im_config, { uid: vid }, function (res) { if (res.status == 200 && res.data.im_chat) { - - var userInfo = res.data.user_info; - var resourceSiteUrl = res.data.resource_site_url; - var suid = res.data.suid; - var puid = res.data.puid; + var userInfo = res.data.user_info + var resourceSiteUrl = res.data.resource_site_url + var suid = res.data.suid + var puid = res.data.puid resourceSiteUrl = window.admin_url function addCSS(url) { - var link = document.createElement('link'); - link.type = 'text/css'; - link.rel = 'stylesheet'; - link.href = url; - document.getElementsByTagName("head")[0].appendChild(link); + var link = document.createElement('link') + link.type = 'text/css' + link.rel = 'stylesheet' + link.href = url + document.getElementsByTagName('head')[0].appendChild(link) } - addCSS(resourceSiteUrl + '/im/css/layui.css?v=' + SYS.VER); + addCSS(resourceSiteUrl + '/im/css/layui.css?v=' + SYS.VER) - $.getScript(resourceSiteUrl + '/im/layui.js?v=' + SYS.VER, function () { - layui.config({ - base: resourceSiteUrl + '/im/', //你存放新模块的目录,注意,不是layui的模块目录 - dir: resourceSiteUrl + '/im/' - }); //加载入口 + $.getScript( + resourceSiteUrl + '/im/layui.js?v=' + SYS.VER, + function () { + layui.config({ + base: resourceSiteUrl + '/im/', //你存放新模块的目录,注意,不是layui的模块目录 + dir: resourceSiteUrl + '/im/', + }) //加载入口 - if (!/^http(s*):\/\//.test(location.href)) { - alert('请部署到localhost上查看该演示'); - } + if (!/^http(s*):\/\//.test(location.href)) { + alert('请部署到localhost上查看该演示') + } + layui.use('layim', function (layim) { + //演示自动回复 + var autoReplay = [ + '您好,我现在有事不在,一会再和您联系。', + '你没发错吧?face[微笑] ', + '洗澡中,请勿打扰,偷窥请购票,个体四十,团体八折,订票电话:一般人我不告诉他!face[哈哈] ', + '你好,我是主人的美女秘书,有什么事就跟我说吧,等他回来我会转告他的。face[心] face[心] face[心] ', + 'face[威武] face[威武] face[威武] face[威武] ', + '<(@ ̄︶ ̄@)>', + '你要和我说话?你真的要和我说话?你确定自己想说吗?你一定非说不可吗?那你说吧,这是自动回复。', + 'face[黑线] 你慢慢说,别急……', + '(*^__^*) face[嘻嘻] ,是贤心吗?', + ] - layui.use('layim', function (layim) { + var config_data = { + //初始化接口 + init: { + //url: sprintf("%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json", SYS.CONFIG.base_url, 'User_Friend', 'getFriendsInfo'), + //url: SYS.CONFIG.friend_info_lists, + url: SYS.CONFIG.im_config, + data: {}, + }, - //演示自动回复 - var autoReplay = [ - '您好,我现在有事不在,一会再和您联系。', - '你没发错吧?face[微笑] ', - '洗澡中,请勿打扰,偷窥请购票,个体四十,团体八折,订票电话:一般人我不告诉他!face[哈哈] ', - '你好,我是主人的美女秘书,有什么事就跟我说吧,等他回来我会转告他的。face[心] face[心] face[心] ', - 'face[威武] face[威武] face[威武] face[威武] ', - '<(@ ̄︶ ̄@)>', - '你要和我说话?你真的要和我说话?你确定自己想说吗?你一定非说不可吗?那你说吧,这是自动回复。', - 'face[黑线] 你慢慢说,别急……', - '(*^__^*) face[嘻嘻] ,是贤心吗?' - ]; - - var config_data = { - - //初始化接口 - init: { - //url: sprintf("%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json", SYS.CONFIG.base_url, 'User_Friend', 'getFriendsInfo'), - //url: SYS.CONFIG.friend_info_lists, - url: SYS.CONFIG.im_config, - data: { - } - } - - //或采用以下方式初始化接口 - /* + //或采用以下方式初始化接口 + /* ,init: { mine: { "username": "LayIM体验者" //我的昵称 @@ -194,90 +208,94 @@ window.initIm = function () { } */ + //查看群员接口 + members: { + url: sprintf( + '%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json', + SYS.CONFIG.base_url, + 'User_Zone', + 'getMembers' + ), + data: {}, + }, - //查看群员接口 - , members: { - url: sprintf("%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json", SYS.CONFIG.base_url, 'User_Zone', 'getMembers') - , data: {} + //上传图片接口 + uploadImage: { + url: SYS.CONFIG.upload, //(返回的数据格式见下文) + type: 'post', //默认post + }, + + //上传文件接口 + uploadFile: { + url: SYS.CONFIG.upload, //(返回的数据格式见下文) + type: 'post', //默认post + }, + + isAudio: true, //开启聊天工具栏音频 + isVideo: true, //开启聊天工具栏视频 + + //扩展工具栏 + tool: [ + { + alias: 'code', + title: '代码', + icon: '', + }, + ], + + //,brief: true //是否简约模式(若开启则不显示主面板) + + title: '客服', //自定义主面板最小化时的标题 + right: '0px', //主面板相对浏览器右侧距离 + //,minRight: '90px' //聊天面板最小化时相对浏览器右侧距离 + initSkin: '5.jpg', //1-5 设置初始背景 + //,skin: ['aaa.jpg'] //新增皮肤 + //,isfriend: false //是否开启好友 + isgroup: true, //是否开启群组 + min: true, //是否始终最小化主面板,默认false + notice: true, //是否开启桌面消息提醒,默认false + //,voice: false //声音提醒,默认开启,声音文件为:default.mp3 + + msgbox: layui.cache.dir + 'css/modules/layim/html/msgbox.html', //消息盒子页面地址,若不开启,剔除该项即可 + find: layui.cache.dir + 'css/modules/layim/html/find.html', //发现页面地址,若不开启,剔除该项即可 + chatLog: layui.cache.dir + 'css/modules/layim/html/chatlog.html', //聊天记录页面地址,若不开启,剔除该项即可 } - //上传图片接口 - , uploadImage: { - url: SYS.CONFIG.upload //(返回的数据格式见下文) - , type: 'post' //默认post + if (typeof ajaxCart != 'undefined') { + config_data['right'] = '36px' } - //上传文件接口 - , uploadFile: { - url: SYS.CONFIG.upload //(返回的数据格式见下文) - , type: 'post' //默认post - } + if (userInfo) { + } else { + $.cookie('vid', vid) - , isAudio: true //开启聊天工具栏音频 - , isVideo: true //开启聊天工具栏视频 + config_data = { + init: { + //配置客户信息 + mine: { + username: '访客', //我的昵称 + id: puid || vid, //我的ID + user_id: vid, //我的ID + status: 'online', //在线状态 online:在线、hide:隐身 + remark: '在深邃的编码世界,做一枚轻盈的纸飞机', //我的签名 + avatar: resourceSiteUrl + '/im/images/user_no_avatar.png', //我的头像 + }, + }, + title: '客服', //自定义主面板最小化时的标题 - //扩展工具栏 - , tool: [{ - alias: 'code' - , title: '代码' - , icon: '' - }] - - //,brief: true //是否简约模式(若开启则不显示主面板) - - , title: '客服' //自定义主面板最小化时的标题 - , right: '0px' //主面板相对浏览器右侧距离 - //,minRight: '90px' //聊天面板最小化时相对浏览器右侧距离 - , initSkin: '5.jpg' //1-5 设置初始背景 - //,skin: ['aaa.jpg'] //新增皮肤 - //,isfriend: false //是否开启好友 - , isgroup: true //是否开启群组 - , min: true //是否始终最小化主面板,默认false - , notice: true //是否开启桌面消息提醒,默认false - //,voice: false //声音提醒,默认开启,声音文件为:default.mp3 - - , msgbox: layui.cache.dir + 'css/modules/layim/html/msgbox.html' //消息盒子页面地址,若不开启,剔除该项即可 - , find: layui.cache.dir + 'css/modules/layim/html/find.html' //发现页面地址,若不开启,剔除该项即可 - , chatLog: layui.cache.dir + 'css/modules/layim/html/chatlog.html' //聊天记录页面地址,若不开启,剔除该项即可 - - }; - - - if (typeof ajaxCart != 'undefined') { - config_data['right'] = '36px'; - } - - if (userInfo) { - } else { - $.cookie('vid', vid); - - config_data = { - init: { - //配置客户信息 - mine: { - "username": "访客" //我的昵称 - , "id": puid || vid //我的ID - , "user_id": vid //我的ID - , "status": "online" //在线状态 online:在线、hide:隐身 - , "remark": "在深邃的编码世界,做一枚轻盈的纸飞机" //我的签名 - , "avatar": resourceSiteUrl + '/im/images/user_no_avatar.png' //我的头像 - } + //开启客服模式 + brief: true, + isfriend: false, //是否开启好友 + isgroup: false, //是否开启群组 + min: true, //是否始终最小化主面板,默认false + notice: true, //是否开启桌面消息提醒,默认false } - , title: '客服' //自定义主面板最小化时的标题 - - //开启客服模式 - , brief: true - , isfriend: false //是否开启好友 - , isgroup: false //是否开启群组 - , min: true //是否始终最小化主面板,默认false - , notice: true //是否开启桌面消息提醒,默认false } - } - //基础配置 - layim.config(config_data); + //基础配置 + layim.config(config_data) - /* + /* layim.chat({ name: '在线客服-小苍' ,type: 'kefu' @@ -292,46 +310,101 @@ window.initIm = function () { }); layim.setChatMin();*/ - //监听在线状态的切换事件 - layim.on('online', function (data) { - //console.log(data); - if (data == "online") { - setonline(); //用户上线 - } else { - sethide();//用户离线 + //切换在线状态的方法 + var setonline = function () { + socket_handle.send('_online_user_' + currentUser_id) } - }); - //监听签名修改 - layim.on('sign', function (value) { - console.log(value); - $.request({ - type: 'post', - url: SYS.CONFIG.edit_sign, - data: {user_sign: value}, - dataType: 'json', - success: function (result) { + //切换离线状态的方法 + var sethide = function () { + console.log(currentUser_id) + socket_handle.send('_leave_user_' + currentUser_id) + } + + //更新在线用户信息 + function updateOnlineStatus(arra) { + //更新在线用户信息 + $( + 'div.layui-layim-main ul.layim-list-friend li ul.layui-layim-list li' + ).each(function () { + //状态还原 + if (this.className != 'layim-null') { + var span = $(this).find('span:first') + var name = span.html() + var loginName = this.className + .replace('layim-friend', '') + .trim() + //alert(arra+"***"+loginName); + if ((',' + arra + ',').indexOf(',' + loginName + ',') >= 0) { + if (name.indexOf('(离线)') >= 0) { + span.replace( + '(离线)', + '(在线)' + ) + } else if ( + name.indexOf('(在线)') >= 0 + ) { + } else { + span.html(name + '(在线)') + } + } else { + if (name.indexOf('(离线)') >= 0) { + } else if ( + name.indexOf('(在线)') >= 0 + ) { + span.replace( + '(在线)', + '(离线)' + ) + } else { + span.html(name + '(离线)') + } + } + } + }) + } + + //监听在线状态的切换事件 + layim.on('online', function (data) { + //console.log(data); + if (data == 'online') { + setonline() //用户上线 + } else { + sethide() //用户离线 } - }); - }); + }) - //监听自定义工具栏点击,以添加代码为例 - layim.on('tool(code)', function (insert) { - layer.prompt({ - title: __('插入代码') - , formType: 2 - , shade: 0 - }, function (text, index) { - layer.close(index); - insert('[pre class=layui-code]' + text + '[/pre]'); //将内容插入到编辑器 - }); - }); + //监听签名修改 + layim.on('sign', function (value) { + console.log(value) + $.request({ + type: 'post', + url: SYS.CONFIG.edit_sign, + data: { user_sign: value }, + dataType: 'json', + success: function (result) {}, + }) + }) - //监听layim建立就绪 - layim.on('ready', function (res) { + //监听自定义工具栏点击,以添加代码为例 + layim.on('tool(code)', function (insert) { + layer.prompt( + { + title: __('插入代码'), + formType: 2, + shade: 0, + }, + function (text, index) { + layer.close(index) + insert('[pre class=layui-code]' + text + '[/pre]') //将内容插入到编辑器 + } + ) + }) - //console.log(res.mine); - /* + //监听layim建立就绪 + layim.on('ready', function (res) { + //console.log(res.mine); + /* layim.msgbox(5); //模拟消息盒子有新消息,实际使用时,一般是动态获得 //添加好友(如果检测到该socket) @@ -354,9 +427,9 @@ window.initIm = function () { */ - setTimeout(function () { - //接受消息(如果检测到该socket) - /* + setTimeout(function () { + //接受消息(如果检测到该socket) + /* layim.getMessage({ username: "Hi" ,avatar: "http://qzapp.qlogo.cn/qzapp/100280987/56ADC83E78CEC046F8DF2C5D0DD63CDE/100" @@ -373,75 +446,81 @@ window.initIm = function () { ,content: "嗨,你好!欢迎体验LayIM。演示标记:"+ new Date().getTime() }); */ + }, 3000) + }) - }, 3000); - }); + //监听发送消息 + layim.on('sendMessage', function (data) { + var To = data.to //对方的信息 + //跨平台用户修正 + //data['to']['id'] = suid + '-' + data['to']['id']; + //console.log(data); + //发送消息 + if (socket_connect === 1) { + if (userInfo) { + if (To.type === 'group') { + var url = sprintf( + '%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json', + SYS.CONFIG.base_url, + 'User_Zone', + 'addMessage' + ) - //监听发送消息 - layim.on('sendMessage', function (data) { - var To = data.to;//对方的信息 - //跨平台用户修正 - //data['to']['id'] = suid + '-' + data['to']['id']; - //console.log(data); - //发送消息 - if (socket_connect === 1) { - if (userInfo) { - if (To.type === 'group') { - var url = sprintf("%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json", SYS.CONFIG.base_url, 'User_Zone', 'addMessage'); + url = SYS.CONFIG.zonemsg_add_msg + } else { + var url = sprintf( + '%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json', + SYS.CONFIG.base_url, + 'User_Message', + 'add' + ) + url = SYS.CONFIG.msg_add + } - url = SYS.CONFIG.zonemsg_add_msg; - } else { - var url = sprintf("%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json", SYS.CONFIG.base_url, 'User_Message', 'add'); - url = SYS.CONFIG.msg_add; - } + console.info(data) - console.info(data); + var params = {} + params['user_other_id'] = data.to.friend_id + params['message_content'] = data.mine.content + params['item_id'] = 0 + params['length'] = 0 + params['w'] = 0 + params['h'] = 0 + //params["type"] = text - var params = {}; - params["user_other_id"] = data.to.friend_id - params["message_content"] = data.mine.content - params["item_id"] = 0 - params["length"] = 0 - params["w"] = 0 - params["h"] = 0 - //params["type"] = text + $.request({ + type: 'get', + //url: SYS.URL.user.msg_add, + url: url, + data: params, + dataType: 'json', + success: function (result) { + if (result.status == 200) { + var msgData = result.data + data['mine']['message_id'] = msgData.message_other_id - - - $.request({ - type: 'get', - //url: SYS.URL.user.msg_add, - url: url, - data: params, - dataType: 'json', - success: function (result) { - if (result.status == 200) { - var msgData = result.data; - data['mine']['message_id'] = msgData.message_other_id; - - /* + /* var e = socket.createEvent('send_msg'); e.data = msgData; socket.dispatchEvent(e); */ - //向服务器发送数据 - var text = JSON.stringify(data); - socket_handle.send(text); - } else { - return false; - } - } - }); - } else { - //向服务器发送数据 - var text = JSON.stringify(data); - socket_handle.send(text); - + //向服务器发送数据 + var text = JSON.stringify(data) + socket_handle.send(text) + } else { + return false + } + }, + }) + } else { + //向服务器发送数据 + var text = JSON.stringify(data) + socket_handle.send(text) + } } - } - /* + /* if(To.type === 'friend'){ layim.setChatStatus('对方正在输入。。。'); } @@ -470,23 +549,23 @@ window.initIm = function () { layim.getMessage(obj); }, 1000); */ - }); + }) - //监听查看群员 - layim.on('members', function (data) { - //console.log(data); - }); + //监听查看群员 + layim.on('members', function (data) { + //console.log(data); + }) - //监听聊天窗口的切换 - layim.on('chatChange', function (res) { - var type = res.data.type; - console.log(res.data.id) - if (type === 'friend') { - //模拟标注好友状态 - //layim.setChatStatus('在线'); - } else if (type === 'group') { - //模拟系统消息 - /* + //监听聊天窗口的切换 + layim.on('chatChange', function (res) { + var type = res.data.type + console.log(res.data.id) + if (type === 'friend') { + //模拟标注好友状态 + //layim.setChatStatus('在线'); + } else if (type === 'group') { + //模拟系统消息 + /* layim.getMessage({ system: true ,id: res.data.id @@ -494,168 +573,143 @@ window.initIm = function () { ,content: '模拟群员'+(Math.random()*100|0) + '加入群聊' }); */ - } - }); - - - var connentNode = function (data) { - nodeSiteUrl = data.node_site_url; - resourceSiteUrl = data.resource_site_url; - - - var script = document.createElement("script"); - script.type = "text/javascript"; - script.src = resourceSiteUrl + '/js/reconnecting-websocket.js?v=' + SYS.VER; - document.body.appendChild(script); - checkIO(); - - function checkIO() { - setTimeout(function () { - if (typeof ReconnectingWebSocket === "function") { - connect_node(); - } else { - checkIO(); - } - }, 500); - } - - function connect_node() { - var connect_url = nodeSiteUrl; - var member = {}; - - - socket_connect = 0;//连接状态 - socket_handle = new ReconnectingWebSocket(connect_url); - socket_handle.onopen = function (event) { - socket_connect = 1; - console.info('open'); - console.info(event); - }; - - socket_handle.onconnecting = function (event) { - console.info(event); - }; - - socket_handle.onmessage = function (event) { - console.info(event); - - var msg_row = JSON.parse(event.data); - - - if (typeof msg_row.msg_type !== "undefined") { - if (msg_row.msg_type == 'text') { - - } else if (msg_row.msg_type == 'voice') { - msg_row.content = 'audio[' + msg_row.content + ']'; - - } else if (msg_row.msg_type == 'img') { - msg_row.content = 'img[' + msg_row.content + ']'; - } - } - - - if (msg_row.message_id) { - //消息设置为已读 - var url = sprintf("%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json", SYS.CONFIG.base_url, 'User_Message', 'setRead'); - url = SYS.CONFIG.msg_set_read; - - $.request({ - type: 'post', - url: url, - data: {message_id: msg_row.message_id}, - dataType: 'json', - success: function (result) { - } - }); - - } - - layim.getMessage(msg_row); } - ; + }) - socket_handle.onerror = function (event) { - console.info(event); - }; - socket_handle.onclose = function (event) { - console.info(event); - }; + var connentNode = function (data) { + nodeSiteUrl = data.node_site_url + resourceSiteUrl = data.resource_site_url - //开始 - //结束 - } - - // 表情 - function update_chat_msg(msg) { - if (typeof smilies_array !== "undefined") { - msg = '' + msg; - for (var i in smilies_array[1]) { - var s = smilies_array[1][i]; - var re = new RegExp("" + s[1], "g"); - var smilieimg = '' + s[6] + ''; - msg = msg.replace(re, smilieimg); - } - } - return msg; - } - - //发送消息的方法 - function send(mine, To) { - socket_handle.send(currentUser_id + "_msg_" + To.id + "_msg_" + mine.content + "_msg_" + mine.avatar + "_msg_" + To.type + "_msg_" + currentName + "_msg_NAN"); - }; - - //切换在线状态的方法 - function setonline() { - socket_handle.send("_online_user_" + currentUser_id); - }; - - //切换离线状态的方法 - function sethide() { - socket_handle.send("_leave_user_" + currentUser_id); - }; - - //更新在线用户信息 - function updateOnlineStatus(arra)//更新在线用户信息 - { - $("div.layui-layim-main ul.layim-list-friend li ul.layui-layim-list li").each(function () {//状态还原 - if (this.className != 'layim-null') { - var span = $(this).find("span:first"); - var name = span.html(); - var loginName = this.className.replace("layim-friend", "").trim(); - //alert(arra+"***"+loginName); - if ((',' + arra + ",").indexOf(',' + loginName + ',') >= 0) { - if (name.indexOf('(离线)') >= 0) { - span.replace('(离线)', '(在线)') - } else if (name.indexOf('(在线)') >= 0) { - - } else { - span.html(name + '(在线)'); - } + var script = document.createElement('script') + script.type = 'text/javascript' + script.src = + resourceSiteUrl + '/js/reconnecting-websocket.js?v=' + SYS.VER + document.body.appendChild(script) + checkIO() + function checkIO() { + setTimeout(function () { + if (typeof ReconnectingWebSocket === 'function') { + connect_node() } else { - if (name.indexOf('(离线)') >= 0) { - } else if (name.indexOf('(在线)') >= 0) { - span.replace('(在线)', '(离线)') - } else { - span.html(name + '(离线)'); - } + checkIO() + } + }, 500) + } + function connect_node() { + var connect_url = nodeSiteUrl + var member = {} + + socket_connect = 0 //连接状态 + socket_handle = new ReconnectingWebSocket(connect_url) + socket_handle.onopen = function (event) { + socket_connect = 1 + console.info('open') + console.info(event) + } + + socket_handle.onconnecting = function (event) { + console.info(event) + } + + socket_handle.onmessage = function (event) { + console.info(event) + + var msg_row = JSON.parse(event.data) + + if (typeof msg_row.msg_type !== 'undefined') { + if (msg_row.msg_type == 'text') { + } else if (msg_row.msg_type == 'voice') { + msg_row.content = 'audio[' + msg_row.content + ']' + } else if (msg_row.msg_type == 'img') { + msg_row.content = 'img[' + msg_row.content + ']' + } + } + + if (msg_row.message_id) { + //消息设置为已读 + var url = sprintf( + '%s/account.php?mdu=sns&ctl=%s&met=%s&typ=json', + SYS.CONFIG.base_url, + 'User_Message', + 'setRead' + ) + url = SYS.CONFIG.msg_set_read + + $.request({ + type: 'post', + url: url, + data: { message_id: msg_row.message_id }, + dataType: 'json', + success: function (result) {}, + }) + } + + layim.getMessage(msg_row) + } + + socket_handle.onerror = function (event) { + console.info(event) + } + socket_handle.onclose = function (event) { + console.info(event) + } + + //开始 + //结束 + } + + // 表情 + function update_chat_msg(msg) { + if (typeof smilies_array !== 'undefined') { + msg = '' + msg + for (var i in smilies_array[1]) { + var s = smilies_array[1][i] + var re = new RegExp('' + s[1], 'g') + var smilieimg = + '' +
+                      s[6] +
+                      '' + msg = msg.replace(re, smilieimg) } } - }); + return msg + } + + //发送消息的方法 + function send(mine, To) { + socket_handle.send( + currentUser_id + + '_msg_' + + To.id + + '_msg_' + + mine.content + + '_msg_' + + mine.avatar + + '_msg_' + + To.type + + '_msg_' + + currentName + + '_msg_NAN' + ) + } } - } - connentNode(res.data); - }); - - - }, true); + connentNode(res.data) + }) + }, + true + ) } - }); - + }) } //登录后执行 -//initIm(); - +// initIm() diff --git a/src/api/shopAudit/shopAudit.js b/src/api/shopAudit/shopAudit.js index a351152..71673ef 100644 --- a/src/api/shopAudit/shopAudit.js +++ b/src/api/shopAudit/shopAudit.js @@ -4,8 +4,8 @@ import { URL } from '@/config' /** * @name 商家申请入驻信息分页列表 * @api api_url + '/admin/shop/merch/list' - * @param { id } - * @returns + * @param { id } + * @returns */ export function getPrinterList(params) { @@ -15,15 +15,15 @@ export function getPrinterList(params) { headers: { 'Content-Type': 'application/json', }, - data:params, + data: params, }) } /** * @name 商家申请入驻信息详情 * @api api_url + '/admin/shop/merch/detail' - * @param { id } - * @returns + * @param { id } + * @returns */ export function getMerchDetail(params) { @@ -33,15 +33,15 @@ export function getMerchDetail(params) { headers: { 'Content-Type': 'application/json', }, - data:params, + data: params, }) } /** * @name 审批商家申请入驻 * @api api_url + '/admin/shop/merch/approval' - * @param { id , approvalStatus , approvalRemark} - * @returns + * @param { id , approvalStatus , approvalRemark} + * @returns */ export function getMerchApproval(params) { @@ -51,16 +51,15 @@ export function getMerchApproval(params) { headers: { 'Content-Type': 'application/json', }, - data:params, + data: params, }) } - /** * @name 发起合同签署 * @api api_url + '/admin/shop/esign/sign-flow/create-by-file' - * @param { id , approvalStatus , approvalRemark} - * @returns + * @param { id , approvalStatus , approvalRemark} + * @returns */ export function getCreateByFile(params) { @@ -70,15 +69,15 @@ export function getCreateByFile(params) { headers: { 'Content-Type': 'application/json', }, - data:params, + data: params, }) } /** * @name 查看商家签署合同 * @api api_url + '/admin/shop/esign/signed/contract/file' - * @param { mchMobile } - * @returns + * @param { mchMobile } + * @returns */ export function getCheckContractFile(params) { @@ -88,8 +87,42 @@ export function getCheckContractFile(params) { headers: { 'Content-Type': 'application/json', }, - data:params, + data: params, }) } +/** + * @name 创建店铺(补偿机制) + * @api api_url + '/admin/shop/esign/signed/contract/file' + * @param { mchMobile } + * @returns + */ +export function createShop(params) { + return request({ + url: URL.shop.merch.createShop, + method: 'post', + headers: { + 'Content-Type': 'application/json', + }, + data: params, + }) +} + +/** + * @name 创建分账(补偿机制) + * @api api_url + '/admin/shop/esign/signed/contract/file' + * @param { mchMobile } + * @returns + */ + +export function createSubAccount(params) { + return request({ + url: URL.shop.merch.createSubAccount, + method: 'post', + headers: { + 'Content-Type': 'application/json', + }, + data: params, + }) +} diff --git a/src/baiduMap/index.js b/src/baiduMap/index.js index d1e0756..893a9d9 100644 --- a/src/baiduMap/index.js +++ b/src/baiduMap/index.js @@ -12,8 +12,7 @@ import BaiduMap from './../components/baidu_Map_xiufu' Vue.use(BaiduMap, { // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */ - ak: 'chsSzRvFcU1uXYoDHAHlsF98NkTVbzvE', + ak: 'it9e3OBa5JLwTT4V0YGyLUP02w3o1mml', }) - export default BaiduMap diff --git a/src/config/net.config.js b/src/config/net.config.js index 1b5f4c3..6fe9e00 100644 --- a/src/config/net.config.js +++ b/src/config/net.config.js @@ -438,6 +438,10 @@ let url = { createByFile: api_url + '/admin/shop/esign/sign-flow/create-by-file', //查看商家签署合同 checkContractFile: api_url + '/admin/shop/esign/signed/contract/file', + //创建店铺(补偿机制) + createShop: api_url + '/admin/shop/shop-store-base/mchinfo/to/storeinfo', + //创建分账(补偿机制) + createSubAccount: api_url + '/mobile/pay/lakala/ledger/applyLedgerMer', }, activity: { lottery: { diff --git a/src/views/settings/config/appVersion.vue b/src/views/settings/config/appVersion.vue index b5eee80..fc82487 100644 --- a/src/views/settings/config/appVersion.vue +++ b/src/views/settings/config/appVersion.vue @@ -183,12 +183,12 @@ - + > -