reim_xina.js 80 KB

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