layui.define(['layer', 'laytpl', 'upload'], function(exports){ var v = '3.7.2 Pro'; var $ = layui.$; var layer = layui.layer; var laytpl = layui.laytpl; var device = layui.device(); var SHOW = 'layui-show', THIS = 'layim-this', MAX_ITEM = 20; //回调 var call = {}; //对外API var LAYIM = function(){ this.v = v; $('body').on('click', '*[layim-event]', function(e){ var othis = $(this), methid = othis.attr('layim-event'); events[methid] ? events[methid].call(this, othis, e) : ''; }); }; //基础配置 LAYIM.prototype.config = function(options){ var skin = []; layui.each(Array(5), function(index){ skin.push(layui.cache.dir+'css/modules/layim/skin/'+ (index+1) +'.jpg') }); options = options || {}; options.skin = options.skin || []; layui.each(options.skin, function(index, item){ skin.unshift(item); }); options.skin = skin; options = $.extend({ isfriend: !0 ,isgroup: !0 ,voice: 'default.mp3' }, options); if(!window.JSON || !window.JSON.parse) return; init(options); return this; }; //监听事件 LAYIM.prototype.on = function(events, callback){ if(typeof callback === 'function'){ call[events] ? call[events].push(callback) : call[events] = [callback]; } return this; }; //获取所有缓存数据 LAYIM.prototype.cache = function(){ return cache; }; //打开一个自定义的会话界面 LAYIM.prototype.chat = function(data){ if(!window.JSON || !window.JSON.parse) return; return popchat(data), this; }; //设置聊天界面最小化 LAYIM.prototype.setChatMin = function(){ return setChatMin(), this; }; //设置当前会话状态 LAYIM.prototype.setChatStatus = function(str){ var thatChat = thisChat(); if(!thatChat) return; var status = thatChat.elem.find('.layim-chat-status'); return status.html(str), this; }; //接受消息 LAYIM.prototype.getMessage = function(data){ return getMessage(data), this; }; //桌面消息通知 LAYIM.prototype.notice = function(data){ return notice(data), this; }; //打开添加好友/群组面板 LAYIM.prototype.add = function(data){ return popAdd(data), this; }; //好友分组面板 LAYIM.prototype.setFriendGroup = function(data){ return popAdd(data, 'setGroup'), this; }; //消息盒子的提醒 LAYIM.prototype.msgbox = function(nums){ return msgbox(nums), this; }; //添加好友/群 LAYIM.prototype.addList = function(data){ return addList(data), this; }; //删除好友/群 LAYIM.prototype.removeList = function(data){ return removeList(data), this; }; //设置好友在线/离线状态 LAYIM.prototype.setFriendStatus = function(id, type){ var list = $('.layim-friend'+ id); list[type === 'online' ? 'removeClass' : 'addClass']('layim-list-gray'); }; //解析聊天内容 LAYIM.prototype.content = function(content){ return layui.data.content(content); }; //主模板 var listTpl = function(options){ var nodata = { friend: __("该分组下暂无好友") ,group: __("暂无群组") ,history: __("暂无历史会话") }; options = options || {}; options.item = options.item || ('d.' + options.type); return ['{{# var length = 0; layui.each('+ options.item +', function(i, data){ length++; }}' ,'
{{ data.remark||data.sign||"" }}
new{{ d.data.name||"" }}
' + __('选择分组') + '
' ,'{{# } if(d.data.type === "friend"){ }}' ,'' ,'{{# } }}' ,'{{# if(d.data.type === "group"){ }}' ,'' + __('请输入验证信息') + '
' ,'{{# } if(d.type !== "setGroup"){ }}' ,'' ,'{{# } }}' ,'音频消息
'+ (data[l].remark||data[l].sign||'') +'