reim_xina.js 75 KB

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