reim_xina.js 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467
  1. /**
  2. * REIM即时通信主js-最新版本
  3. * caratename:雨中磐石(rainrock)
  4. * caratetime:2018-11-01 21:40:00
  5. * homepage:www.rockoa.com
  6. */
  7. var agentarr={},userarr={},grouparr={},cnum='',windowfocus=true,jietubool=false;
  8. var reim={
  9. chatobj:{},
  10. maindata:{},
  11. initci:0,
  12. timeloads:0,
  13. ruloadtime:5*60, //5分钟
  14. init:function(){
  15. js.ajaxwurbo = true;
  16. this.centlistobj = $('#centlist');
  17. js.xpbodysplit = 0;
  18. date = js.now('Y-m-d');
  19. nwjs.init();
  20. bodyunload=function(){
  21. nwjs.removetray();
  22. reim.onoffline(0);
  23. }
  24. this.resize();
  25. nwjs.serverdata=function(d){
  26. return reim.serverdata(d);
  27. }
  28. //var sw = js.getoption('setchatlistw');
  29. //if(sw)$('#centlist').css('width',''+sw+'px');
  30. $(window).resize(this.resize);
  31. $(window).focus(function(){windowfocus=true;im.windowfocus()});
  32. $(window).blur(function(){windowfocus=false});
  33. //数秒
  34. setInterval('reim.timeload()', 1000);
  35. var fse=js.getoption('loginface');
  36. token =js.getoption('admintoken');
  37. if(fse)get('myface').src=fse;
  38. nwjs.createtray(document.title+'-'+adminname, 1);
  39. strformat.ismobile=0;
  40. //禁止后退
  41. try{
  42. history.pushState(null, null, document.URL);
  43. window.addEventListener('popstate', function (){
  44. history.pushState(null, null, document.URL);
  45. });
  46. }catch(e){}
  47. this.initload();
  48. this.centlistobj.perfectScrollbar();
  49. uploadobj = $.rockupload({
  50. inputfile:'allfileinput',
  51. initpdbool:false,
  52. updir:'reimchat',
  53. urlparams:{noasyn:'yes'}, //不需要同步到文件平台上
  54. onchange:function(d){
  55. im.sendfileshow(d);
  56. },
  57. onprogress:function(f,per,evt){
  58. im.upprogresss(per);
  59. },
  60. onsuccess:function(f,str,o1){
  61. im.sendfileok(f,str);
  62. },
  63. onerror:function(str){
  64. js.msg('msg', str);
  65. im.senderror();
  66. }
  67. });
  68. strformat.upobj = uploadobj;
  69. js.setoption('kefulist', '');
  70. $('body').keydown(function(e){
  71. return reim.bodykeydown(e);
  72. });
  73. //注册推送提醒的
  74. var ssrc = js.getoption('soundsrc');
  75. if(!ssrc)ssrc='web/res/sound/email.mp3';
  76. notifyobj=new notifyClass({
  77. title:'系统提醒',
  78. sound:ssrc,
  79. sounderr:'',
  80. soundbo:this.getsound(), //是否要声音
  81. showbool:false
  82. });
  83. this.righthistroboj = $.rockmenu({
  84. data:[],
  85. itemsclick:function(d){
  86. reim.rightclick(d);
  87. }
  88. });
  89. $('#reimcog').click(function(){
  90. reim.clickcog(this);
  91. return false;
  92. });
  93. $('#homeplus').click(function(){
  94. reim.clickcog(get('reimcog'));
  95. return false;
  96. });
  97. document.ondragover=function(e){e.preventDefault();};
  98. document.ondrop=function(e){e.preventDefault();};
  99. //注册全局ajax的错误
  100. js.ajaxerror=function(msg,code){
  101. if(code==401){
  102. js.msg();
  103. js.msgerror('登录失效,重新登录');
  104. if(!nwjsgui){
  105. js.location('/users/login?backurl=reim');
  106. }else{
  107. js.location('/reim/login.html');
  108. }
  109. }
  110. }
  111. if(!nwjsgui){
  112. $('#closediv').remove();
  113. }
  114. $('#reim_keysou').keyup(function(){reim.searchss();});
  115. $('#reim_keysou').click(function(){reim.searchss();});
  116. },
  117. resize:function(){
  118. viewheight = winHb(); //可操作高度
  119. $('#mindivshow').css('height',''+(viewheight)+'px');
  120. if(reim.centlistobj)reim.centlistobj.css('height',''+(viewheight-60)+'px');
  121. $('#viewzhulist').css('height',''+viewheight+'px');
  122. var obj = $('div[resizeh]'),o,hei;
  123. for(var i=0;i<obj.length;i++){
  124. o = $(obj[i]);
  125. hei=parseInt(o.attr('resizeh'));
  126. o.css('height',''+(viewheight-hei)+'px');
  127. }
  128. //控制最小宽高
  129. if(nwjsgui){
  130. var w1 = 900,h1 = 600;
  131. var wid = winWb();
  132. var hei = winHb();
  133. if(wid<w1)nwjs.win.width=w1;
  134. if(hei<h1)nwjs.win.height=h1;
  135. }
  136. },
  137. timeload:function(){
  138. this.timeloads++;
  139. //刷新
  140. if(this.timeloads >= this.ruloadtime){
  141. this.timeloads = 0;
  142. this.initload();
  143. }
  144. //if(this.timeloads==5)this.getonline();//获取在线人员id
  145. },
  146. bodykeydown:function(e){
  147. var code = e.keyCode;
  148. if(code==27){
  149. if($.imgviewclose())return false;
  150. var objt = $('div[tanbodynew]');
  151. if(objt.length>0){
  152. js.tanclose($(objt[objt.length-1]).attr('tanbodynew'));return false;
  153. }
  154. if(get('xpbg_bodydds')){
  155. js.tanclose($('#xpbg_bodydds').attr('xpbody'));
  156. }else{
  157. this.closenowtabss();
  158. }
  159. return false;
  160. }
  161. if(code==65 && e.altKey){//Alt+A截屏
  162. try{this.chatobj[this.nowtabs].cropScreen();}catch(e){}
  163. return false;
  164. }
  165. },
  166. winclose:function(){
  167. nwjs.win.hide();
  168. },
  169. winzuida:function(){
  170. if(!this.zdhbo){
  171. nwjs.win.maximize();
  172. this.zdhbo=true;
  173. }else{
  174. nwjs.win.unmaximize();
  175. this.zdhbo=false;
  176. }
  177. },
  178. changetabs:function(ind){
  179. $('div[id^="changetabs"]').removeClass('leftactive');
  180. $('div[id^="centshow"]').hide();
  181. $('#changetabs'+ind+'').addClass('leftactive');
  182. $('#centshow'+ind+'').show();
  183. if(ind==1)this.showdept();
  184. if(ind==2){
  185. $('#maincenter').hide();
  186. this.showagent(true);
  187. }else{
  188. this.hideagent();
  189. $('#maincenter').show();
  190. }
  191. this.centlistobj.scrollTop(0);
  192. this.centlistobj.find('.ps-scrollbar-y-rail').hide();
  193. this.showbadge('chat');
  194. },
  195. getapiurl:function(m,a,lx){
  196. if(lx=='gout')return this.outgroup.geturl(a);
  197. if(lx=='zixun' || lx=='wait')m='rockkefu';
  198. var dzs = 'api.php?m='+m+'&a='+a+'&cfrom=reim';
  199. if(companynum)dzs+='&dwnum='+companynum+'';
  200. return dzs;
  201. },
  202. //ajax访问处理
  203. ajax:function(url,cans, fun, lx,efun){
  204. if(!lx)lx='get';
  205. if(!fun)fun=function(){}
  206. if(!efun)efun=function(){}
  207. js.ajaxbool = false;
  208. js.ajax(url,cans,function(ret){
  209. if(ret.code==200){
  210. fun(ret);
  211. }else if(ret.code==199){
  212. if(!get('confirm_main'))js.confirm(ret.msg, function(){
  213. reim.exitlogin(true);
  214. });
  215. }else{
  216. js.msg('msg',ret.msg);
  217. efun(ret);
  218. }
  219. },''+lx+',json', efun);
  220. },
  221. //初始加载数据
  222. initload:function(bo){
  223. this.initbool = true;
  224. this.ajax(this.getapiurl('indexreim','indexinit'),{'initci':this.initci,'gtype':'reim'}, function(ret){
  225. reim.initci++;
  226. reim.showdata(ret.data);
  227. if(bo)reim.reloaduser();
  228. });
  229. },
  230. firstpid:0,
  231. showdata:function(ret){
  232. if(!ret.userjson)return;
  233. this.lastloaddt = ret.loaddt;
  234. this.maindata.darr = js.decode(ret.deptjson);
  235. this.maindata.uarr = js.decode(ret.userjson);
  236. this.maindata.garr = js.decode(ret.groupjson);
  237. this.maindata.harr = js.decode(ret.historyjson);
  238. this.onlinearr = ret.onlinearr;
  239. this.firstpid = this.maindata.darr[0].pid;
  240. if(!this.showconfigarr){
  241. this.showconfigarr = ret.config;
  242. this.websocketlink(ret.config);
  243. }
  244. var aarr = js.decode(ret.agentjson);
  245. var cbarr = {},i;
  246. for(i=0;i<aarr.length;i++){
  247. if(!cbarr[aarr[i].types])cbarr[aarr[i].types]=[];
  248. cbarr[aarr[i].types].push(aarr[i]);
  249. }
  250. this.maindata.aarr=cbarr;
  251. aarr = this.maindata.garr;
  252. for(i=0;i<aarr.length;i++){
  253. grouparr[aarr[i].id]=aarr[i];
  254. }
  255. aarr = this.maindata.uarr;
  256. for(i=0;i<aarr.length;i++){
  257. userarr[aarr[i].id]=aarr[i];
  258. }
  259. this.showagent(false);
  260. this.myip = ret.ip;
  261. this.outgroupopen = ret.outgroupopen;
  262. this.showhistory(this.maindata.harr);
  263. this.outgroup.loaddata(ret.outunum,0);
  264. if(this.kefu)this.kefu.loaddata();
  265. if(ret.editpass==0)this.editpass('请先修改密码后在使用','none');
  266. },
  267. //搜索联系人/会话/应用
  268. searchss:function(){
  269. clearTimeout(this.searchsstime);
  270. this.searchsstime=setTimeout('reim.searchssss()',500);
  271. if(!this.searchright)this.searchright=$.rockmenu({
  272. data:[],iconswh:20,width:210,
  273. itemsclick:function(d){
  274. reim.searchclick(d);
  275. }
  276. });
  277. },
  278. searchclick:function(d){
  279. var ty = d.type;
  280. if(ty=='user')this.showuserinfo(d.xuoi);
  281. if(ty=='group')this.openchat(d.type,d.id,d.name,d.icons);
  282. if(ty=='agent')this.openagenh(d.id);
  283. },
  284. searchssss:function(){
  285. var o = $('#reim_keysou'),val=strreplace(o.val());
  286. var d=[];
  287. if(val==''){
  288. this.searchright.hide();
  289. return;
  290. }
  291. val=val.toLowerCase();
  292. var off=o.offset(),sid,a,s1,arr,i,oi=1;
  293. arr = this.maindata.uarr;
  294. for(i=0;i<arr.length;i++){
  295. a=arr[i];
  296. if(a.name.indexOf(val)>-1 || a.pingyin.indexOf(val)==0 || a.deptname.indexOf(val)>-1 || a.ranking.indexOf(val)>-1){
  297. s1=''+a.name+'<font color=#888888>('+a.ranking+')</font>';
  298. d.push({name:s1,id:a.id,icons:a.face,type:'user',xuoi:i});
  299. oi++;
  300. }
  301. if(oi>10)break;//最多显示10人
  302. }
  303. arr = this.maindata.garr;
  304. for(i=0;i<arr.length;i++){
  305. a=arr[i];
  306. if(a.name.indexOf(val)>-1){
  307. s1=''+a.name+'<font color=#888888>(会话)</font>';
  308. d.push({name:s1,id:a.id,icons:a.face,type:'group'});
  309. }
  310. }
  311. for(sid in agenharr){
  312. a=agenharr[sid];
  313. if(a.name.indexOf(val)>-1){
  314. s1=''+a.name+'<font color=#888888>(应用)</font>';
  315. d.push({name:s1,id:a.id,icons:a.face,type:'agent'});
  316. }
  317. }
  318. if(d.length==0){
  319. this.searchright.hide();
  320. return;
  321. }
  322. this.searchright.setData(d);
  323. this.searchright.showAt(off.left+1,off.top+25,$('#reim_headercenter').width()-2);
  324. },
  325. websocketlink:function(a){
  326. if(this.connectbool){
  327. this.serverstatus(1);
  328. return false;
  329. }
  330. if(!a){
  331. this.serverstatus(3);
  332. return false;
  333. }
  334. var wsurl = jm.base64decode(a.wsurl),receid = a.recid;
  335. this.showconfigarr = a;
  336. if(isempt(wsurl) || wsurl.indexOf('ws')<0){
  337. this.serverstatus(3);
  338. return false;
  339. }
  340. clearTimeout(this.relianshotime_time);
  341. websocketobj = new websocketClass({
  342. adminid:adminid,
  343. reimfrom:receid,
  344. wshost:wsurl,
  345. sendname:adminname,
  346. onerror:function(o,ws){
  347. reim.connectbool=false;
  348. reim.serverstatus(0);
  349. js.msg('msg','无法连接服务器1<br><span id="lianmiaoshoetime"></span><a href="javascript:;" onclick="reim.connectservers()">[重连]</a>',0);
  350. reim.relianshotime(30);
  351. },
  352. onmessage:function(str){
  353. reim.connectbool=true;
  354. clearTimeout(reim.relianshotime_time);
  355. var a=js.decode(str);
  356. reim.receivemesb(a);
  357. },
  358. onopen:function(){
  359. reim.connectbool=true;
  360. reim.serverstatus(1);
  361. clearTimeout(reim.relianshotime_time);
  362. js.msg('none');
  363. reim.initnotify();
  364. setTimeout('reim.getonline()',1000);
  365. setTimeout('reim.onoffline(1)',2000);
  366. },
  367. onclose:function(o,e){
  368. reim.connectbool=false;
  369. if(reim.otherlogin)return;
  370. reim.serverstatus(0);
  371. js.msg('msg','连接已经断开了<br><span id="lianmiaoshoetime"></span><a href="javascript:;" onclick="reim.connectservers()">[重连]</a>',0);
  372. reim.relianshotime(10);
  373. }
  374. });
  375. },
  376. connectservers:function(){
  377. if(this.connectbool){
  378. this.serverstatus(1);
  379. return;
  380. }
  381. var bo = this.websocketlink(this.showconfigarr);
  382. if(bo)js.msg('wait','连接中...');
  383. },
  384. serverstatus:function(lx){
  385. var s = '<font color="green">已连接</font>';s='';
  386. if(lx==0)s='<font color="red">未连接</font>'
  387. if(lx==2)s='<font color="#ff6600">在别处连接</font>'
  388. if(lx==3)s='<font color="blue">没服务端</font>';
  389. $('#reim_statusserver').html(s);
  390. },
  391. relianshotime:function(oi){
  392. clearTimeout(this.relianshotime_time);
  393. $('#lianmiaoshoetime').html('('+oi+'秒后重连)');
  394. if(oi<=0){
  395. this.connectservers();
  396. }else{
  397. this.relianshotime_time=setTimeout('reim.relianshotime('+(oi-1)+')',1000);
  398. }
  399. },
  400. showdept:function(id){
  401. if($('#showdept').html()==''){
  402. this.reloaduser();
  403. }else{
  404. }
  405. },
  406. initnotify:function(){
  407. var lx=notifyobj.getaccess();
  408. if(lx!='ok'){
  409. //js.msg('msg','为了可及时收到信息通知 <br>请开启提醒,<span class="zhu cursor" onclick="reim.indexsyscogss()">[开启]</span>',-1);
  410. }
  411. },
  412. indexsyscogs:function(){
  413. var str = notifyobj.getnotifystr('reim.indexsyscogss()');
  414. return '桌面通知提醒'+str+'';
  415. },
  416. indexsyscogss:function(){
  417. notifyobj.opennotify(function(){
  418. js.msg('success', reim.indexsyscogs());
  419. });
  420. },
  421. reloaduser:function(){
  422. $('#showdept').html('');
  423. this.showuserlists(this.firstpid,0, 'showdept');
  424. this.showgroup();
  425. },
  426. //服务端发消息调用opener.reim.serversend(a);
  427. serversend:function(a){
  428. if(!this.connectbool)return false;
  429. websocketobj.send(a);
  430. return true;
  431. },
  432. //获取在线人员
  433. getonline:function(){
  434. this.serversend({'atype':'getonline'});
  435. },
  436. onoffline:function(on){
  437. this.serversend({'atype':'send','type':'onoffline','online':on,'receid':'all'});
  438. },
  439. //别的地方登录
  440. otherlogins:function(){
  441. this.otherlogin = true;
  442. var msg='已在别的地方连接了';
  443. js.msg('success', msg, -1);
  444. this.serverstatus(2);
  445. },
  446. //收到推送消息
  447. receivemesb:function(d, lob){
  448. var lx=d.type,sendid=d.adminid;
  449. d.zijiid = adminid;
  450. if(lx=='offoline'){
  451. this.otherlogins();
  452. return;
  453. }
  454. if(lx=='user' || lx=='group'){
  455. if(sendid!=adminid)this.receivechat(d);
  456. }
  457. if(lx=='agent'){
  458. this.receiveagenh(d);
  459. nwjs.jumpicon();
  460. }
  461. if(lx=='chehui'){
  462. $('#qipaocont_mess_'+d.messid+'').html(js.getmsg(jm.base64decode(d.cont),'green'));
  463. this.historyreload();
  464. }
  465. if(lx=='getonline'){
  466. this.addonline(d.online, true, 1);
  467. }
  468. if(lx=='onoffline'){
  469. this.addonline(sendid, false, d.online);
  470. }
  471. if(lx=='calltonghua'){
  472. this.calltonghua(d);
  473. }
  474. },
  475. addonline:function(s1,isa,zt){
  476. s1 = ''+s1+'';
  477. var a1 = s1.split(','),i,i1;
  478. if(isa)for(i in this.onlinearr)this.onlinearr[i].reim=0;
  479. for(i=0;i<a1.length;i++){
  480. i1 = a1[i];
  481. if(!this.onlinearr[i1])this.onlinearr[i1] = {reim:0,mobile:0,web:''};
  482. if(zt==2){this.onlinearr[i1].mobile=1;}else{this.onlinearr[i1].reim=zt;}
  483. }
  484. if(!isa){
  485. var o1 = $('div[temp="usname_user_'+s1+'"]');
  486. o1.find('font').remove();
  487. var str = this.getonlinestr(s1);
  488. if(str)o1.append(str);
  489. }
  490. },
  491. getonlinestr:function(uid){
  492. var str = '';
  493. var d = this.onlinearr[uid];
  494. this.nowonlinearr = d;
  495. if(!d)return str;
  496. if(d.reim==1)str+='<font title="PC端在线" class="zhu" style="font-size:10px;margin-left:5px"><i class="icon-desktop"></i></font>';
  497. if(d.mobile==1)str+='<font title="APP在线" class="zhu" style="font-size:10px;margin-left:5px"><i class="icon-tablet"></i></font>';
  498. return str;
  499. },
  500. showuserlists:function(pid,xu, svie){
  501. var o = $('#'+svie+'');
  502. var tx= o.text();
  503. if(tx){if(pid!=0){o.toggle();}return;}
  504. var a =this.maindata.uarr,i,len=a.length,d,dn,s='',wfj,zt,sids;
  505. for(i=0;i<len;i++){
  506. d=a[i];
  507. if(!userarr[d.id])userarr[d.id]=d;
  508. sids = ','+d.deptids+',';
  509. if(pid==d.deptid || sids.indexOf(','+pid+',')>-1){
  510. zt=this.getonlinestr(d.id);
  511. s='<div class="lists" onclick="reim.showuserinfo('+i+')" style="padding-left:'+(xu*20+10)+'px" >';
  512. s+='<table cellpadding="0" border="0" width="100%"><tr>';
  513. s+='<td style="padding-right:5px"><div style="height:24px;overflow:hidden"><img src="'+d.face+'" style="height:24px;width:24px"></div></td>';
  514. s+='<td align="left" width="100%"><div temp="usname_user_'+d.id+'" class="name">'+d.name+''+zt+'</div></td>';
  515. s+='</tr></table>';
  516. s+='</div>';
  517. o.append(s);
  518. }
  519. }
  520. a = this.maindata.darr;
  521. len=a.length;
  522. for(i=0;i<len;i++){
  523. d = a[i];
  524. if(d.pid==pid){
  525. wfj = 'icon-folder-close-alt';
  526. s='<div class="lists" style="padding-left:'+(xu*20+10)+'px" onclick="reim.showuserlists('+d.id+','+(xu+1)+',\'showdept_'+d.id+'\')">';
  527. s+=' <i class="'+wfj+'"></i> '+d.name+'';
  528. if(d.ntotal>0)s+=' <span style="font-size:12px;color:#888888">('+d.ntotal+')</span>';
  529. s+='</div>';
  530. s+='<span id="showdept_'+d.id+'"></span>';
  531. o.append(s);
  532. if(xu==0)this.showuserlists(d.id, xu+1, 'showdept_'+d.id+'');
  533. }
  534. }
  535. },
  536. showgroup:function(){
  537. var a =this.maindata.garr,ds=[],i;
  538. for(i=0;i<a.length;i++)ds.push(a[i]);
  539. if(this.outgroupopen=='open' && this.outgrouplist){
  540. for(i=0;i<this.outgrouplist.length;i++){
  541. this.outgrouplist[i].type1='gout';
  542. ds.push(this.outgrouplist[i]);
  543. }
  544. }
  545. var len=ds.length,d,s='',s1,lx;
  546. s='<div style="padding:5px;margin-top:5px;color:#aaaaaa;border-bottom:1px #e1e1e1 solid">会话('+len+')</div>';
  547. for(i=0;i<len;i++){
  548. d = ds[i];
  549. lx= d.type1;
  550. if(!lx)lx='group';
  551. s1= this.grouptype(d.deptid,lx);
  552. s+='<div onclick="reim.openchat(\''+lx+'\',\''+d.id+'\',\''+d.name+'\',\''+d.face+'\')" class="lists">';
  553. s+='<table cellpadding="0" border="0" width="100%"><tr>';
  554. s+='<td style="padding-right:5px"><div style="height:24px;overflow:hidden"><img src="'+d.face+'" style="height:24px;width:24px"></div></td>';
  555. s+=' <td align="left" width="100%"><div class="name">'+d.name+''+s1+'</div></td>';
  556. s+='</tr></table>';
  557. s+='</div>';
  558. }
  559. $('#showgroup').html(s)
  560. },
  561. historyreload:function(){
  562. this.ajax(this.getapiurl('indexreim','gethistory'),{id:0},function(
  563. ret){
  564. var data = ret.data;
  565. reim.showhistory(data);
  566. });
  567. },
  568. sortpaxh:function(d1,d2){
  569. if(d1.optdt > d2.optdt){
  570. return -1;
  571. }else if(d1.optdt < d2.optdt){
  572. return 1;
  573. }else{
  574. return 0;
  575. }
  576. },
  577. showhistory:function(a){
  578. var outstr = js.getoption('outgrouplist0'),i,outa,ds=[];
  579. for(i=0;i<a.length;i++)ds.push(a[i]);
  580. if(outstr && this.outgroupopen=='open'){
  581. outa = JSON.parse(outstr);
  582. for(i=0;i<outa.length;i++)ds.push(outa[i]);
  583. ds.sort(this.sortpaxh);
  584. }
  585. outstr = js.getoption('kefulist');
  586. if(outstr){
  587. outa = JSON.parse(outstr);
  588. for(i=0;i<outa.length;i++)ds.push(outa[i]);
  589. ds.sort(this.sortpaxh);
  590. }
  591. var len=ds.length;
  592. $('#historylist').html('');
  593. $('#historylist_tems').show();
  594. for(i=0;i<len;i++){
  595. this.showhistorys(ds[i]);
  596. }
  597. if(i>0)$('#historylist_tems').hide();
  598. },
  599. grouptype:function(did, lx){
  600. var s = '';
  601. if(lx=='gout')did='-1';
  602. if(lx=='zixun')did='-2';
  603. if(isempt(did) || (lx && lx=='user'))return s;
  604. if(did=='1')s=' <span class="reimlabel">全员</span>';
  605. if(did=='-1')s=' <span class="reimlabel2">外部</span>';
  606. //if(did=='-2')s=' <span class="reimlabel3">咨询</span>';
  607. if(did=='-2')s=' <span style="font-size:10px;color:#aaaaaa"><i class="icon-headphones"></i></span>';
  608. if(did>1)s=' <span class="reimlabel1">部门</span>';
  609. return s;
  610. },
  611. showhistorydata:{},
  612. showhistorys:function(d,pad, lex, glx){
  613. var s,ty,o=$('#historylist'),d1,st,nas=d.names,qz=d.qian;
  614. var num = ''+d.type+'_'+d.receid+'';
  615. this.showhistorydata[num]=d;
  616. $('#history_'+num+'').remove();
  617. st = d.stotal;if(st=='0')st='';
  618. if(!d.optdt)d.optdt=js.now('now');
  619. var ops = d.optdt.substr(11,5);
  620. if(d.optdt.indexOf(date)!=0)ops=d.optdt.substr(5,5);
  621. ty = d.type;
  622. var cls = lex ? ' active' : '';
  623. var na = d.name;
  624. if(d.title)na = d.title;
  625. var tit = ''+na+'';
  626. if(d.type=='group'){
  627. var d2 = grouparr[d.receid];
  628. if(d2)d.deptid = d2.deptid;
  629. }
  630. if(!nas)nas='';
  631. if(!qz)qz='chat';
  632. if(d.subname){
  633. nas+='<span style="color:'+maincolor+';font-size:10px">@'+d.subname+'</span>';
  634. tit+='@'+d.subname+'';
  635. }
  636. var s1 = this.grouptype(d.deptid,d.type);
  637. s = '<div class="lists'+cls+'" rtype="hist" oncontextmenu="reim.historyright(this,event,\''+num+'\')" tsaid="'+d.receid+'" tsaype="'+d.type+'" temp="hist" id="history_'+num+'" onclick="reim.openchat(\''+ty+'\',\''+d.receid+'\',\''+d.name+'\',\''+d.face+'\')">';
  638. s+='<table cellpadding="0" border="0" width="100%"><tr>';
  639. s+='<td style="padding-right:8px"><div style="height:30px;overflow:hidden"><img src="'+d.face+'"></div></td>';
  640. s+='<td align="left" width="100%"><div title="'+tit+'" id="lname_'+num+'" class="name">'+na+''+nas+''+s1+'</div><div class="huicont">'+jm.base64decode(d.cont)+'</div></td>';
  641. s+='<td align="right" nowrap><span id="'+qz+'_stotal_'+num+'" class="badge red">'+st+'</span><br><span style="color:#aaaaaa;font-size:10px">'+ops+'</span></td>';
  642. s+='</tr></table>';
  643. s+='</div>';
  644. if(glx)return s;
  645. if(!pad){o.append(s);}else{o.prepend(s)}
  646. $('#historylist_tems').hide();
  647. this.showbadge('chat');
  648. if(pad && (d.type=='gout' || d.type=='uout'))this.outgroup.updatelist(d.type,d.receid,d);
  649. },
  650. historyright:function(o1,e,num){
  651. var rt = $(o1).attr('rtype');
  652. if(isempt(rt))return false;
  653. this.rightdivobj = o1;
  654. var da=[{name:'打开',lx:0}],d=this.showhistorydata[num];
  655. if(d && d.stotal>0)da.push({name:'标识已读',lx:1});
  656. if(rt.indexOf('hist')>-1){
  657. da.push({name:'删除此记录',lx:2});
  658. }
  659. this.righthistroboj.setData(da);
  660. this.righthistroboj.showAt(e.clientX-3,e.clientY-3);
  661. return false;
  662. },
  663. rightclick:function(d){
  664. var o1 = $(this.rightdivobj),lx=d.lx;
  665. var tsaid = o1.attr('tsaid'),
  666. tsayp = o1.attr('tsaype');
  667. if(lx==0){
  668. this.rightdivobj.onclick();
  669. }
  670. if(lx==2){
  671. o1.remove();
  672. var tst=$('#historylist').text();if(tst=='')$('#historylist_tems').show();
  673. tst=$('#kefulistwait').text();if(tst=='')$('#kefulist_tems').show();
  674. js.ajax(this.getapiurl('reim','delhistory',tsayp),{type:tsayp,gid:tsaid},false,'get');
  675. if(tsayp=='gout' || tsayp=='uout')this.outgroup.dellist(tsayp, tsaid);
  676. this.showbadge('chat');
  677. }
  678. if(lx==1){
  679. var num = ''+tsayp+'_'+tsaid+'';
  680. $('#chat_stotal_'+num+'').html('');
  681. $('#wait_stotal_'+num+'').html('');
  682. var d=this.showhistorydata[num];
  683. if(d)d.stotal='0';
  684. this.showbadge('chat');
  685. this.biaoyd(tsayp,tsaid);
  686. }
  687. },
  688. openmyinfo:function(){
  689. this.showuserinfo(0,userarr[adminid]);
  690. },
  691. showuserinfo:function(oi, d1){
  692. var d = this.maindata.uarr[oi];
  693. if(d1)d=d1;
  694. if(d.email==null)d.email='';
  695. if(d.mobile==null)d.mobile='';
  696. if(d.tel==null)d.tel='';
  697. var num = 'userinfo_'+d.id+'';
  698. var s = '<div align="center"><div align="left" style="width:300px;margin-top:50px">';
  699. s+=' <div style="padding-left:70px"><img id="myfacess" onclick="$(this).imgview()" src="'+d.face+'" height="100" width="100" style="border-radius:50%;border:1px #eeeeee solid"></div>';
  700. if(d.id==adminid)s+='<div style="padding-left:90px"><a href="javascript:;" id="fupbgonet" onclick="reim.upfaceobj.click()" style="font-size:12px">修改头像</a></div>';
  701. s+=' <div style="line-height:30px;padding:10px;padding-left:20px;"><font color=#888888>姓名:</font>'+d.name+'<br><font color=#888888>部门:</font>'+d.deptallname+'<br><font color=#888888>职位:</font>'+d.ranking+'<br><font color=#888888>性别:</font>'+d.sex+'<br><font color=#888888>电话:</font>'+d.tel+'<br><font color=#888888>手机:</font>'+d.mobile+'<br><font color=#888888>邮箱:</font>'+d.email+'</div>';
  702. s+=' <div style="padding-top:10px;padding-left:50px"><input type="button" value="发消息" onclick="reim.openchat(\'user\',\''+d.id+'\',\''+d.name+'\',\''+d.face+'\')" class="btn">&nbsp; &nbsp; <input onclick="reim.closetabs(\''+num+'\')" type="button" value="关闭" class="btn btn-danger"></div>';
  703. s+='</div></div>';
  704. this.addtabs(num,s);
  705. if(d.id==adminid){
  706. if(!this.upfaceobj)this.upfaceobj=$.rockupload({
  707. inputfile:'upfacess',
  708. uptype:'image',
  709. urlparams:{noasyn:'yes'}, //不需要同步到文件平台上
  710. onsuccess:function(f,str){
  711. var a=js.decode(str);
  712. if(!a.id)return;
  713. reim.saveface(a.id);
  714. },
  715. onchange:function(){
  716. $('#fupbgonet').html('上传中...');
  717. }
  718. });
  719. }
  720. },
  721. saveface:function(fid){
  722. this.ajax(this.getapiurl('reim','changeface'),{id:fid},function(ret){
  723. var face = ret.data;
  724. get('myface').src=face;
  725. get('myfacess').src=face;
  726. adminface=face;
  727. js.setoption('loginface', face);
  728. js.setoption('adminface', face);
  729. $('#fupbgonet').html('修改成功');
  730. });
  731. },
  732. openchat:function(type,reid,na,fac){
  733. var num = ''+type+'_'+reid+'';
  734. $('#chat_stotal_'+num+'').html('');
  735. this.showbadge('chat');
  736. if(type=='agent'){
  737. var d = this.showhistorydata[num];
  738. var url='';
  739. if(d && d.stotal>0 && !isempt(d.xgurl)){
  740. d.stotal='0';
  741. var xga = d.xgurl.split('|');
  742. if(xga[1]>0)url='task.php?a=p&num='+xga[0]+'&mid='+xga[1]+'';
  743. }
  744. if(url==''){
  745. this.openagenh(reid);
  746. }else{
  747. this.biaoyd('agent',reid);
  748. js.open(url,760,500);
  749. }
  750. return;
  751. }
  752. if(type=='wait'){
  753. this.kefu.openwait(this.showhistorydata[num]);
  754. return;
  755. }
  756. var s = '<div>';
  757. s+='<div id="viewtitle_'+num+'" style="height:50px;overflow:hidden;border-bottom:#dddddd solid 1px;">';
  758. s+='</div>';
  759. var hei = 206;
  760. s+='<div resizeh="'+hei+'" id="viewcontent_'+num+'" style="height:'+(viewheight-hei)+'px;overflow:hidden;position:relative;"><div style="margin-top:50px" align="center"><img src="images/mloading.gif"></div></div>';
  761. s+='<div class="toolsliao" style="background:none" id="toolsliao_'+num+'">';
  762. s+=' <span title="表情" tools="emts" class="cursor"><i class="icon-heart"></i></span>';
  763. s+=' <span title="文件/图片" tools="file" class="cursor"><i class="icon-folder-close"></i></span>';
  764. if(nwjsgui){
  765. s+=' <span title="粘贴图片" tools="paste" class="cursor"><i class="icon-paste"></i></span>';
  766. s+=' <span title="截屏(Alt+A)" tools="crop" class="cursor"><i class="icon-cut"></i></span>';
  767. }
  768. if(video_bool && type=='user')s+=' <span title="音视频通话" tools="tonghua" class="cursor"><i class="icon-facetime-video"></i></span>';
  769. s+=' <span title="收藏消息" tools="star" class="cursor"><i class="icon-star"></i></span>';
  770. s+=' <span title="消息记录" tools="jilu" class="cursor"><i class="icon-time"></i></span>';
  771. if(type=='gout')s+=' <span title="@信呼客服" tools="atkf" class="cursor"><i class="icon-headphones"></i></span>';
  772. s+='</div>';
  773. s+='<div style="height:80px;overflow:hidden;"><div style="height:70px;margin:5px"><textarea onpaste="im.readclip(\''+num+'\',event)" class="content" style="background:none;" id="input_content_'+num+'"></textarea></div></div>';
  774. s+='<div style="height:40px;overflow:hidden;"><div align="right" style="padding:9px"><input id="chatclosebtn_'+num+'" class="webbtn" style="background:none;color:#aaaaaa" type="button" value="关闭(C)">&nbsp;<input class="webbtn" style="background:none;color:'+maincolor+'" id="chatsendbtn_'+num+'" type="button" value="发送(S)"></div></div>';
  775. s+='</div>';
  776. var bo = this.addtabs(num,s),sid='input_content_'+num+'';
  777. if(get(sid))get(sid).focus();
  778. if(!bo){
  779. this.chatobj[num]=new chatcreate({
  780. 'type' : type,
  781. 'gid' : reid,
  782. 'num' : num,
  783. 'name' : na,
  784. 'face' : fac
  785. });
  786. }
  787. this.chatobj[num].onshow();
  788. },
  789. biaoyd:function(type,gid){
  790. js.ajax(this.getapiurl('reim','yiduall',type),{type:type,gid:gid},false,'get');
  791. },
  792. receiveagenh:function(d){
  793. var gid = d.gid;
  794. var num = d.type+'_'+gid,stotal=0,msg;
  795. var so = $('#chat_stotal_'+num+'').html();
  796. if(!so)so=0;
  797. stotal = parseInt(so)+1;
  798. this.showhistorys({
  799. 'cont' : d.cont,
  800. 'name' : d.gname,
  801. 'title' : d.title,
  802. 'face' : d.gface,
  803. 'optdt' : d.optdt,
  804. 'type' : d.type,
  805. 'receid' : gid,
  806. 'stotal' : stotal
  807. }, true);
  808. msg = jm.base64decode(d.cont);
  809. msg = msg.replace(/\\n/gi,' ');
  810. var sopenfun=function(b){
  811. js.alertclose();
  812. notifyobj.close();//关闭右下角的提示
  813. if(b.url){
  814. js.open(b.url,760,500);
  815. return true;
  816. }else{
  817. reim.openagenh(b.gid, b.url);
  818. }
  819. return true; //不激活主窗口
  820. }
  821. js.alertclose();
  822. js.confirm(msg,function(jg){if(jg=='yes'){sopenfun(d)}},'','<img src="'+d.gface+'" align="absmiddle" width="20" height="20">&nbsp;'+d.title);
  823. if(this.getzhuom()){
  824. notifyobj.showpopup(msg,{icon:d.gface,url:d.url,gid:gid,title:d.title,rand:num,click:function(b){
  825. return sopenfun(b);
  826. }});
  827. }else{
  828. if(notifyobj.getsound())notifyobj.playsound();
  829. }
  830. nwjs.jumpicon();
  831. },
  832. receivechat:function(d){
  833. var gid = d.gid,lx = d.type,stotal=0,num,msg,name=d.gname,face=d.face,s1='';
  834. if(lx=='user'){
  835. gid = d.adminid;
  836. name= d.sendname;
  837. }
  838. if(lx=='group'){
  839. face = d.gface;
  840. s1 = jm.base64encode(''+d.sendname+':');
  841. if(isempt(face))face = 'images/group.png';
  842. }
  843. if(lx=='gout'){
  844. name = d.title;
  845. }
  846. num = d.type+'_'+gid;
  847. var showtx = true;
  848. if(this.isopentabs(num)){
  849. this.chatobj[num].receivedata(d);
  850. if(this.nowtabs!=num){
  851. this.chatobj[num].newbool=true;
  852. }
  853. }
  854. //if(windowfocus && this.nowtabs==num)showtx=false;
  855. if(windowfocus)showtx=false;
  856. if(d.nottixi)showtx=false;
  857. if(d.atid)showtx = (d.atid==d.zijiid)//不是@我就不要提醒
  858. //未读数
  859. if(this.nowtabs!=num){
  860. var so = $('#chat_stotal_'+num+'').html();
  861. if(!so)so=0;
  862. stotal = parseInt(so)+1;
  863. }
  864. if(d.ismysend)stotal = 0;
  865. if(lx != 'zixun')this.showhistorys({
  866. 'cont' : s1+d.cont,
  867. 'name' : name,
  868. 'face' : face,
  869. 'optdt' : d.optdt,
  870. 'type' : d.type,
  871. 'receid' : gid,
  872. 'stotal' : stotal
  873. }, true, this.nowtabs==num);
  874. if(d.ismysend)return;//自己发的
  875. var nr = jm.base64decode(d.cont);
  876. var title = '会话消息';
  877. msg = '人员['+d.sendname+'],发来一条信息';
  878. if(lx == 'group'){
  879. msg += ',来自['+name+']';
  880. }
  881. if(lx == 'gout'){
  882. title = name;
  883. msg = nr;
  884. }
  885. if(lx == 'zixun'){
  886. title = d.title;
  887. msg = nr;
  888. }
  889. var cans = {
  890. icon:face,sound:d.sound,type:lx,gid:gid,name:name,title:title,rand:num,
  891. click:function(b){if(b.gid)reim.openchat(b.type, b.gid,b.name,b.icon);}
  892. }
  893. if(showtx || nr.indexOf('@'+adminname+'')>-1){
  894. if(this.getzhuom()){
  895. notifyobj.showpopup(msg, cans);
  896. }else{
  897. if(notifyobj.getsound())notifyobj.playsound();
  898. }
  899. nwjs.jumpicon();
  900. showtx = true;
  901. }
  902. if(!showtx && windowfocus && this.nowtabs!=num){
  903. js.msg('success','<div id="idngmsg" class="cursor" align="left"><b>'+title+'</b><br>'+msg+'</div>');
  904. if(cans.gid)$('#idngmsg').click(function(){reim.openchat(cans.type, cans.gid,cans.name,cans.icon);});
  905. if(notifyobj.getsound())notifyobj.playsound();
  906. }
  907. },
  908. addtabs:function(num, s){
  909. var ids = 'tabs_'+num+'',bo;
  910. if(!get(ids)){
  911. var s = '<div tabs="'+num+'" id="'+ids+'">'+s+'</div>';
  912. $('#viewzhulist').append(s);
  913. bo = false;
  914. }else{
  915. bo = true;
  916. }
  917. this.showtabs(num);
  918. return bo;
  919. },
  920. closetabs:function(num){
  921. var ids = 'tabs_'+num+'';
  922. $('#'+ids+'').remove();
  923. var ood = $('#viewzhulist div[tabs]:last');
  924. var snu = ood.attr('tabs');
  925. this.showtabs(snu);
  926. },
  927. closenowtabs:function(){
  928. if(this.nowtabs)this.closetabs(this.nowtabs);
  929. },
  930. closenowtabss:function(){
  931. var nun = this.nowtabs;
  932. if(!nun)return;
  933. if(nun.indexOf('user_')==0 || nun.indexOf('group_')==0 || nun.indexOf('gout_')==0 || nun.indexOf('zixun_')==0 || nun.indexOf('userinfo_')==0)this.closenowtabs();
  934. },
  935. isopentabs:function(num){
  936. return get('tabs_'+num+'');
  937. },
  938. showtabs:function(num){
  939. $('div[tabs]').hide();
  940. var ids = 'tabs_'+num+'';
  941. $('#'+ids+'').show();
  942. $('div[temp]').removeClass('active');
  943. $('#history_'+num+'').addClass('active');
  944. this.nowtabs = num;
  945. },
  946. showagent:function(sbo){
  947. var agedt = this.maindata.aarr,s='',ty,a,len,d,d1,sno,so=0,sodd=1;
  948. s+='<div id="agenhview" resizeh="0" style="height:'+viewheight+'px;overflow:hidden;position:relative;" align="center"><div style="width:80%;padding:20px" align="left">';
  949. agenharr={};
  950. for(ty in agedt){
  951. a = agedt[ty];
  952. len = a.length;
  953. s+='<div style="color:#aaaaaa;padding-left:20px;margin-bottom:10px;padding:5px;border-bottom:'+sodd+'px solid #eeeeee">&nbsp;&nbsp;'+ty+'</div>';
  954. s+='<div class="agenhclsdiv">';
  955. for(i=0;i<len;i++){
  956. d1 = a[i];
  957. if(!agenharr[d1.id])agenharr[d1.id]=d1;
  958. d = agenharr[d1.id];
  959. sno = d.stotal;
  960. so += sno;
  961. if(sno==0)sno='';
  962. s+='<div onclick="reim.openagenh(\''+d.id+'\')" class="agenhcls"><div style="padding-top:5px"><img src="'+d.face+'"></div><div>'+d.name+'</div>';
  963. s+='<span id="agenh_stotal_'+d.id+'" class="badge">'+sno+'</span>';
  964. s+='</div>';
  965. }
  966. s+='</div>';
  967. sodd=1;
  968. }
  969. s+='</div>';
  970. if(!sbo){
  971. if(so==0)so='';
  972. $('#agenh_stotal').html(so);
  973. return;
  974. }
  975. var bo = this.addtabs('agenh',s);
  976. if(!bo)$('#agenhview').perfectScrollbar();
  977. this.showbadge('agenh');
  978. },
  979. hideagent:function(){
  980. if(get('tabs_agenh'))
  981. this.closetabs('agenh');
  982. },
  983. openagenh:function(id, url){
  984. var d = agenharr[id];
  985. if(!d){
  986. js.msg('msg','应用不存在,请刷新');
  987. return;
  988. }
  989. d.stotal=0;
  990. var num = 'agenh_'+d.id+'';
  991. $('#agenh_stotal_'+d.id+'').html('');
  992. this.showagent(false);
  993. $('#chat_stotal_'+num+'').html('');
  994. this.showbadge('chat');
  995. this.biaoyd('agent',d.id);
  996. var w = 1100,h=600,url = d.urlpc;
  997. if(isempt(url)){
  998. url = d.urlm;
  999. if(isempt(url)){
  1000. url = '?d=we&m=ying&num='+d.num+''; //先默认用移动端
  1001. }
  1002. w = 350;
  1003. }
  1004. var jg = (url.indexOf('?')>-1)?'&':'?';
  1005. url+=''+jg+'openfrom=reim';
  1006. //考勤打卡
  1007. if(d.num=='kqdaka'){
  1008. this.opendaka();return;
  1009. }
  1010. if(url.substr(0,4)=='http' && url.indexOf(HOST)<0 && nwjsgui){
  1011. nwjs.openurl(url);
  1012. }else{
  1013. js.open(url, w,h,'agent'+d.num+'');
  1014. }
  1015. },
  1016. //考勤打卡
  1017. opendaka:function(bo){
  1018. var url = '?d=reim&m=ying&a=daka',w = 550;h=300;
  1019. js.open(url, w,h,'agentkqdaka',{},{icon:'images/adddk.png'});
  1020. },
  1021. showbadge:function(lx){
  1022. var obj = $('span[id^="'+lx+'_stotal_"]'),so=0,s1,o,i;
  1023. for(i=0;i<obj.length;i++){
  1024. o = $(obj[i]);
  1025. s1= o.html();
  1026. if(!s1)s1='0';
  1027. so+=parseInt(s1);
  1028. }
  1029. if(so==0)so='';
  1030. $('#'+lx+'_stotal').html(so);
  1031. var zoi = 0;
  1032. so = $('#agenh_stotal').html();
  1033. if(!so)so = 0;
  1034. zoi+=parseInt(so);
  1035. so = $('#chat_stotal').html();
  1036. if(!so)so = 0;
  1037. zoi+=parseInt(so);
  1038. so = $('#wait_stotal').html();
  1039. if(!so)so = 0;
  1040. zoi+=parseInt(so);
  1041. nwjs.changeicon(zoi);
  1042. if(lx=='chat')this.showbadge('wait');
  1043. },
  1044. clickcog:function(o1){
  1045. if(!this.cogmenu)this.cogmenu =$.rockmenu({
  1046. data:[],
  1047. width:120,
  1048. itemsclick:function(d){
  1049. reim.clickcogclick(d);
  1050. }
  1051. });
  1052. var d = [{'name':'消息记录',lx:'jl'},{'name':'刷新',lx:'sx'},{'name':'创建会话',lx:'create'},{'name':'修改密码',lx:'pass'}];
  1053. if(companymode)d.push({'name':'切换单位',lx:'qhqy'});
  1054. if(nwjsgui)d.push({'name':'下载管理器',lx:'down'});
  1055. d.push({'name':'设置',lx:'cog'});
  1056. d.push({'name':'退出',lx:'exit'});
  1057. this.cogmenu.setData(d);
  1058. var off = $(o1).offset();
  1059. this.cogmenu.showAt(60,off.top+d.length*36);
  1060. },
  1061. openrecord:function(){
  1062. var url = '?homeurl=cmVpbSxyZWNvcmQsYXR5cGU9bXk:&homename=5oiR55qE5Lya6K!d6K6w5b2V&menuid=MjI3';
  1063. js.open(url,1000,550,'chatrecord');
  1064. },
  1065. clickcogclick:function(d){
  1066. var lx=d.lx;
  1067. if(lx=='sx'){
  1068. js.loading('刷新中...');
  1069. location.reload();
  1070. }
  1071. if(lx=='exit'){
  1072. this.exitlogin();
  1073. }
  1074. if(lx=='cog'){
  1075. this.cogshow();
  1076. }
  1077. if(lx=='jl'){
  1078. this.openrecord();
  1079. }
  1080. if(lx=='create'){
  1081. this.creategroup();
  1082. }
  1083. if(lx=='pass'){
  1084. this.editpass();
  1085. }
  1086. if(lx=='qhqy'){
  1087. this.changecom();
  1088. }
  1089. if(lx=='down')js.open('?d=reim&m=record&a=download', 630,450,'downs');
  1090. },
  1091. //创建会话
  1092. creategroup:function(){
  1093. js.prompt('创建会话','请输入会话名称:',function(lx,v){
  1094. if(lx=='yes'){
  1095. if(!v){js.msg('msg','没有输入会话名称');return false;}
  1096. js.msg('wait','创建中...');
  1097. reim.ajax(reim.getapiurl('reim','createlun'),{val:jm.base64encode(strreplace(v))}, function(da){
  1098. js.msg('success','创建成功,请打开会话窗口邀请人员加入');
  1099. reim.changetabs(1);
  1100. reim.initload(true);
  1101. });
  1102. }
  1103. });
  1104. return false;
  1105. },
  1106. editpass:function(bt,cse){
  1107. if(!bt)bt='修改密码';
  1108. if(!cse)cse='';
  1109. js.tanbody('winiframe',bt,350,300,{
  1110. html:'<div style="height:250px;overflow:hidden"><iframe src="" name="openinputiframe" width="100%" height="100%" frameborder="0"></iframe></div>',
  1111. bbar:'none',
  1112. closed:cse
  1113. });
  1114. openinputiframe.location.href='?m=index&d=we&a=editpass&hideheader=true&ofrom=reim';
  1115. },
  1116. changecom:function(){
  1117. js.tanbody('winiframe','切换单位',350,300,{
  1118. html:'<div style="height:250px;overflow:hidden"><iframe src="" name="openinputiframe" width="100%" height="100%" frameborder="0"></iframe></div>',
  1119. bbar:'none'
  1120. });
  1121. openinputiframe.location.href='?m=index&d=we&a=company&hideheader=true&ofrom=reim';
  1122. },
  1123. changecomok:function(){
  1124. js.tanclose('winiframe');
  1125. js.msgok('切换成功');
  1126. location.reload();
  1127. },
  1128. exitlogin:function(bo){
  1129. if(!bo){
  1130. js.confirm('确定要退出系统吗?',function(jg){
  1131. if(jg=='yes')reim.exitlogin(true);
  1132. });
  1133. return;
  1134. }
  1135. if(nwjsgui){
  1136. js.loading('退出中...');
  1137. js.ajax(this.getapiurl('login','loginexit'),{},function(ret){
  1138. js.setoption('autologin', '0');
  1139. js.location('?d=reim&a=login&a=xina');
  1140. });
  1141. }else{
  1142. window.close();
  1143. }
  1144. },
  1145. getsound:function(){
  1146. var lx = js.getoption('soundcog'),chs=false;
  1147. if(lx=='')lx='1';
  1148. if(lx==1)chs=true;
  1149. return chs;
  1150. },
  1151. setsound:function(o1){
  1152. var lx=(o1.checked)?'1':'2';
  1153. js.setoption('soundcog', lx);
  1154. notifyobj.setsound(o1.checked);
  1155. },
  1156. getzhuom:function(){
  1157. var lx = js.getoption('zhuomcog'),chs=false;
  1158. if(lx=='')lx='1';
  1159. if(lx==1)chs=true;
  1160. return chs;
  1161. },
  1162. setzhuom:function(o1){
  1163. var lx=(o1.checked)?'1':'2';
  1164. js.setoption('zhuomcog', lx);
  1165. },
  1166. setsendkkj:function(vs){
  1167. js.setoption('sendkuijie', vs);
  1168. },
  1169. changesound:function(o1){
  1170. var src = o1.value;
  1171. js.setoption('soundsrc', src);
  1172. notifyobj.sound = src;
  1173. notifyobj.playsound();
  1174. },
  1175. setchatlistw:function(kg){
  1176. $('#centlist').css('width',''+kg+'px');
  1177. js.setoption('setchatlistw', ''+kg+'');
  1178. },
  1179. cogshow:function(){
  1180. var chs= (this.getsound())?'checked':'';
  1181. var ch1= (this.getzhuom())?'checked':'';
  1182. var num = 'userinfo_cogshow';
  1183. var s = '<div align="center"><div align="left" style="width:300px;margin-top:50px">';
  1184. s+=' <div style="line-height:30px"><b>设置</b></div>';
  1185. s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid"><label><input '+ch1+' onclick="reim.setzhuom(this)" type="checkbox">新信息桌面提醒</label></div>';
  1186. s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid"><label><input '+chs+' onclick="reim.setsound(this)" type="checkbox">新信息声音提示</label></div>';
  1187. s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid">提示声音:<select onchange="reim.changesound(this)" id="changesoundid"><option value="web/res/sound/email.mp3">email.mp3</option><option value="web/res/sound/dong.mp3">dong.mp3</option><option value="web/res/sound/todo.ogg">todo.ogg</option><option value="web/res/sound/niu.mp3">niu.mp3</option><option value="web/res/sound/don1.mp3">don1.mp3</option></select></div>';
  1188. chs = 'checked';
  1189. ch1 = '';
  1190. if(js.getoption('sendkuijie')=='1'){
  1191. ch1='checked';chs='';
  1192. }
  1193. s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid">发送快捷键:<label><input onclick="reim.setsendkkj(0)" '+chs+' type="radio" name="sendkuijie">Enter</label>&nbsp; <label><input onclick="reim.setsendkkj(1)" '+ch1+' type="radio" name="sendkuijie">Ctrl+Enter</label></div>';
  1194. //s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid">列表列宽:<label><input onclick="reim.setchatlistw(220)" checked type="radio" name="chatlistw">正常</label>&nbsp; <label><input onclick="reim.setchatlistw(230)" type="radio" name="chatlistw">宽点</label>&nbsp; <label><input onclick="reim.setchatlistw(250)" type="radio" name="chatlistw">大宽</label></div>';
  1195. if(nwjsgui){
  1196. var ips = nwjs.getipmac();
  1197. s+='<div style="padding:10px 0px;border-top:1px #eeeeee solid">我局域网IP:'+ips.ip+'</div>';
  1198. s+='<div style="padding:10px 0px;border-top:1px #eeeeee solid">我的MAC地址:'+ips.mac+'</div>';
  1199. }
  1200. s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid">网络IP:'+this.myip+'</div>';
  1201. s+=' <div style="padding-top:10px;"><input onclick="reim.closetabs(\''+num+'\')" type="button" value="关闭" class="btn btn-danger"></div>';
  1202. s+='</div></div>';
  1203. this.addtabs(num,s);
  1204. get('changesoundid').value=notifyobj.sound;
  1205. },
  1206. //内部服务处理
  1207. serverdata:function(a){
  1208. var lx = a.atype;
  1209. if(lx=='focus')nwjs.winshow();
  1210. if(lx=='crop')this.cropScreen(true);
  1211. if(lx=='notify')this.shownotify(a);
  1212. if(lx=='openchat')this.openchat(a.id,a.type);
  1213. if(lx=='getlogin')return {uid:adminid,uname:adminname,face:adminface};
  1214. if(lx=='getipmac')return nwjs.getipmac();
  1215. if(lx=='office')nwjs.editoffice(a.paramsstr);
  1216. if(lx=='upfile')return nwjs.filetobase64(a.path);
  1217. if(lx=='gpath')return nwjs.getpath();
  1218. },
  1219. //语音视频通话
  1220. calltonghua:function(d){
  1221. var lx = d.calltype;
  1222. if(lx=='call'){
  1223. var channel = d.th_channel;
  1224. if(js.getoption('nowchannel')==channel)return;
  1225. js.setoption('nowchannel', channel);
  1226. var url =NOWURL+'?d=reim&m=tonghua&channel='+channel+'&id='+d.adminid+'';
  1227. js.open(url, 350,530,'',{},{resizable:false,'always_on_top':true});
  1228. }
  1229. }
  1230. };
  1231. function chatcreate(cans){
  1232. for(var i in cans)this[i]=cans[i];
  1233. strformat.emotspath='web/';
  1234. var me = this;
  1235. this._init = function(){
  1236. this.minid = 999999999;
  1237. this.dktype = false;
  1238. this.showoba = get('viewcontent_'+this.num+'');
  1239. this.showobj = $(this.showoba);
  1240. this.inputobj = $('#input_content_'+this.num+'');
  1241. this.sendbtn = $('#chatsendbtn_'+this.num+'');
  1242. this.listdata = {};
  1243. this.sendinfo = {name:adminname,face:adminface};
  1244. this.loadci = 0;
  1245. this.atid = 0;
  1246. this.uptypes = '*';
  1247. this.createid = 0;
  1248. this.upurl = '';
  1249. this.soulx = '';
  1250. this.soukey = '';
  1251. this.objstr = 'reim.chatobj[\''+this.num+'\']';
  1252. var nstr = js.getoption('receinfo_'+this.num+'');
  1253. if(nstr)this.setreceinfor(js.decode(nstr));
  1254. this.sendbtn.click(function(){
  1255. me.sendcont();
  1256. });
  1257. $('#chatclosebtn_'+this.num+'').click(function(){
  1258. me.closechat();
  1259. });
  1260. this.inputobj.keydown(function(e){
  1261. return me.onkeydown(e);
  1262. });
  1263. this.showtools();
  1264. this.showtitle();
  1265. this.loaddata();
  1266. if(get('tabs_'+this.num+''))get('tabs_'+this.num+'').addEventListener('drop', function(e) {
  1267. var files = e.dataTransfer;
  1268. me.filedrop(files);
  1269. }, false);
  1270. this.showobj.click(function(e){
  1271. me.clickbody(this,e);
  1272. });
  1273. this.showobj.scroll(function(){
  1274. me.onsscroll();
  1275. });
  1276. this.inputobj.contextmenu(function(e){
  1277. me.inputright(this,e);
  1278. return false;
  1279. });
  1280. };
  1281. this.showtools=function(){
  1282. if(this.dktype){
  1283. var s = '<span title="有图片消息" tools="sou0" class="cursor"><i class="icon-picture"></i></span>';
  1284. s+= ' <span title="有文件消息" tools="sou1" class="cursor"><i class="icon-folder-open-alt"></i></span>';
  1285. s+= ' <span title="所有消息" tools="sou2" class="cursor"><i class="icon-file-alt"></i></span>';
  1286. s+= ' <span title="消息搜索" tools="sou3" class="cursor"><i class="icon-search"></i></span>';
  1287. $('#toolsliao_'+this.num+'').html(s);
  1288. }
  1289. $('#toolsliao_'+this.num+'').find('span').click(function(e){
  1290. me.clicktools(this);
  1291. return false;
  1292. });
  1293. };
  1294. this.showtitle=function(){
  1295. var o = $('#viewtitle_'+this.num+''),s='';
  1296. var od = this.receinfo;
  1297. if(!od)od={deptid:'-2'};
  1298. s+='<table width="100%"><tr>';
  1299. s+='<td width="30" align="center"><div style="padding:0px 10px;padding-right:8px;height:30px;overflow:hidden"><img onclick="$.imgview({url:this.src})" style="border-radius:5px" src="'+this.face+'" height="30" width="30"></div></td>';
  1300. s+='<td height="50" width="100%">';
  1301. s+=' <div temp="usname_'+this.num+'"><b style="font-size:16px;">'+this.name+'</b>';
  1302. if((this.type=='group' || this.type=='gout') && this.usershu)s+='('+this.usershu+')';
  1303. if(od.subname)s+='<span style="color:'+maincolor+';font-size:10px">@'+od.subname+'</span>';
  1304. s+=reim.grouptype(od.deptid,this.type);
  1305. if(od.ranking)s+=' <span style="font-size:12px;color:#aaaaaa">('+od.ranking+')</span>';
  1306. if(this.type=='user')s+=reim.getonlinestr(this.gid);
  1307. s+=' </div>';
  1308. if(od.unitname)s+='<div style="font-size:12px;color:#aaaaaa">'+od.unitname+'</div>';
  1309. s+='</td>';
  1310. if(this.type=='group' || this.type=='gout'){
  1311. if(!od.deptid || od.deptid=='0' || od.deptid=='-1'){
  1312. if(this.type=='group')s+='<td title="邀请" id="yaoqingchat_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-plus"></i></div></td>';
  1313. s+='<td title="退出会话" id="tuichuchat_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-signout"></i></div></td>';
  1314. }
  1315. s+='<td title="会话里的人员" id="tuiuserlist_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-group"></i></div></td>';
  1316. }
  1317. if(this.type=='zixun'){
  1318. s+='<td title="转给其他客服" id="sharebtn_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-share-alt"></i></div></td>';
  1319. s+='<td title="加更多客服" id="addkfbtn_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-plus"></i></div></td>';
  1320. s+='<td title="咨询人员信息" id="zixunbtn_'+this.num+'" class="chattitbtn" nowrap><div style="width:30px"><i class="icon-user"></i></div></td>';
  1321. }
  1322. s+='</tr></table>';
  1323. o.html(s);
  1324. $('#yaoqingchat_'+this.num+'').click(function(){
  1325. me.yaoqing();
  1326. });
  1327. $('#tuichuchat_'+this.num+'').click(function(){
  1328. me.exitgroup();
  1329. });
  1330. $('#tuiuserlist_'+this.num+'').click(function(){
  1331. me.showhuilist();
  1332. });
  1333. $('#zixunbtn_'+this.num+'').click(function(){
  1334. reim.kefu.showuser(me.gid);
  1335. });
  1336. $('#sharebtn_'+this.num+'').click(function(){
  1337. reim.kefu.shareuser(me.gid,0);
  1338. });
  1339. $('#addkfbtn_'+this.num+'').click(function(){
  1340. reim.kefu.shareuser(me.gid,1);
  1341. });
  1342. };
  1343. this.getapiurl=function(m1,a1){
  1344. if(this.type=='zixun')m1='rockkefu';
  1345. if(this.type=='gout'){
  1346. return reim.outgroup.geturl(a1);
  1347. }else{
  1348. return reim.getapiurl(m1,a1);
  1349. }
  1350. };
  1351. this.recordsearch=function(lx){
  1352. this.soulx = lx;
  1353. this.minid = 999999999;
  1354. this.listdata = {};
  1355. js.loading('加载中...');
  1356. this.loadci = 0;
  1357. this.showobj.perfectScrollbar('destroy');
  1358. this.loaddata();
  1359. };
  1360. this.searchjilu=function(){
  1361. js.prompt('搜索消息','请输入搜索关键词',function(jg,txt){
  1362. if(jg=='yes'){
  1363. me.soukey = txt;
  1364. me.recordsearch(me.soulx);
  1365. }
  1366. }, this.soukey);
  1367. };
  1368. this.loaddata=function(o1, iref){
  1369. if(this.boolload)return;
  1370. var iref = (!iref)?false:true;
  1371. var minid= 0;
  1372. if(iref)minid=this.minid;
  1373. if(o1)$(o1).html('<img src="images/loadings.gif" height="14" width="15" align="absmiddle"> 加载中...');
  1374. this.boolload = true;
  1375. reim.ajax(this.getapiurl('reim','getrecord'),{type:this.type,gid:this.gid,minid:minid,loadci:this.loadci,laiyuan:'not',soulx:this.soulx,soukey:jm.base64encode(this.soukey)},function(ret){
  1376. js.unloading();
  1377. if(o1)$(o1).html('');
  1378. var da = ret.data;
  1379. me.showloaddata(da,iref);
  1380. });
  1381. };
  1382. this.setreceinfor=function(rece){
  1383. this.receinfo = rece;
  1384. this.usershu = this.receinfo.utotal;
  1385. this.createid = this.receinfo.createid;
  1386. this.face = this.receinfo.face;
  1387. this.name = this.receinfo.name;
  1388. js.setoption('receinfo_'+this.num+'', JSON.stringify(rece));
  1389. };
  1390. this.showloaddata=function(da,iref){
  1391. if(this.loadci==0){
  1392. this.showobj.html('');
  1393. this.sendinfo = da.sendinfo;
  1394. this.setreceinfor(da.receinfor);
  1395. this.showobj.perfectScrollbar();
  1396. if(this.sendinfo.uptypes)this.uptypes = this.sendinfo.uptypes;
  1397. if(this.sendinfo.uploadurl)this.upurl = this.sendinfo.uploadurl+'&laiyuan=web';
  1398. this.showtitle();
  1399. }
  1400. this.loadci++;
  1401. this.boolload = false;
  1402. this.loaddatashow(da, iref);
  1403. };
  1404. this.loaddatashow=function(ret,isbf, isls){
  1405. if(!get('viewcontent_'+this.num+''))return;
  1406. var a = ret.rows;
  1407. this.lastdt = ret.nowdt;
  1408. var i,len = a.length,cont,lex,nas,fase,nr,d,na=[],rnd,sid,frs,nfr1;
  1409. if(!isls)$('#loadmored_'+this.num+'').remove();
  1410. var seseid = -100;
  1411. if(isbf){
  1412. if(len>0)this.showobj.prepend('<div class="showblanks">---------↑以上是新加载---------</div>');
  1413. na = a;
  1414. }else{
  1415. for(i= len-1; i>=0; i--)na.push(a[i]);
  1416. }
  1417. var budnr = false;
  1418. if(isls && len>0 && !this.isscrollbottom()){
  1419. this.showdownjd()
  1420. budnr = true;
  1421. }
  1422. this.isshangla = false;
  1423. for(i= 0; i<len; i++){
  1424. d = na[i];
  1425. sid = parseFloat(d.id);
  1426. lex = 'right';
  1427. nas = this.sendinfo.name;
  1428. fase= this.sendinfo.face;
  1429. if(d.sendid!=this.sendinfo.id){
  1430. lex='left';
  1431. nas= d.sendname;
  1432. fase= d.face;
  1433. }
  1434. frs = d.filers;
  1435. if(frs && frs.fileid && js.isimg(frs.fileext)){
  1436. nfr1 = js.getoption('filesrc_'+frs.fileid+'');
  1437. if(nfr1)frs.thumbpath = nfr1;
  1438. }
  1439. nr = this.contshozt(frs);
  1440. if(nr=='')nr= jm.base64decode(d.cont);
  1441. rnd = 'mess_'+sid+'';
  1442. if(get('qipaocont_'+rnd+'') || this.listdata[rnd])continue;
  1443. cont= strformat.showqp(lex,nas,d.optdt,nr ,'', fase, rnd,d.bqname,d.bqcolor);
  1444. if(!isbf){
  1445. this.addcont(cont, isbf, budnr);
  1446. }else{
  1447. this.showobj.prepend(cont);
  1448. seseid+=$('#ltcont_'+rnd+'').height();
  1449. }
  1450. this.listdata[rnd]=d;
  1451. $('#qipaocont_'+rnd+'').contextmenu(function(e){
  1452. me.contright(this,e);
  1453. return false;
  1454. });
  1455. if(sid<this.minid)this.minid=sid;
  1456. }
  1457. if(len>0 && !isls){
  1458. var s = '<div class="showblanks" >';
  1459. if(ret.wdtotal==0){
  1460. s+='---------↑以上是历史记录---------';
  1461. if(ret.systotal>0){
  1462. this.showobj.prepend('<div id="loadmored_'+this.num+'" class="showblanks" ><a onclick="'+this.objstr+'.loadmoreda(this)"><i class="icon-time"></i> 还有'+ret.systotal+'条点我查看更多</a></div>');
  1463. this.isshangla = true;
  1464. }else{
  1465. this.showobj.prepend('<div id="loadmored_'+this.num+'" class="showblanks" >没有更多了</div>');
  1466. }
  1467. }else{
  1468. s+='---↑以上是历史,还有未读信息'+ret.wdtotal+'条,<a href="javascript:;" onclick="'+this.objstr+'.loaddata(this)">点击加载</a>---';
  1469. }
  1470. s+='</div>';
  1471. if(!isbf)this.addcont(s);
  1472. }
  1473. if(ret.showmsg)this.addmsg(ret.showmsg);
  1474. if(seseid>0)this.showobj.scrollTop(seseid);
  1475. };
  1476. this.isscrollbottom=function(){
  1477. var o1 = this.showoba;
  1478. var jg = o1.scrollHeight - o1.scrollTop - o1.offsetHeight;
  1479. this.bodyscrollTop = o1.scrollTop;
  1480. return jg<20;
  1481. };
  1482. this.showdownjd=function(){
  1483. var sid = 'downjd_'+this.num+'';
  1484. if(get(sid)){
  1485. $('#'+sid+'').show();
  1486. }else{
  1487. var str = '<div style="height:24px;width:24px;position:fixed;text-align:center;right:10px;bottom:160px;line-height:24px;background:'+maincolor+';color:white;border-radius:50%;z-index:10;font-size:12px;cursor:pointer" id="'+sid+'"><i class="icon-arrow-down"></i></div>';
  1488. this.showobj.prepend(str);
  1489. $('#'+sid+'').click(function(){me.scrollboot();});
  1490. }
  1491. };
  1492. //邀请
  1493. this.yaoqing=function(){
  1494. if(this.type!='group')return;
  1495. js.changeuser(false,'usercheck','邀请人到会话中', {
  1496. onselect:function(sna,sid){
  1497. if(!sid)return;
  1498. me.yaoqings(sid);
  1499. }
  1500. });
  1501. };
  1502. this.yaoqings=function(sid){
  1503. js.msg('wait','邀请中...');
  1504. reim.ajax(reim.getapiurl('reim','yaoqinguid'),{val:sid,gid:this.gid},function(da){
  1505. js.msg();
  1506. if(da.success){
  1507. js.msgok('邀请成功');
  1508. me.userlistarr=false;
  1509. me.getreceinfor();
  1510. }else{
  1511. js.msg('msg',da);
  1512. }
  1513. });
  1514. };
  1515. this.getreceinfor=function(){
  1516. reim.ajax(reim.getapiurl('reim','getreceinfor'),{type:this.type,gid:this.gid},function(ret){
  1517. me.receinfo = ret.data.receinfor;
  1518. me.usershu = me.receinfo.utotal;
  1519. me.showtitle();
  1520. });
  1521. };
  1522. this.exitgroup=function(){
  1523. if(this.type=='user')return;
  1524. js.confirm('确定要此退出会话吗?',function(lx){
  1525. if(lx=='yes'){
  1526. me.exitgroups();
  1527. }
  1528. });
  1529. };
  1530. this.showhuilist=function(){
  1531. var s = '<div id="showuserlist" style="height:250px;overflow:hidden;position:relative"><div align="center" style="padding:10px;"><img src="images/mloading.gif" align="absmiddle">&nbsp;加载人员...</div></div>';
  1532. js.tanbody('syscogshow','会话上人员('+this.usershu+')',480,100,{html:s});
  1533. if(!this.userlistarr){
  1534. reim.ajax(this.getapiurl('reim','getgroupuser'),{type:this.type,gid:this.gid},function(ret){
  1535. me.showusershow(ret.data.uarr);
  1536. },'get');
  1537. }else{
  1538. this.showusershow(this.userlistarr);
  1539. }
  1540. };
  1541. this.showusershow=function(a){
  1542. this.userlistarr = a;
  1543. var sad = this.showtableda(a);
  1544. $('#showuserlist').html(sad[0]);
  1545. $('#showuserlist').perfectScrollbar();
  1546. $('#msgview_syscogshow').html('<span style="font-size:12px;color:#888888">右键人名可以@TA,'+sad[1]+'人在线</span>');
  1547. $('#showuserlist').find('div[xuh]').contextmenu(function(e){
  1548. me.atright(this,e);
  1549. return false;
  1550. });
  1551. };
  1552. this.showtableda=function(a){
  1553. var i,len=a.length,s='',oi=0,s1='',zx=0,d1;
  1554. s+='<table width="100%"><tr>';
  1555. for(i=0;i<len;i++){
  1556. oi++;
  1557. s1='';
  1558. if(a[i].online==1 && this.type=='gout'){
  1559. s1='<font title="PC端在线" class="zhu" style="font-size:10px;margin-left:5px"><i class="icon-desktop"></i></font>';
  1560. zx++;
  1561. }
  1562. if(this.type=='group'){
  1563. s1=reim.getonlinestr(a[i].id);
  1564. d1=reim.nowonlinearr;
  1565. if(d1 && d1.reim==1)zx++;
  1566. }
  1567. s+='<td width="20%"><div style="padding:5px" align="center"><div><img style="height:34px;width:34px;border-radius:50%" onclick="$.imgview({url:this.src})" src="'+a[i].face+'"></div><div xuh="'+i+'" style="color:#888888">'+a[i].name+''+s1+'</div></div></td>';
  1568. if(oi%5==0)s+='</tr><tr>';
  1569. }
  1570. if(len<5)for(i=0;i<5-len;i++)s+='<td width="20%"></td>';
  1571. s+='</tr></table>';
  1572. return [s, zx];
  1573. };
  1574. this.atright=function(o1){
  1575. var xu = parseFloat($(o1).attr('xuh'));
  1576. var d1 = this.userlistarr[xu];
  1577. this.atid = d1.id;
  1578. this.addinput('@'+d1.name+' ');
  1579. };
  1580. this.clickbody=function(o,e){
  1581. if(e.target.nodeName=='FONT'){
  1582. var o1 = $(e.target);
  1583. var atid = o1.attr('atid'),nst;
  1584. if(atid){
  1585. this.atid = atid;
  1586. this.addinput(''+o1.text()+' ');
  1587. }
  1588. }
  1589. if(this.rightqipaoobj)this.rightqipaoobj.hide();
  1590. };
  1591. this.kefuat=function(){
  1592. this.atid = 2;
  1593. this.addinput('@信呼客服 ');
  1594. };
  1595. this.exitgroups=function(){
  1596. js.msg('wait','退出中...');
  1597. reim.ajax(this.getapiurl('reim','exitgroup'),{gid:this.gid,aid:this.sendinfo.id}, function(da){
  1598. js.msgok('成功退出此会话,无法在此会话发消息了');
  1599. });
  1600. };
  1601. this.contshozt=function(d){
  1602. return strformat.contshozt(d,'web/');
  1603. };
  1604. this.addmsg=function(msg){
  1605. this.addcont('<div class="showblanks" >'+msg+'</div>');
  1606. };
  1607. this.addcont=function(cont, isbf, isb1){
  1608. var o = this.showobj;
  1609. if(cont){if(isbf){o.prepend(cont);}else{o.append(cont);}}
  1610. clearTimeout(this.scrolltime);
  1611. this.scrolltime = setTimeout(function(){
  1612. if(!isb1)me.scrollboot();
  1613. }, 50);
  1614. };
  1615. //滚动条到最下面
  1616. this.scrollboot=function(){
  1617. var sid = 'viewcontent_'+this.num+'';
  1618. if(get(sid))this.showobj.animate({scrollTop:get(sid).scrollHeight},100);
  1619. sid = 'downjd_'+this.num+'';
  1620. if(get(sid))$('#'+sid+'').hide();
  1621. };
  1622. this.onsscroll=function(){
  1623. clearTimeout(this.onsscrolltime);
  1624. this.onsscrolltime = setTimeout(function(){me.onsscrolls();}, 200);
  1625. };
  1626. this.onsscrolls=function(){
  1627. var sid = 'downjd_'+this.num+'';
  1628. if(this.isscrollbottom() && get(sid)){
  1629. $('#'+sid+'').hide();
  1630. }
  1631. };
  1632. this.loadmoreda=function(o1){
  1633. this.loaddata(o1, true);
  1634. };
  1635. this.sendcont=function(ssnr){
  1636. if(this.sendbool)return;
  1637. js.msg('none');
  1638. var o = this.inputobj;
  1639. var nr = strformat.sendinstr(o.val());
  1640. nr = nr.replace(/</gi,'&lt;').replace(/>/gi,'&gt;').replace(/\n/gi,'<br>');
  1641. if(ssnr)nr=ssnr;
  1642. if(isempt(nr))return false;
  1643. if(nr.indexOf('@')<0)this.atid=0;
  1644. var conss = jm.base64encode(nr);
  1645. if(conss.length>3998){
  1646. js.msg('msg','发送内容太多了');
  1647. return;
  1648. }
  1649. var nuid= js.now('time'),optdt = js.serverdt();
  1650. if(optdt==this.nowoptdt){
  1651. js.msg('msg','消息发太快了');
  1652. return;
  1653. }
  1654. this.nowoptdt = optdt;
  1655. var cont= strformat.showqp('right',this.sendinfo.name,optdt, nr, nuid, this.sendinfo.face, nuid, this.sendinfo.bqname, this.sendinfo.bqcolor);
  1656. this.addcont(cont);
  1657. o.val('').focus();
  1658. this.sendconts(conss, nuid, optdt, 0);
  1659. return false;
  1660. };
  1661. //收到推送消息来了
  1662. this.receivedata=function(d){
  1663. var minid=this.minid;
  1664. reim.ajax(this.getapiurl('reim','getrecord'),{type:this.type,gid:this.gid,minid:0,lastdt:this.lastdt,loadci:this.loadci},function(ret){
  1665. me.loaddatashow(ret.data, false, true);
  1666. });
  1667. };
  1668. this.onshow=function(){
  1669. if(this.newbool){
  1670. this.scrollboot();
  1671. }
  1672. this.newbool = false;
  1673. };
  1674. this.onkeydown=function(e){
  1675. var code = e.keyCode,kj = js.getoption('sendkuijie');
  1676. if(code==13 && e.shiftKey){
  1677. this.addinput('\n')
  1678. return false;
  1679. }
  1680. if(code==13 && !e.ctrlKey && kj!='1'){
  1681. this.sendcont();
  1682. return false;
  1683. }
  1684. if(e.altKey && code==83){
  1685. this.sendcont();
  1686. return false;
  1687. }
  1688. if(e.altKey && code==67){
  1689. this.closechat();
  1690. return false;
  1691. }
  1692. if(e.ctrlKey && code==13){
  1693. if(kj=='1'){this.sendcont();}else{this.addinput('\n');}
  1694. return false;
  1695. }
  1696. return true;
  1697. };
  1698. this.sendconts=function(conss, nuid, optdt, fid){
  1699. this.sendbool = true;
  1700. var d = {cont:conss,gid:this.gid,type:this.type,nuid:nuid,optdt:optdt,fileid:fid,atid:''+this.atid+''};
  1701. this.atid= 0;
  1702. reim.ajax(this.getapiurl('reim','sendinfor'),d,function(ret){
  1703. me.sendsuccess(ret.data,nuid, d);
  1704. },'post',function(){
  1705. me.senderror(nuid, d);
  1706. });
  1707. var s1='';
  1708. if(this.type=='group' || this.type=='gout')s1=jm.base64encode(''+this.sendinfo.name+':');
  1709. //显示到会话里
  1710. reim.showhistorys({
  1711. 'cont' : s1+d.cont,
  1712. 'name' : this.receinfo.name,
  1713. 'subname' : this.receinfo.subname,
  1714. 'face' : this.receinfo.face,
  1715. 'optdt' : d.optdt,
  1716. 'type' : this.type,
  1717. 'receid' : this.gid,
  1718. 'stotal' : 0
  1719. }, true, true);
  1720. if(this.type=='zixun')reim.kefu.showonline(this.type,this.gid);
  1721. };
  1722. this.senderror=function(nuid, ds){
  1723. get(nuid).src='images/error.png';
  1724. get(nuid).title='发送失败';
  1725. if(ds)get(nuid).onclick=function(){
  1726. js.confirm('是否要重新发送?', function(jg){
  1727. if(jg=='yes'){
  1728. get(nuid).src='images/loadings.gif';
  1729. get(nuid).title='发送中...';
  1730. me.atid = ds.atid;
  1731. me.sendconts(ds.cont,ds.nuid,ds.optdt,ds.fileid);
  1732. }
  1733. });
  1734. }
  1735. this.sendbool=false;
  1736. };
  1737. this.sendsuccess=function(d,nuid,sd){
  1738. this.sendbool = false;
  1739. if(!d.id){
  1740. this.senderror(nuid,sd);
  1741. return;
  1742. }
  1743. $('#'+d.nuid+'').remove();
  1744. var bo = false;
  1745. d.messid=d.id;
  1746. d.face = this.sendinfo.face;
  1747. if(d.showmsg)this.addmsg(d.showmsg);
  1748. if(this.type=='group')d.gface=this.receinfo.face;
  1749. if(d.fileid)d.filers = this.nowfilers;
  1750. this.listdata[nuid]=d;
  1751. this.listdata['mess_'+d.id+'']=d;
  1752. //添加右键事件
  1753. $('#qipaocont_'+nuid+'').contextmenu(function(e){
  1754. me.contright(this,e);
  1755. return false;
  1756. });
  1757. reim.serversend(d);
  1758. };
  1759. this.addinput=function(s){
  1760. var val = this.inputobj.val()+s;
  1761. this.inputobj.val(val).focus();
  1762. };
  1763. this.closechat=function(){
  1764. if(this.sendbool)return;
  1765. reim.chatobj[this.num]=false;
  1766. reim.closetabs(this.num);
  1767. };
  1768. this.clicktools=function(o1){
  1769. var o = $(o1);
  1770. var lx = o.attr('tools');
  1771. if(lx=='emts')this.getemts(o);
  1772. if(lx=='file')this.sendfile(o);
  1773. if(lx=='paste')this.pasteimg();
  1774. if(lx=='crop')this.cropScreen();
  1775. if(lx=='tonghua')this.opentonghua();
  1776. if(lx=='jilu')this.openjilu();
  1777. if(lx=='sou0' || lx=='sou1' || lx=='sou2')this.recordsearch(lx);
  1778. if(lx=='sou3')this.searchjilu();
  1779. if(lx=='star')this.showstar();
  1780. if(lx=='atkf')this.kefuat();
  1781. };
  1782. this.getemts=function(o){
  1783. if(!get('aemtsdiv')){
  1784. var s = '<div id="aemtsdiv" style="width:400px;height:200px;overflow:hidden;border:1px #cccccc solid;background:white;box-shadow:0px 0px 5px rgba(0,0,0,0.3);left:3px;top:5px;position:absolute;display:none;z-index:6">';
  1785. s+='<div style="padding:5px">';
  1786. s+=this.getemtsbq('qq',0, 104, 11, 24);
  1787. s+='</div>';
  1788. s+='</div>';
  1789. $('body').append(s);
  1790. js.addbody('emts','hide','aemtsdiv');
  1791. $('#aemtsdiv').perfectScrollbar();
  1792. }
  1793. var o1 = $('#aemtsdiv');
  1794. o1.toggle();
  1795. var off = o.offset();
  1796. o1.css({'top':''+(off.top-205)+'px','left':''+(off.left)+'px'});
  1797. };
  1798. this.opentonghua=function(){
  1799. var url =NOWURL+'?d=reim&m=tonghua&id='+this.gid+'';
  1800. js.open(url, 350,530,'tonghuacall',{},{resizable:false,'always_on_top':true});
  1801. };
  1802. this.openjilu=function(){
  1803. var win = js.open(NOWURL+'?d=reim&m=record&a=history&type='+this.type+'&gid='+this.gid+'',850,550,'recorda');
  1804. if(win)js.openrun('recorda','reshow', this.type, this.gid);
  1805. };
  1806. this.getemtsbq=function(wj, oi1,oi2, fzd, dx){
  1807. var i,oi=0,j1 = js.float(100/fzd);
  1808. var s = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
  1809. for(i=oi1; i<=oi2; i++){
  1810. oi++;
  1811. s+='<td width="'+j1+'%" title="'+strformat.emotsarr[i+1]+'" align="center"><img onclick="im.backemts(\''+strformat.emotsarr[i+1]+'\')" src="web/images/im/emots/'+wj+'/'+i+'.gif" width="'+dx+'" height="'+dx+'"></td>';
  1812. if(oi % fzd==0)s+='</tr><tr>';
  1813. }
  1814. s+='</tr></table>';
  1815. return s;
  1816. };
  1817. this.sendfile=function(bo){
  1818. uploadobj.nownum = this.num;
  1819. uploadobj.setuptype(this.uptypes);
  1820. uploadobj.setupurl(this.upurl);
  1821. uploadobj.click();
  1822. };
  1823. this.sendfileshow=function(f){
  1824. f.face = this.sendinfo.face;
  1825. f.bqname= this.sendinfo.bqname;
  1826. f.sendname= this.sendinfo.name;
  1827. f.bqcolor= this.sendinfo.bqcolor;
  1828. var fa = strformat.showupfile(f);
  1829. var cont= fa.cont;
  1830. this.upfilearr = fa;
  1831. this.addcont(cont);
  1832. };
  1833. this.sendfileok=function(f,str){
  1834. var a=js.decode(str);
  1835. if(!a.id){
  1836. js.msg('msg', str);
  1837. this.senderrornss();
  1838. return;
  1839. }
  1840. var tm= this.upfilearr,conss='';
  1841. if(this.type=='gout')a.fileid = a.filenum;
  1842. f = a;
  1843. strformat.upsuccess(a);
  1844. if(js.isimg(f.fileext)){
  1845. conss = '[图片 '+f.filesizecn+']';
  1846. }else{
  1847. conss = '['+f.filename+' '+f.filesizecn+']'
  1848. }
  1849. this.nowfilers = a;
  1850. this.sendconts(jm.base64encode(conss), tm.nuid, tm.optdt, a.id);
  1851. };
  1852. this.senderrornss=function(){
  1853. this.senderror(this.upfilearr.nuid);
  1854. };
  1855. this.readclip=function(evt){
  1856. var clipboardData = evt.clipboardData;
  1857. if(!clipboardData)return;
  1858. for(var i=0; i<clipboardData.items.length; i++){
  1859. var item = clipboardData.items[i];
  1860. if(item.kind=='file'&&item.type.match(/^image\//i)){
  1861. var blob = item.getAsFile(),reader = new FileReader();
  1862. reader.onload=function(){
  1863. var cont=this.result;
  1864. me.readclipshow(cont);
  1865. }
  1866. reader.readAsDataURL(blob);
  1867. }
  1868. }
  1869. };
  1870. this.readclipshow=function(snr){
  1871. var f={face:this.sendinfo.face}
  1872. f.bqname= this.sendinfo.bqname;
  1873. f.bqcolor= this.sendinfo.bqcolor;
  1874. f.sendname= this.sendinfo.name;
  1875. var fa = strformat.showupfile(f, snr);
  1876. var cont= fa.cont;
  1877. this._sssnuid = fa.nuid;
  1878. this._sssoptdt = fa.optdt;
  1879. this.upfilearr = fa;
  1880. this.addcont(cont);
  1881. };
  1882. this.sendbase64 = function(strnr){
  1883. uploadobj.nownum = this.num;
  1884. uploadobj.setuptype(this.uptypes);
  1885. uploadobj.setupurl(this.upurl);
  1886. uploadobj.sendbase64(strnr);
  1887. };
  1888. this.clipobj = function(){
  1889. if(!this.clipobj1)this.clipobj1 = nw.Clipboard.get();
  1890. return this.clipobj1;
  1891. };
  1892. this.pasteimg=function(){
  1893. var snr = this.clipobj().get('png');
  1894. //console.log(this.clipobj().readAvailableTypes());
  1895. if(!snr){
  1896. //js.msgerror('剪切板上没有图片');
  1897. return;
  1898. }
  1899. this.readclipshow(snr);
  1900. };
  1901. this.cropScreen=function(){
  1902. this.clipobj().clear();
  1903. jietubool = true;
  1904. im.cropScreen();
  1905. };
  1906. this.filedrop=function(o1){
  1907. uploadobj.nownum = this.num;
  1908. uploadobj.setuptype(this.uptypes);
  1909. uploadobj.setupurl(this.upurl);
  1910. uploadobj.change(o1, 0);
  1911. };
  1912. this.inputright=function(o,e){
  1913. if(!this.inputrightobj)this.inputrightobj=$.rockmenu({
  1914. data:[],width:100,itemsclick:function(d){me.inputrightclick(d);}
  1915. });
  1916. this.selectionStart = o.selectionStart;
  1917. this.selectionEnd = o.selectionEnd;
  1918. var sel = o.value.substr(o.selectionStart,o.selectionEnd-o.selectionStart);
  1919. this.selectValue = sel;
  1920. var d = [];
  1921. d.push({name:'复制',lx:1});
  1922. d.push({name:'剪切',lx:2});
  1923. if(nwjsgui){d.push({'name':'粘贴',lx:0});d.push({'name':'粘贴图片',lx:5});}
  1924. d.push({name:'清空',lx:4});
  1925. if(!sel){
  1926. d[0].name='<font color=#aaaaaa>'+d[0].name+'</font>';d[0].lx = 3;
  1927. d[1].name='<font color=#aaaaaa>'+d[1].name+'</font>';d[1].lx = 3;
  1928. }
  1929. this.inputrightobj.setData(d);
  1930. this.inputrightobj.showAt(e.clientX,e.clientY);
  1931. };
  1932. this.inputrightclick=function(d){
  1933. if(d.lx==0){
  1934. var snr = this.clipobj().get('text'),nr = this.inputobj.val();
  1935. if(snr){
  1936. var s1 = nr.substr(0,this.selectionStart)+snr+nr.substr(this.selectionEnd);
  1937. this.inputobj.val(s1).focus();
  1938. }
  1939. }
  1940. if(d.lx==1){
  1941. js.setcopy(this.selectValue,true);
  1942. }
  1943. if(d.lx==2){
  1944. js.setcopy(this.selectValue,true);
  1945. var nr = this.inputobj.val();
  1946. var s1 = nr.substr(0,this.selectionStart)+nr.substr(this.selectionEnd);
  1947. this.inputobj.val(s1).focus();
  1948. }
  1949. if(d.lx==4)this.inputobj.val('').focus();
  1950. if(d.lx==5)this.pasteimg();
  1951. };
  1952. this.contright=function(o1,e){
  1953. var o=$(o1),rnd=o.attr('rand');
  1954. this.rightqipao(o1,e,rnd);
  1955. };
  1956. this.rightqipao=function(o1,e,rnd){
  1957. if(!this.rightqipaoobj)this.rightqipaoobj=$.rockmenu({
  1958. data:[],width:130,itemsclick:function(d){me.rightqipaoclick(d);}
  1959. });
  1960. this.randmess = rnd;
  1961. this.rightdata= this.listdata[rnd];
  1962. this.chuihuinr= 'PGRlbCBzdHlsZT0iY29sb3I6Z3JheSI!5bey5pKk5ZuePC9kZWw!';
  1963. var d=[{name:'复制此消息',lx:0},{name:'删除',lx:1}];
  1964. if(this.rightdata.cont!=this.chuihuinr)d.push({name:'收藏',lx:5});
  1965. if(!this.dktype){
  1966. if(this.type=='group' || this.type=='gout')d.push({name:'@TA',lx:3});
  1967. var chehui = reim.showconfigarr.chehui,isch=false;
  1968. if(this.type=='gout')chehui = 120;
  1969. if(o1.className.indexOf('right')>0 && chehui>0){
  1970. var t1 = js.now('time', this.rightdata.optdt),t2 = js.now('time');
  1971. var t3 = (t2-t1)*0.001;
  1972. if(t3<chehui)isch = true;
  1973. }
  1974. if(this.sendinfo.id==this.createid)isch = true; //创建者
  1975. if(this.rightdata.cont==this.chuihuinr)isch=false;
  1976. if(isch)d.push({name:'撤回',lx:2});
  1977. }
  1978. if(this.type!='gout' && this.rightdata.sendid==adminid)d.push({name:'已读未读情况',lx:6});
  1979. this.rightqipaoobj.setData(d);
  1980. this.rightqipaoobj.showAt(e.clientX,e.clientY);
  1981. };
  1982. this.rightqipaoclick=function(d){
  1983. var lx=d.lx;
  1984. var ids = this.rightdata.id;
  1985. if(lx==0){
  1986. var cont = $('#qipaocont_'+this.randmess+'').text();
  1987. if(cont)js.setcopy(cont);
  1988. }
  1989. if(lx==1){
  1990. $('#ltcont_'+this.randmess+'').remove();
  1991. if(!isNaN(ids)){
  1992. reim.ajax(this.getapiurl('reim','clearrecord'),{type:this.type,gid:this.gid,ids:ids});
  1993. }
  1994. }
  1995. if(lx==3){
  1996. var cont = $('#ltname_'+this.randmess+'').text();
  1997. if(this.rightdata.sendname)cont = this.rightdata.sendname;
  1998. if(cont){
  1999. this.atid = this.rightdata.sendid;
  2000. this.addinput('@'+cont+' ');
  2001. }
  2002. }
  2003. if(lx==2 && !isNaN(ids)){
  2004. var o1dd = $('#qipaocont_'+this.randmess+'')
  2005. o1dd.html(js.getmsg('撤回中...'));
  2006. reim.ajax(this.getapiurl('reim','chehuimess'),{type:this.type,gid:this.gid,ids:ids}, function(ret){
  2007. me.listdata[me.randmess].ocont = me.listdata[me.randmess].cont;
  2008. me.listdata[me.randmess].cont = 'PGRlbCBzdHlsZT0iY29sb3I6Z3JheSI!5bey5pKk5ZuePC9kZWw!';
  2009. o1dd.html(js.getmsg(ret.data.msg1,'green')+' <a onclick="'+me.objstr+'.rebianji(this,\''+me.randmess+'\')" href="javascript:;">重新编辑</a>');
  2010. },'get', function(){
  2011. o1dd.html(js.getmsg('撤回失败','red'));
  2012. });
  2013. };
  2014. if(lx==5)this.staradd(this.rightdata);
  2015. if(lx==6)this.showhuizhi();
  2016. };
  2017. this.rebianji=function(o1,rnd){
  2018. var d = this.listdata[rnd],
  2019. nstr = jm.base64decode(d.ocont);
  2020. $('body').append('<div id="addcstre" style="display:none">'+nstr+'</div>');
  2021. this.inputobj.val($('#addcstre').text());
  2022. $('#addcstre').remove();
  2023. };
  2024. this.showhuizhi=function(){
  2025. var s = '<div id="showstarlistdss" class="qipao" style="height:250px;overflow:hidden;position:relative"><div align="center" style="padding:10px;"><img src="images/mloading.gif" align="absmiddle">&nbsp;加载...</div></div>';
  2026. js.tanbody('xiaoxirece','消息已读未读情况',480,100,{html:s});
  2027. reim.ajax(reim.getapiurl('reim','getxqkkd'),{id:this.rightdata.id},function(ret){
  2028. me.showhuizhishow(ret.data);
  2029. },'get');
  2030. };
  2031. this.showhuizhishow=function(ret){
  2032. var str = '';
  2033. var d = ret.wdarr;
  2034. if(d.length>0){
  2035. str+='<div style="padding:5px 10px;border-bottom:1px solid #eeeeee;font-size:12px;color:gray">未读'+d.length+'人</div>';
  2036. var sad = this.showtableda(d);
  2037. str+=sad[0];
  2038. }
  2039. d = ret.ydarr;
  2040. if(d.length>0){
  2041. str+='<div style="padding:5px 10px;border-bottom:1px solid #eeeeee;font-size:12px;color:gray">已读'+d.length+'人</div>';
  2042. var sad = this.showtableda(d);
  2043. str+=sad[0];
  2044. }
  2045. $('#showstarlistdss').html(str);
  2046. $('#showstarlistdss').perfectScrollbar();
  2047. }
  2048. //以下是收藏使用的
  2049. this.showstar=function(){
  2050. var s = '<div id="showstarlist" class="qipao" style="height:300px;overflow:hidden;position:relative"><div align="center" style="padding:10px;"><img src="images/mloading.gif" align="absmiddle">&nbsp;加载...</div></div>';
  2051. js.tanbody('sysshowstar','收藏的消息',370,100,{html:s,btn:[{text:'管理'}]});
  2052. if(!reim.starlistarr){
  2053. this.showstarshu();
  2054. }else{
  2055. this.showstarshow(reim.starlistarr);
  2056. }
  2057. };
  2058. this.showstarshu=function(o1){
  2059. if(o1)o1.innerHTML=js.getmsg('刷新中...');
  2060. reim.ajax(reim.getapiurl('reim','getstar'),{},function(ret){
  2061. me.showstarshow(ret.data);
  2062. },'get');
  2063. };
  2064. this.showstarshow=function(a){
  2065. reim.starlistarr = a;
  2066. var i,len=a.length,s='',oi=0,s1='',s2='',zx=0,d1;
  2067. s+='';
  2068. for(i=0;i<len;i++){
  2069. if(!a[i])continue;
  2070. oi++;
  2071. d1= js.decode(jm.base64decode(a[i].value));
  2072. s1= jm.base64decode(d1.cont);
  2073. if(d1.fileid>0){
  2074. if(this.type=='gout' || this.type=='uout'){
  2075. if(d1.type=='user' || d1.type=='group')continue;
  2076. }
  2077. if(this.type=='user' || this.type=='group'){
  2078. if(d1.type=='gout' || d1.type=='uout')continue;
  2079. }
  2080. if(this.type=='zixun' || d1.type=='zixun'){
  2081. if(d1.type != this.type)continue;
  2082. }
  2083. }
  2084. if(d1.imgurl){
  2085. s2+='<div onclick="'+this.objstr+'.clickstar('+i+',this)" class="lists" style="padding:10px;float:left"><img src="'+d1.imgurl+'" fileid="'+d1.fileid+'" type="'+d1.type+'" style="width:50px;height:50px"></div>';
  2086. continue;
  2087. }
  2088. if(d1.filename){
  2089. if(d1.filenum)d1.fileid = d1.filenum;
  2090. s1=strformat.contshozt(d1);
  2091. }
  2092. s+='<div class="lists" onclick="'+this.objstr+'.clickstar('+i+',this,event)" style="border-bottom-width:1px">';
  2093. s+='<div>'+s1+'</div>';
  2094. s+='</div>';
  2095. }
  2096. s+='';
  2097. if(s2)s2='<div style="display:inline-block;border-bottom:1px #eeeeee solid;width:100%">'+s2+'</div>';
  2098. $('#showstarlist').html(s2+s);
  2099. $('#showstarlist').perfectScrollbar();
  2100. $('#msgview_sysshowstar').html('<a onclick="'+this.objstr+'.showstarshu(this)" href="javascript:;">刷新</a>');
  2101. this.starisguan = false;
  2102. $('#sysshowstar_btn0').click(function(){
  2103. if(!me.starisguan){
  2104. me.starisguan = true;
  2105. $(this).html('退出管理');
  2106. }else{
  2107. me.starisguan = false;
  2108. $(this).html('管理');
  2109. }
  2110. });
  2111. };
  2112. this.clickstar=function(i,o1,e1){
  2113. if(e1 && e1.target.nodeName=='A')return;
  2114. var d1 = reim.starlistarr[i];
  2115. var d = js.decode(jm.base64decode(d1.value));
  2116. if(!this.starisguan){
  2117. if(d.fileid==0){
  2118. var nr = jm.base64decode(d.cont);
  2119. $('body').append('<div id="addcstre" style="display:none">'+nr+'</div>');
  2120. this.addinput($('#addcstre').text());
  2121. $('#addcstre').remove();
  2122. }else{
  2123. var str = '确定要发送“'+d.filename+'('+d.filesizecn+')”文件吗?';
  2124. if(d.imgurl)str='<img src="'+d.imgurl+'" onclick="strformat.clickimg(this)" width="50px" height="50px"> 点确定发送。';
  2125. js.confirm(str, function(jg){
  2126. if(jg=='yes'){
  2127. var sf = {
  2128. fileext:d.fileext,
  2129. filename:d.filename,
  2130. filesizecn:d.filesizecn,
  2131. id:d.fileid,
  2132. filenum:d.filenum
  2133. }
  2134. if(d.imgurl){
  2135. sf.filename = '图片';
  2136. sf.isimg = true;
  2137. sf.imgviewurl = d.imgurl;
  2138. sf.thumbpath = d.imgurl;
  2139. }
  2140. me.sendfileshow(sf);
  2141. me.sendfileok({},JSON.stringify(sf));
  2142. }
  2143. });
  2144. }
  2145. js.tanclose('sysshowstar');
  2146. }else{
  2147. js.confirm('确定要删除此收藏吗?', function(jg){
  2148. if(jg=='yes'){
  2149. reim.starlistarr[i]=false;
  2150. $(o1).remove();
  2151. reim.ajax(reim.getapiurl('reim','delstar'),{id:d1.id});
  2152. }
  2153. });
  2154. }
  2155. };
  2156. this.staradd=function(d){
  2157. js.loading('收藏中...');
  2158. var da = {messid:d.id,fileid:d.fileid,cont:d.cont,type:this.type}
  2159. if(d.filers){
  2160. da.fileext = d.filers['fileext'];
  2161. var img = d.filers['thumbpath'];
  2162. var nae = d.filers['filename'];
  2163. var sids = d.filers['filesizecn'];
  2164. var nnud = d.filers['filenum'];
  2165. if(js.isimg(da.fileext) && img)da.imgurl = img;
  2166. if(nae)da.filename = nae;
  2167. if(sids)da.filesizecn = sids;
  2168. if(nnud)da.filenum = nnud;
  2169. }
  2170. var kev = ''+d.id+'';if(this.type=='gout' || this.type=='uout')kev='out_'+d.id+'';
  2171. if(this.type=='zixun')kev='zixun_'+d.id+'';
  2172. reim.ajax(reim.getapiurl('reim','savestar'),{kev:kev,content:jm.base64encode(JSON.stringify(da))}, function(ret){
  2173. reim.starlistarr=false;
  2174. js.msgok('收藏成功');
  2175. },'post');
  2176. }
  2177. this._init();
  2178. }
  2179. //相关回调
  2180. var im = {
  2181. clickqipao:function(o1,e){
  2182. },
  2183. rightqipao:function(o1,e,rnd){
  2184. reim.chatobj[reim.nowtabs].rightqipao(o1,e,rnd);
  2185. },
  2186. backemts:function(s){
  2187. reim.chatobj[reim.nowtabs].addinput(s);
  2188. $('#aemtsdiv').hide();
  2189. },
  2190. sendfileshow:function(f){
  2191. var num = uploadobj.nownum;
  2192. reim.chatobj[num].sendfileshow(f);
  2193. },
  2194. upprogresss:function(per){
  2195. var num = uploadobj.nownum;
  2196. strformat.upprogresss(per);
  2197. },
  2198. sendfileok:function(f,str){
  2199. var num = uploadobj.nownum;
  2200. reim.chatobj[num].sendfileok(f, str);
  2201. },
  2202. senderror:function(){
  2203. var num = uploadobj.nownum;
  2204. reim.chatobj[num].senderrornss();
  2205. },
  2206. readclip:function(num,e){
  2207. reim.chatobj[num].readclip(e);
  2208. },
  2209. upbase64:function(nuid){
  2210. var o = get('jietuimg_'+nuid+'');
  2211. reim.chatobj[reim.nowtabs].sendbase64(o.src);
  2212. },
  2213. cropScreen:function(){
  2214. if(nwjsgui){
  2215. var oatg = nwjs.getpath();
  2216. nw.Shell.openItem(''+oatg+'/images/reimcaptScreen.exe');
  2217. }
  2218. },
  2219. windowfocus:function(){
  2220. if(jietubool){
  2221. reim.chatobj[reim.nowtabs].pasteimg();
  2222. }
  2223. jietubool = false;
  2224. notifyobj.close();
  2225. nwjs.jumpclear();
  2226. },
  2227. fileyulan:function(pn,fid){
  2228. var url = '?m=public&a=fileviewer&id='+fid+'';
  2229. js.open(url, 800, 500);
  2230. }
  2231. }
  2232. //下载文件预览的,glx0预览,1下载
  2233. strformat.onopenfile=function(da,glx){
  2234. var url = da.upurl;
  2235. if(glx==0 && da.isimg=='1'){
  2236. strformat.imgview(url);
  2237. }else{
  2238. if(glx==1){
  2239. js.location(url);
  2240. }else{
  2241. js.open(url, 1000,600);
  2242. }
  2243. }
  2244. return true;
  2245. }
  2246. strformat.clickface=function(rnd,os){
  2247. $.imgview({url:os.src});
  2248. }
  2249. strformat.openurl=function(dz){
  2250. if(!nwjsgui){
  2251. window.open(dz);
  2252. }else{
  2253. nwjs.openurl(dz);
  2254. //js.open(dz,1000,600);
  2255. }
  2256. }
  2257. strformat.clickfile=function(fid,lx){
  2258. if(isNaN(fid)){
  2259. reim.outgroup.fileopt(fid,lx);
  2260. }else{
  2261. js.fileopt(fid,lx);
  2262. }
  2263. }
  2264. strformat.clickimg=function(o1){
  2265. var o=$(o1);
  2266. var src = o1.src.replace('_s.','.');
  2267. var fid = o.attr('fid');
  2268. $.imgview({
  2269. url:src,
  2270. fileid:fid,
  2271. ismobile:false,
  2272. onloadsuccess:function(img){
  2273. if(img.src.substr(-3)=='gif'){
  2274. o1.src = img.src;
  2275. js.setoption('filesrc_'+this.fileid+'', img.src);
  2276. }
  2277. }
  2278. });
  2279. }
  2280. //外部群使用
  2281. reim.outgroup={
  2282. objarr:[],
  2283. outgrouplist0:[],
  2284. myid:0,
  2285. istxs:'',
  2286. apiurl:'aHR0cDovL2FwaS5yb2Nrb2EuY29tLw::', //如果不想使用清空这个地址就可以
  2287. apiurls:'aHR0cHM6Ly94Y3kucm9ja29hLmNvbS8:', //https使用
  2288. //apiurl:'aHR0cDovLzE5Mi4xNjguMS4yL2FwcC9yb2NrYXBpLw::',
  2289. geturl:function(fx){
  2290. if(NOWURL.substr(0,5)=='https')this.apiurl = this.apiurls;
  2291. var url = jm.base64decode(this.apiurl)+'?m=outgroup&a='+fx+'&outunum='+this.outunum+'&cfrom=reim';
  2292. return url;
  2293. },
  2294. isopen:function(){
  2295. if(reim.outgroupopen=='open')return true;
  2296. return false;
  2297. },
  2298. clearchache:function(){
  2299. js.setoption('outgrouplist0', '');
  2300. js.setoption('outunum', '');
  2301. },
  2302. reload:function(){
  2303. this.loaddata(this.outunum);
  2304. },
  2305. loaddata:function(unum){
  2306. this.outunum = unum;
  2307. if(!this.isopen()){
  2308. this.clearchache();
  2309. return;
  2310. }
  2311. js.setoption('outunum', unum);
  2312. var me = this;
  2313. reim.ajax(this.geturl('getlist'),{lx:0},function(ret){
  2314. me.showdata(ret.data);
  2315. });
  2316. },
  2317. dellist:function(typ,gid){
  2318. this.updatelist(typ,gid,{}, true);
  2319. },
  2320. updatelist:function(typ,gid,arr,isd){
  2321. var d = false,da=this.outgrouplist0,i,ds=[],d1,j,d2;
  2322. for(i=0;i<da.length;i++){
  2323. d1 = da[i];
  2324. if(d1.type==typ && d1.receid==gid){
  2325. for(j in arr)d1[j]=arr[j];
  2326. d2 = d1;
  2327. }else{
  2328. ds.push(d1);
  2329. }
  2330. }
  2331. if(d2 && !isd)ds.unshift(d2);
  2332. this.outgrouplist0 = ds;
  2333. js.setoption('outgrouplist0', JSON.stringify(ds));
  2334. },
  2335. showdata:function(da){
  2336. var hlist = da.hlist;
  2337. this.outgrouplist0 = hlist;
  2338. js.setoption('outgrouplist0', JSON.stringify(hlist));
  2339. reim.outgrouplist = da.alist;
  2340. var myinfo = da.myinfo;
  2341. reim.showhistory(reim.maindata.harr);
  2342. if(!this.socketob && da.wsconfig)this.linkwebsocket(da.wsconfig,0);
  2343. },
  2344. linkwebsocket:function(conf,lx){
  2345. this.reimconf = conf;
  2346. clearTimeout(this.webtimes);
  2347. if(this.ws)this.ws.close();
  2348. this.ws = new WebSocket(conf.url);
  2349. var me = this;
  2350. this.myid = conf.id;
  2351. this.istxs = conf.istxs;
  2352. this.ws.onopen = function(){
  2353. this.send('{"from":"'+conf.recid+'","adminid":"'+conf.id+'","atype":"connect","sendname":"outname"}');
  2354. me.socketob = true;
  2355. if(lx==1)me.linkwebsocket(conf,2);
  2356. };
  2357. this.ws.onerror = function(e){
  2358. me.socketob = false;
  2359. me.reloadWebSocket(false);
  2360. };
  2361. this.ws.onmessage = function (evt){
  2362. var ds = JSON.parse(evt.data);
  2363. me.onmessage(ds);
  2364. };
  2365. this.ws.onclose = function(e){
  2366. me.socketob = false;
  2367. me.reloadWebSocket(false);
  2368. };
  2369. },
  2370. reloadWebSocket:function(bo){
  2371. clearTimeout(this.webtimes);
  2372. if(!bo){
  2373. this.webtimes=setTimeout('reim.outgroup.reloadWebSocket(true)', 5*1000);
  2374. }else{
  2375. if(!this.socketob)this.linkwebsocket(this.reimconf,1);
  2376. }
  2377. },
  2378. onmessage:function(ds){
  2379. //console.log(ds);
  2380. if(ds.sendid==this.myid && ds.laiyuan=='reim')return;
  2381. ds.ismysend = (ds.sendid==this.myid);
  2382. if(ds.type=='chehui'){
  2383. $('#qipaocont_mess_'+ds.messid+'').html(js.getmsg(jm.base64decode(ds.cont),'green'));
  2384. this.reload();
  2385. }else{
  2386. if(ds.type=='gout' && ds.face){
  2387. ds.zijiid = this.myid;
  2388. if(this.istxs.indexOf(','+ds.gid+',')<0)ds.nottixi = true;
  2389. reim.receivechat(ds);
  2390. }
  2391. }
  2392. },
  2393. fileopt:function(id1,lx){
  2394. js.loading('加载中...');
  2395. reim.ajax(this.geturl('fileinfo'),{lx:lx,id:id1},function(ret){
  2396. var da = ret.data,url = da.url;
  2397. js.unloading();
  2398. if(da.lx==1){
  2399. js.location(url);
  2400. }else{
  2401. js.open(url, 1000,500);
  2402. }
  2403. },'',function(ret){
  2404. js.msgerror(ret.msg);
  2405. });
  2406. }
  2407. }