reim_xin.js 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682
  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. //是不是xp和win7的版本
  9. function jisxobo(){
  10. var llq = navigator.userAgent.toLowerCase();
  11. if(llq.indexOf('windows nt 5')>0 || llq.indexOf('windows nt 6.1')>0){
  12. return true;
  13. }
  14. return false;
  15. }
  16. var reim={
  17. chatobj:{},
  18. maindata:{},
  19. initci:0,
  20. timeloads:0,
  21. ruloadtime:5*60, //5分钟
  22. init:function(){
  23. js.ajaxwurbo = true;
  24. js.xpbodysplit = 5;
  25. date = js.now('Y-m-d');
  26. nwjs.init();
  27. bodyunload=function(){
  28. nwjs.removetray();
  29. }
  30. this.resize();
  31. nwjs.serverdata=function(d){
  32. return reim.serverdata(d);
  33. }
  34. $(window).resize(this.resize);
  35. $(window).focus(function(){windowfocus=true;im.windowfocus()});
  36. $(window).blur(function(){windowfocus=false});
  37. //数秒
  38. setInterval('reim.timeload()', 1000);
  39. var fse=js.getoption('loginface');
  40. if(fse)get('myface').src=fse;
  41. nwjs.createtray(document.title+'-'+adminname, 1);
  42. strformat.ismobile=0;
  43. //禁止后退
  44. try{
  45. history.pushState(null, null, document.URL);
  46. window.addEventListener('popstate', function (){
  47. history.pushState(null, null, document.URL);
  48. });
  49. }catch(e){}
  50. this.initload();
  51. $('#centlist').perfectScrollbar();
  52. uploadobj = $.rockupload({
  53. inputfile:'allfileinput',
  54. initpdbool:false,
  55. updir:'reimchat',
  56. urlparams:{noasyn:'yes'}, //不需要同步到文件平台上
  57. onchange:function(d){
  58. im.sendfileshow(d);
  59. },
  60. onprogress:function(f,per,evt){
  61. im.upprogresss(per);
  62. },
  63. onsuccess:function(f,str,o1){
  64. im.sendfileok(f,str);
  65. },
  66. onerror:function(str){
  67. js.msg('msg', str);
  68. im.senderror();
  69. }
  70. });
  71. strformat.upobj = uploadobj;
  72. $('body').keydown(function(e){
  73. return reim.bodykeydown(e);
  74. });
  75. //注册推送提醒的
  76. notifyobj=new notifyClass({
  77. title:'系统提醒',
  78. sound:'web/res/sound/todo.ogg',
  79. sounderr:'',
  80. soundbo:this.getsound(), //是否要声音
  81. showbool:false
  82. });
  83. this.righthistroboj = $.rockmenu({
  84. data:[],
  85. itemsclick:function(d){
  86. reim.rightclick(d);
  87. }
  88. });
  89. $('#reimcog').click(function(){
  90. reim.clickcog(this);
  91. return false;
  92. });
  93. document.ondragover=function(e){e.preventDefault();};
  94. document.ondrop=function(e){e.preventDefault();};
  95. //注册全局ajax的错误
  96. js.ajaxerror=function(msg,code){
  97. if(code==401){
  98. js.msg();
  99. js.msgerror('登录失效,重新登录');
  100. if(!nwjsgui){
  101. js.location('/users/login?backurl=reim');
  102. }else{
  103. js.location('/reim/login.html');
  104. }
  105. }
  106. }
  107. if(!nwjsgui){
  108. $('#closediv').remove();
  109. }
  110. $('#reim_keysou').keyup(function(){reim.searchss();});
  111. $('#reim_keysou').click(function(){reim.searchss();});
  112. if(jisxobo()){
  113. js.xpbodysplit = 0;
  114. get('mindivshow').style.margin='0px';
  115. }
  116. },
  117. resize:function(){
  118. viewheight = winHb()-10-50; //可操作高度
  119. var lx1 = 0;
  120. if(jisxobo())lx1=10;
  121. viewheight+=lx1;
  122. $('#mindivshow').css('height',''+(viewheight+50)+'px');
  123. $('#centlist').css('height',''+viewheight+'px');
  124. $('#viewzhulist').css('height',''+viewheight+'px');
  125. var obj = $('div[resizeh]'),o,hei;
  126. for(var i=0;i<obj.length;i++){
  127. o = $(obj[i]);
  128. hei=parseInt(o.attr('resizeh'));
  129. o.css('height',''+(viewheight-hei)+'px');
  130. }
  131. //控制最小宽高
  132. if(nwjsgui){
  133. var w1 = 900,h1 = 600;
  134. var wid = winWb();
  135. var hei = winHb();
  136. if(wid<w1)nwjs.win.width=w1;
  137. if(hei<h1)nwjs.win.height=h1;
  138. }
  139. },
  140. timeload:function(){
  141. this.timeloads++;
  142. //刷新
  143. if(this.timeloads >= this.ruloadtime){
  144. this.timeloads = 0;
  145. this.initload();
  146. }
  147. //if(this.timeloads==5)this.getonline();//获取在线人员id
  148. },
  149. bodykeydown:function(e){
  150. var code = e.keyCode;
  151. if(code==27){
  152. if($.imgviewclose())return false;
  153. if(get('xpbg_bodydds')){
  154. js.tanclose($('#xpbg_bodydds').attr('xpbody'));
  155. }else{
  156. this.closenowtabss();
  157. }
  158. return false;
  159. }
  160. },
  161. winclose:function(){
  162. nwjs.win.hide();
  163. },
  164. winzuida:function(){
  165. if(!this.zdhbo){
  166. nwjs.win.maximize();
  167. this.zdhbo=true;
  168. }else{
  169. nwjs.win.unmaximize();
  170. this.zdhbo=false;
  171. }
  172. },
  173. changetabs:function(ind){
  174. $('div[id^="changetabs"]').css('color','#cccccc');
  175. $('div[id^="centshow"]').hide();
  176. $('#changetabs'+ind+'').css('color','#1389D3');
  177. $('#centshow'+ind+'').show();
  178. if(ind==1)this.showdept();
  179. if(ind==2){
  180. $('#maincenter').hide();
  181. this.showagent(true);
  182. }else{
  183. this.hideagent();
  184. $('#maincenter').show();
  185. }
  186. },
  187. getapiurl:function(m,a){
  188. return 'api.php?m='+m+'&a='+a+'&cfrom=reim';
  189. },
  190. //ajax访问处理
  191. ajax:function(url,cans, fun, lx,efun){
  192. if(!lx)lx='get';
  193. if(!fun)fun=function(){}
  194. if(!efun)efun=function(){}
  195. js.ajax(url,cans,function(ret){
  196. if(ret.code==200){
  197. fun(ret);
  198. }else if(ret.code==199){
  199. js.confirm(ret.msg, function(){
  200. reim.exitlogin(true);
  201. });
  202. }else{
  203. js.msg('msg',ret.msg);
  204. efun(ret);
  205. }
  206. },''+lx+',json', efun);
  207. },
  208. //初始加载数据
  209. initload:function(bo){
  210. this.initbool = true;
  211. this.ajax(this.getapiurl('indexreim','indexinit'),{'initci':this.initci,'gtype':'reim'}, function(ret){
  212. reim.initci++;
  213. reim.showdata(ret.data);
  214. if(bo)reim.reloaduser();
  215. });
  216. },
  217. firstpid:0,
  218. showdata:function(ret){
  219. if(!ret.userjson)return;
  220. this.lastloaddt = ret.loaddt;
  221. this.maindata.darr = js.decode(ret.deptjson);
  222. this.maindata.uarr = js.decode(ret.userjson);
  223. this.maindata.garr = js.decode(ret.groupjson);
  224. this.maindata.harr = js.decode(ret.historyjson);
  225. this.firstpid = this.maindata.darr[0].pid;
  226. if(!this.showconfigarr){
  227. this.showconfigarr = ret.config;
  228. this.websocketlink(ret.config);
  229. }
  230. var aarr = js.decode(ret.agentjson);
  231. var cbarr = {},i;
  232. for(i=0;i<aarr.length;i++){
  233. if(!cbarr[aarr[i].types])cbarr[aarr[i].types]=[];
  234. cbarr[aarr[i].types].push(aarr[i]);
  235. }
  236. this.maindata.aarr=cbarr;
  237. aarr = this.maindata.garr;
  238. for(i=0;i<aarr.length;i++){
  239. grouparr[aarr[i].id]=aarr[i];
  240. }
  241. aarr = this.maindata.uarr;
  242. for(i=0;i<aarr.length;i++){
  243. userarr[aarr[i].id]=aarr[i];
  244. }
  245. this.showagent(false);
  246. this.myip = ret.ip;
  247. this.showhistory(this.maindata.harr);
  248. if(ret.editpass==0)this.editpass('请先修改密码后在使用','none');
  249. },
  250. //搜索联系人/会话/应用
  251. searchss:function(){
  252. clearTimeout(this.searchsstime);
  253. this.searchsstime=setTimeout('reim.searchssss()',500);
  254. if(!this.searchright)this.searchright=$.rockmenu({
  255. data:[],iconswh:20,width:210,
  256. itemsclick:function(d){
  257. reim.searchclick(d);
  258. }
  259. });
  260. },
  261. searchclick:function(d){
  262. var ty = d.type;
  263. if(ty=='user')this.showuserinfo(d.xuoi);
  264. if(ty=='group')this.openchat(d.type,d.id,d.name,d.icons);
  265. if(ty=='agent')this.openagenh(d.id);
  266. },
  267. searchssss:function(){
  268. var o = $('#reim_keysou'),val=strreplace(o.val());
  269. var d=[];
  270. if(val==''){
  271. this.searchright.hide();
  272. return;
  273. }
  274. val=val.toLowerCase();
  275. var off=o.offset(),sid,a,s1,arr,i,oi=1;
  276. arr = this.maindata.uarr;
  277. for(i=0;i<arr.length;i++){
  278. a=arr[i];
  279. if(a.name.indexOf(val)>-1 || a.pingyin.indexOf(val)==0 || a.deptname.indexOf(val)>-1 || a.ranking.indexOf(val)>-1){
  280. s1=''+a.name+'<font color=#888888>('+a.ranking+')</font>';
  281. d.push({name:s1,id:a.id,icons:a.face,type:'user',xuoi:i});
  282. oi++;
  283. }
  284. if(oi>10)break;//最多显示10人
  285. }
  286. arr = this.maindata.garr;
  287. for(i=0;i<arr.length;i++){
  288. a=arr[i];
  289. if(a.name.indexOf(val)>-1){
  290. s1=''+a.name+'<font color=#888888>(会话)</font>';
  291. d.push({name:s1,id:a.id,icons:a.face,type:'group'});
  292. }
  293. }
  294. for(sid in agenharr){
  295. a=agenharr[sid];
  296. if(a.name.indexOf(val)>-1){
  297. s1=''+a.name+'<font color=#888888>(应用)</font>';
  298. d.push({name:s1,id:a.id,icons:a.face,type:'agent'});
  299. }
  300. }
  301. if(d.length==0){
  302. this.searchright.hide();
  303. return;
  304. }
  305. this.searchright.setData(d);
  306. this.searchright.showAt(off.left+1,off.top+25,$('#reim_headercenter').width()-2);
  307. },
  308. websocketlink:function(a){
  309. if(this.connectbool){
  310. this.serverstatus(1);
  311. return false;
  312. }
  313. if(!a){
  314. this.serverstatus(3);
  315. return false;
  316. }
  317. var wsurl = jm.base64decode(a.wsurl),receid = a.recid;
  318. this.showconfigarr = a;
  319. if(isempt(wsurl) || wsurl.indexOf('ws')<0){
  320. this.serverstatus(3);
  321. return false;
  322. }
  323. clearTimeout(this.relianshotime_time);
  324. websocketobj = new websocketClass({
  325. adminid:adminid,
  326. reimfrom:receid,
  327. wshost:wsurl,
  328. sendname:adminname,
  329. onerror:function(o,ws){
  330. reim.connectbool=false;
  331. reim.serverstatus(0);
  332. js.msg('msg','无法连接服务器1<br><span id="lianmiaoshoetime"></span><a href="javascript:;" onclick="reim.connectservers()">[重连]</a>',0);
  333. reim.relianshotime(30);
  334. },
  335. onmessage:function(str){
  336. reim.connectbool=true;
  337. clearTimeout(reim.relianshotime_time);
  338. var a=js.decode(str);
  339. reim.receivemesb(a);
  340. },
  341. onopen:function(){
  342. reim.connectbool=true;
  343. reim.serverstatus(1);
  344. clearTimeout(reim.relianshotime_time);
  345. js.msg('none');
  346. reim.initnotify();
  347. },
  348. onclose:function(o,e){
  349. reim.connectbool=false;
  350. if(reim.otherlogin)return;
  351. reim.serverstatus(0);
  352. js.msg('msg','连接已经断开了<br><span id="lianmiaoshoetime"></span><a href="javascript:;" onclick="reim.connectservers()">[重连]</a>',0);
  353. reim.relianshotime(10);
  354. }
  355. });
  356. },
  357. connectservers:function(){
  358. if(this.connectbool){
  359. this.serverstatus(1);
  360. return;
  361. }
  362. var bo = this.websocketlink(this.showconfigarr);
  363. if(bo)js.msg('wait','连接中...');
  364. },
  365. serverstatus:function(lx){
  366. var s = '<font color="green">已连接</font>';s='';
  367. if(lx==0)s='<font color="red">未连接</font>'
  368. if(lx==2)s='<font color="#ff6600">在别处连接</font>'
  369. if(lx==3)s='<font color="blue">没服务端</font>';
  370. $('#reim_statusserver').html(s);
  371. },
  372. relianshotime:function(oi){
  373. clearTimeout(this.relianshotime_time);
  374. $('#lianmiaoshoetime').html('('+oi+'秒后重连)');
  375. if(oi<=0){
  376. this.connectservers();
  377. }else{
  378. this.relianshotime_time=setTimeout('reim.relianshotime('+(oi-1)+')',1000);
  379. }
  380. },
  381. showdept:function(id){
  382. if($('#showdept').html()==''){
  383. this.reloaduser();
  384. }else{
  385. }
  386. },
  387. initnotify:function(){
  388. var lx=notifyobj.getaccess();
  389. if(lx!='ok'){
  390. //js.msg('msg','为了可及时收到信息通知 <br>请开启提醒,<span class="zhu cursor" onclick="reim.indexsyscogss()">[开启]</span>',-1);
  391. }
  392. },
  393. indexsyscogs:function(){
  394. var str = notifyobj.getnotifystr('reim.indexsyscogss()');
  395. return '桌面通知提醒'+str+'';
  396. },
  397. indexsyscogss:function(){
  398. notifyobj.opennotify(function(){
  399. js.msg('success', reim.indexsyscogs());
  400. });
  401. },
  402. reloaduser:function(){
  403. $('#showdept').html('');
  404. this.showuserlists(this.firstpid,0, 'showdept');
  405. this.showgroup();
  406. },
  407. //服务端发消息调用opener.reim.serversend(a);
  408. serversend:function(a){
  409. if(!this.connectbool)return false;
  410. websocketobj.send(a);
  411. return true;
  412. },
  413. //获取在线人员
  414. getonline:function(){
  415. this.serversend({'atype':'getonline'});
  416. },
  417. //别的地方登录
  418. otherlogins:function(){
  419. this.otherlogin = true;
  420. var msg='已在别的地方连接了';
  421. js.msg('success', msg, -1);
  422. this.serverstatus(2);
  423. },
  424. //收到推送消息
  425. receivemesb:function(d, lob){
  426. var lx=d.type,sendid=d.adminid;
  427. if(lx=='offoline'){
  428. this.otherlogins();
  429. return;
  430. }
  431. if(lx=='user' || lx=='group'){
  432. if(sendid!=adminid)this.receivechat(d);
  433. }
  434. if(lx=='agent'){
  435. this.receiveagenh(d);
  436. nwjs.jumpicon();
  437. }
  438. if(lx=='chehui'){
  439. $('#qipaocont_mess_'+d.messid+'').html(js.getmsg(jm.base64decode(d.cont),'green'));
  440. this.historyreload();
  441. }
  442. },
  443. showuserlists:function(pid,xu, svie){
  444. var o = $('#'+svie+'');
  445. var tx= o.text();
  446. if(tx){if(pid!=0){o.toggle();}return;}
  447. var a =this.maindata.uarr,i,len=a.length,d,dn,s='',wfj,zt,sids;
  448. for(i=0;i<len;i++){
  449. d=a[i];
  450. if(!userarr[d.id])userarr[d.id]=d;
  451. sids = ','+d.deptids+',';
  452. if(pid==d.deptid || sids.indexOf(','+pid+',')>-1){
  453. zt='';
  454. if(d.status==0)zt='&nbsp;<font style="font-size:12px" color=red>未加入</font>';
  455. s='<div class="lists" onclick="reim.showuserinfo('+i+')" style="padding-left:'+(xu*20+10)+'px" >';
  456. s+='<table cellpadding="0" border="0" width="100%"><tr>';
  457. s+='<td style="padding-right:5px"><div style="height:24px;overflow:hidden"><img src="'+d.face+'" style="height:24px;width:24px"></div></td>';
  458. s+='<td align="left" width="100%"><div class="name">'+d.name+''+zt+'</div></td>';
  459. s+='</tr></table>';
  460. s+='</div>';
  461. o.append(s);
  462. }
  463. }
  464. a = this.maindata.darr;
  465. len=a.length;
  466. for(i=0;i<len;i++){
  467. d = a[i];
  468. if(d.pid==pid){
  469. wfj = 'icon-folder-close-alt';
  470. s='<div class="lists" style="padding-left:'+(xu*20+10)+'px" onclick="reim.showuserlists('+d.id+','+(xu+1)+',\'showdept_'+d.id+'\')">';
  471. s+=' <i class="'+wfj+'"></i> '+d.name+'';
  472. if(d.ntotal>0)s+=' <span style="font-size:12px;color:#888888">('+d.ntotal+')</span>';
  473. s+='</div>';
  474. s+='<span id="showdept_'+d.id+'"></span>';
  475. o.append(s);
  476. if(xu==0)this.showuserlists(d.id, xu+1, 'showdept_'+d.id+'');
  477. }
  478. }
  479. },
  480. showgroup:function(){
  481. var a =this.maindata.garr,i,len=a.length,d,s='';
  482. s='<div style="padding:5px;margin-top:5px;color:#aaaaaa;border-bottom:1px #f1f1f1 solid">会话('+len+')</div>';
  483. for(i=0;i<len;i++){
  484. d = a[i];
  485. s+='<div onclick="reim.openchat(\'group\',\''+d.id+'\',\''+d.name+'\',\''+d.face+'\')" class="lists">';
  486. s+='<table cellpadding="0" border="0" width="100%"><tr>';
  487. s+='<td style="padding-right:5px"><div style="height:24px;overflow:hidden"><img src="'+d.face+'" style="height:24px;width:24px"></div></td>';
  488. s+=' <td align="left" width="100%"><div class="name">'+d.name+'';
  489. if(d.deptid=='1')s+=' <span class="reimlabel">全员</span>';
  490. if(d.deptid>'1')s+=' <span class="reimlabel1">部门</span>';
  491. s+=' </div></td>';
  492. s+='</tr></table>';
  493. s+='</div>';
  494. }
  495. $('#showgroup').html(s)
  496. },
  497. historyreload:function(){
  498. this.ajax(this.getapiurl('indexreim','gethistory'),{id:0},function(
  499. ret){
  500. var data = ret.data;
  501. reim.showhistory(data);
  502. });
  503. },
  504. showhistory:function(a){
  505. var i,len=a.length;
  506. $('#historylist').html('');
  507. $('#historylist_tems').show();
  508. for(i=0;i<len;i++){
  509. this.showhistorys(a[i]);
  510. }
  511. if(i>0)$('#historylist_tems').hide();
  512. },
  513. showhistorydata:{},
  514. showhistorys:function(d,pad, lex){
  515. var s,ty,o=$('#historylist'),d1,st,attr;
  516. var num = ''+d.type+'_'+d.receid+'';
  517. this.showhistorydata[num]=d;
  518. $('#history_'+num+'').remove();
  519. st = d.stotal;if(st=='0')st='';
  520. var ops = d.optdt.substr(11,5);
  521. if(d.optdt.indexOf(date)!=0)ops=d.optdt.substr(5,5);
  522. ty = d.type;
  523. var cls = lex ? ' active' : '';
  524. var na = d.name;
  525. if(d.title)na = d.title;
  526. if(d.type=='group'){
  527. var d2 = grouparr[d.receid];
  528. if(d2)d.deptid = d2.deptid;
  529. }
  530. var s1 = '';
  531. if(d.deptid=='1')s1=' <span class="reimlabel">全员</span>';
  532. if(d.deptid>'1')s1=' <span class="reimlabel1">部门</span>';
  533. 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+'\')">';
  534. s+='<table cellpadding="0" border="0" width="100%"><tr>';
  535. s+='<td style="padding-right:8px"><div style="height:30px;overflow:hidden"><img src="'+d.face+'"></div></td>';
  536. s+='<td align="left" width="100%"><div title="'+na+'" class="name">'+na+''+s1+'</div><div class="huicont">'+jm.base64decode(d.cont)+'</div></td>';
  537. s+='<td align="right" nowrap><span id="chat_stotal_'+num+'" class="badge red">'+st+'</span><br><span style="color:#cccccc;font-size:10px">'+ops+'</span></td>';
  538. s+='</tr></table>';
  539. s+='</div>';
  540. if(!pad){o.append(s);}else{o.prepend(s)}
  541. $('#historylist_tems').hide();
  542. this.showbadge('chat');
  543. },
  544. historyright:function(o1,e,num){
  545. var rt = $(o1).attr('rtype');
  546. if(isempt(rt))return false;
  547. this.rightdivobj = o1;
  548. var da=[{name:'打开',lx:0}],d=this.showhistorydata[num];
  549. if(d && d.stotal>0)da.push({name:'标识已读',lx:1});
  550. if(rt.indexOf('hist')>-1){
  551. da.push({name:'删除此记录',lx:2});
  552. }
  553. this.righthistroboj.setData(da);
  554. this.righthistroboj.showAt(e.clientX-3,e.clientY-3);
  555. return false;
  556. },
  557. rightclick:function(d){
  558. var o1 = $(this.rightdivobj),lx=d.lx;
  559. var tsaid = o1.attr('tsaid'),
  560. tsayp = o1.attr('tsaype');
  561. if(lx==0){
  562. this.rightdivobj.onclick();
  563. }
  564. if(lx==2){
  565. o1.remove();
  566. var tst=$('#historylist').text();if(tst=='')$('#historylist_tems').show();
  567. js.ajax(this.getapiurl('reim','delhistory'),{type:tsayp,gid:tsaid},false,'get');
  568. this.showbadge('chat');
  569. }
  570. if(lx==1){
  571. var num = ''+tsayp+'_'+tsaid+'';
  572. $('#chat_stotal_'+num+'').html('');
  573. var d=this.showhistorydata[num];
  574. if(d)d.stotal='0';
  575. this.showbadge('chat');
  576. this.biaoyd('agent',tsaid);
  577. }
  578. },
  579. openmyinfo:function(){
  580. this.showuserinfo(0,userarr[adminid]);
  581. },
  582. showuserinfo:function(oi, d1){
  583. var d = this.maindata.uarr[oi];
  584. if(d1)d=d1;
  585. var num = 'userinfo_'+d.id+'';
  586. var s = '<div align="center"><div align="left" style="width:300px;margin-top:50px">';
  587. 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>';
  588. 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>';
  589. 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>';
  590. 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>';
  591. s+='</div></div>';
  592. this.addtabs(num,s);
  593. if(d.id==adminid){
  594. if(!this.upfaceobj)this.upfaceobj=$.rockupload({
  595. inputfile:'upfacess',
  596. uptype:'image',
  597. urlparams:{noasyn:'yes'}, //不需要同步到文件平台上
  598. onsuccess:function(f,str){
  599. var a=js.decode(str);
  600. if(!a.id)return;
  601. reim.saveface(a.id);
  602. },
  603. onchange:function(){
  604. $('#fupbgonet').html('上传中...');
  605. }
  606. });
  607. }
  608. },
  609. saveface:function(fid){
  610. this.ajax(this.getapiurl('reim','changeface'),{id:fid},function(ret){
  611. var face = ret.data;
  612. get('myface').src=face;
  613. get('myfacess').src=face;
  614. adminface=face;
  615. js.setoption('loginface', face);
  616. js.setoption('adminface', face);
  617. $('#fupbgonet').html('修改成功');
  618. });
  619. },
  620. openchat:function(type,reid,na,fac){
  621. var num = ''+type+'_'+reid+'';
  622. $('#chat_stotal_'+num+'').html('');
  623. this.showbadge('chat');
  624. if(type=='agent'){
  625. var d = this.showhistorydata[num];
  626. var url='';
  627. if(d && d.stotal>0 && !isempt(d.xgurl)){
  628. d.stotal='0';
  629. var xga = d.xgurl.split('|');
  630. if(xga[1]>0)url='task.php?a=p&num='+xga[0]+'&mid='+xga[1]+'';
  631. }
  632. if(url==''){
  633. this.openagenh(reid);
  634. }else{
  635. this.biaoyd('agent',reid);
  636. js.open(url,760,500);
  637. }
  638. return;
  639. }
  640. var s = '<div style="background:#f5f9ff">';
  641. s+='<div id="viewtitle_'+num+'" style="height:50px;overflow:hidden;border-bottom:#dddddd solid 1px;">';
  642. s+='</div>';
  643. var hei = 206;
  644. 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>';
  645. s+='<div class="toolsliao" id="toolsliao_'+num+'">';
  646. s+=' <span title="表情" tools="emts" class="cursor"><i class="icon-heart"></i></span>';
  647. s+=' <span title="文件/图片" tools="file" class="cursor"><i class="icon-folder-close"></i></span>';
  648. if(nwjsgui){
  649. s+=' <span title="粘贴图片" tools="paste" class="cursor"><i class="icon-paste"></i></span>';
  650. s+=' <span title="截屏" tools="crop" class="cursor"><i class="icon-cut"></i></span>';
  651. }
  652. s+='</div>';
  653. 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>';
  654. 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:#1389D3" id="chatsendbtn_'+num+'" type="button" value="发送(S)"></div></div>';
  655. s+='</div>';
  656. var bo = this.addtabs(num,s);
  657. get('input_content_'+num+'').focus();
  658. if(!bo){
  659. this.chatobj[num]=new chatcreate({
  660. 'type' : type,
  661. 'gid' : reid,
  662. 'num' : num,
  663. 'name' : na,
  664. 'face' : fac
  665. });
  666. }
  667. this.chatobj[num].onshow();
  668. },
  669. biaoyd:function(type,gid){
  670. js.ajax(this.getapiurl('reim','yiduall'),{type:type,gid:gid},false,'get');
  671. },
  672. receiveagenh:function(d){
  673. var gid = d.gid;
  674. var num = d.type+'_'+gid,stotal=0,msg;
  675. var so = $('#chat_stotal_'+num+'').html();
  676. if(!so)so=0;
  677. stotal = parseInt(so)+1;
  678. this.showhistorys({
  679. 'cont' : d.cont,
  680. 'name' : d.gname,
  681. 'title' : d.title,
  682. 'face' : d.gface,
  683. 'optdt' : d.optdt,
  684. 'type' : d.type,
  685. 'receid' : gid,
  686. 'stotal' : stotal
  687. }, true);
  688. msg = jm.base64decode(d.cont);
  689. msg = msg.replace(/\\n/gi,' ');
  690. var sopenfun=function(b){
  691. js.alertclose();
  692. notifyobj.close();//关闭右下角的提示
  693. if(b.url){
  694. js.open(b.url,760,500);
  695. return true;
  696. }else{
  697. reim.openagenh(b.gid, b.url);
  698. }
  699. return true; //不激活主窗口
  700. }
  701. js.alertclose();
  702. js.confirm(msg,function(jg){if(jg=='yes'){sopenfun(d)}},'','<img src="'+d.gface+'" align="absmiddle" width="20" height="20">&nbsp;'+d.title);
  703. if(this.getzhuom())notifyobj.showpopup(msg,{icon:d.gface,url:d.url,gid:gid,title:d.title,rand:num,click:function(b){
  704. return sopenfun(b);
  705. }});
  706. },
  707. receivechat:function(d){
  708. var gid = d.gid,lx = d.type,stotal=0,num,msg,name=d.gname,face=d.face,s1='';
  709. if(lx=='user'){
  710. gid = d.adminid;
  711. name= d.sendname;
  712. }
  713. if(lx=='group'){
  714. face = d.gface;
  715. s1 = jm.base64encode(''+d.sendname+':');
  716. if(isempt(face))face = 'images/group.png';
  717. }
  718. num = d.type+'_'+gid;
  719. var showtx = true;
  720. if(this.isopentabs(num)){
  721. this.chatobj[num].receivedata(d);
  722. if(this.nowtabs!=num){
  723. this.chatobj[num].newbool=true;
  724. }
  725. }
  726. if(windowfocus && this.nowtabs==num)showtx=false;
  727. //未读数
  728. if(this.nowtabs!=num){
  729. var so = $('#chat_stotal_'+num+'').html();
  730. if(!so)so=0;
  731. stotal = parseInt(so)+1;
  732. }
  733. this.showhistorys({
  734. 'cont' : s1+d.cont,
  735. 'name' : name,
  736. 'face' : face,
  737. 'optdt' : d.optdt,
  738. 'type' : d.type,
  739. 'receid' : gid,
  740. 'stotal' : stotal
  741. }, true, this.nowtabs==num);
  742. var nr = jm.base64decode(d.cont);
  743. if(showtx || nr.indexOf('@'+adminname+'')>-1){
  744. var title = '会话消息';
  745. msg = '人员['+d.sendname+'],发来一条信息';
  746. if(lx == 'group'){
  747. msg += ',来自['+name+']';
  748. }
  749. if(this.getzhuom())notifyobj.showpopup(msg,{icon:face,type:lx,gid:gid,name:name,title:title,rand:num,click:function(b){
  750. reim.openchat(b.type, b.gid,b.name,b.icon);
  751. }});
  752. nwjs.jumpicon();
  753. }
  754. },
  755. addtabs:function(num, s){
  756. var ids = 'tabs_'+num+'',bo;
  757. if(!get(ids)){
  758. var s = '<div tabs="'+num+'" id="'+ids+'">'+s+'</div>';
  759. $('#viewzhulist').append(s);
  760. bo = false;
  761. }else{
  762. bo = true;
  763. }
  764. this.showtabs(num);
  765. return bo;
  766. },
  767. closetabs:function(num){
  768. var ids = 'tabs_'+num+'';
  769. $('#'+ids+'').remove();
  770. var ood = $('#viewzhulist div[tabs]:last');
  771. var snu = ood.attr('tabs');
  772. this.showtabs(snu);
  773. },
  774. closenowtabs:function(){
  775. if(this.nowtabs)this.closetabs(this.nowtabs);
  776. },
  777. closenowtabss:function(){
  778. var nun = this.nowtabs;
  779. if(!nun)return;
  780. if(nun.indexOf('user_')==0 || nun.indexOf('group_')==0 || nun.indexOf('userinfo_')==0)this.closenowtabs();
  781. },
  782. isopentabs:function(num){
  783. return get('tabs_'+num+'');
  784. },
  785. showtabs:function(num){
  786. $('div[tabs]').hide();
  787. var ids = 'tabs_'+num+'';
  788. $('#'+ids+'').show();
  789. $('div[temp]').removeClass('active');
  790. $('#history_'+num+'').addClass('active');
  791. this.nowtabs = num;
  792. },
  793. showagent:function(sbo){
  794. var agedt = this.maindata.aarr,s='',ty,a,len,d,d1,sno,so=0,sodd=1;
  795. s+='<div id="agenhview" resizeh="0" style="height:'+viewheight+'px;overflow:hidden;position:relative; background:#fcfdff" align="center"><div style="width:80%;padding:20px" align="left">';
  796. agenharr={};
  797. for(ty in agedt){
  798. a = agedt[ty];
  799. len = a.length;
  800. s+='<div style="color:#aaaaaa;padding-left:20px;margin-bottom:10px;padding:5px;border-bottom:'+sodd+'px solid #eeeeee">&nbsp;&nbsp;'+ty+'</div>';
  801. s+='<div class="agenhclsdiv">';
  802. for(i=0;i<len;i++){
  803. d1 = a[i];
  804. if(!agenharr[d1.id])agenharr[d1.id]=d1;
  805. d = agenharr[d1.id];
  806. sno = d.stotal;
  807. so += sno;
  808. if(sno==0)sno='';
  809. s+='<div onclick="reim.openagenh(\''+d.id+'\')" class="agenhcls"><div style="padding-top:5px"><img src="'+d.face+'"></div><div>'+d.name+'</div>';
  810. s+='<span id="agenh_stotal_'+d.id+'" class="badge">'+sno+'</span>';
  811. s+='</div>';
  812. }
  813. s+='</div>';
  814. sodd=1;
  815. }
  816. s+='</div>';
  817. if(!sbo){
  818. if(so==0)so='';
  819. $('#agenh_stotal').html(so);
  820. return;
  821. }
  822. var bo = this.addtabs('agenh',s);
  823. if(!bo)$('#agenhview').perfectScrollbar();
  824. this.showbadge('agenh');
  825. },
  826. hideagent:function(){
  827. if(get('tabs_agenh'))
  828. this.closetabs('agenh');
  829. },
  830. openagenh:function(id, url){
  831. var d = agenharr[id];
  832. if(!d){
  833. js.msg('msg','应用不存在,请刷新');
  834. return;
  835. }
  836. d.stotal=0;
  837. var num = 'agenh_'+d.id+'';
  838. $('#agenh_stotal_'+d.id+'').html('');
  839. this.showagent(false);
  840. $('#chat_stotal_'+num+'').html('');
  841. this.showbadge('chat');
  842. this.biaoyd('agent',d.id);
  843. var w = 1100,h=600,url = d.urlpc;
  844. if(isempt(url)){
  845. url = d.urlm;
  846. if(isempt(url)){
  847. url = '?d=we&m=ying&num='+d.num+''; //先默认用移动端
  848. }
  849. w = 350;
  850. }
  851. var jg = (url.indexOf('?')>-1)?'&':'?';
  852. url+=''+jg+'openfrom=reim';
  853. //考勤打卡
  854. if(d.num=='kqdaka'){
  855. this.opendaka();return;
  856. }
  857. if(url.substr(0,4)=='http' && url.indexOf(HOST)<0 && nwjsgui){
  858. nwjs.openurl(url);
  859. }else{
  860. js.open(url, w,h,'agent'+d.num+'');
  861. }
  862. },
  863. //考勤打卡
  864. opendaka:function(bo){
  865. var url = '?d=reim&m=ying&a=daka',w = 550;h=300;
  866. js.open(url, w,h,'agentkqdaka',{},{icon:'images/adddk.png'});
  867. },
  868. showbadge:function(lx){
  869. var obj = $('span[id^="'+lx+'_stotal_"]'),so=0,s1,o,i;
  870. for(i=0;i<obj.length;i++){
  871. o = $(obj[i]);
  872. s1= o.html();
  873. if(!s1)s1='0';
  874. so+=parseInt(s1);
  875. }
  876. if(so==0)so='';
  877. $('#'+lx+'_stotal').html(so);
  878. var zoi = 0;
  879. so = $('#agenh_stotal').html();
  880. if(!so)so = 0;
  881. zoi+=parseInt(so);
  882. so = $('#chat_stotal').html();
  883. if(!so)so = 0;
  884. zoi+=parseInt(so);
  885. nwjs.changeicon(zoi);
  886. },
  887. clickcog:function(o1){
  888. if(!this.cogmenu)this.cogmenu =$.rockmenu({
  889. data:[],
  890. width:120,
  891. itemsclick:function(d){
  892. reim.clickcogclick(d);
  893. }
  894. });
  895. var d = [{'name':'消息记录',lx:'jl'},{'name':'刷新',lx:'sx'},{'name':'创建会话',lx:'create'},{'name':'修改密码',lx:'pass'}];
  896. if(companymode)d.push({'name':'切换单位',lx:'qhqy'});
  897. d.push({'name':'设置',lx:'cog'});
  898. d.push({'name':'退出',lx:'exit'});
  899. this.cogmenu.setData(d);
  900. var off = $(o1).offset();
  901. this.cogmenu.showAt(40,off.top-d.length*36);
  902. },
  903. openrecord:function(){
  904. var url = '?homeurl=cmVpbSxyZWNvcmQsYXR5cGU9bXk:&homename=5oiR55qE5Lya6K!d6K6w5b2V&menuid=MjI3';
  905. js.open(url,1000,550,'chatrecord');
  906. },
  907. clickcogclick:function(d){
  908. var lx=d.lx;
  909. if(lx=='sx'){
  910. js.loading('刷新中...');
  911. location.reload();
  912. }
  913. if(lx=='exit'){
  914. this.exitlogin();
  915. }
  916. if(lx=='cog'){
  917. this.cogshow();
  918. }
  919. if(lx=='jl'){
  920. this.openrecord();
  921. }
  922. if(lx=='create'){
  923. this.creategroup();
  924. }
  925. if(lx=='pass'){
  926. this.editpass();
  927. }
  928. if(lx=='qhqy'){
  929. this.changecom();
  930. }
  931. },
  932. //创建会话
  933. creategroup:function(){
  934. js.prompt('创建会话','请输入会话名称:',function(lx,v){
  935. if(lx=='yes'){
  936. if(!v){js.msg('msg','没有输入会话名称');return false;}
  937. js.msg('wait','创建中...');
  938. reim.ajax(reim.getapiurl('reim','createlun'),{val:jm.base64encode(v)}, function(da){
  939. js.msg('success','创建成功,请打开会话窗口邀请人员加入');
  940. reim.changetabs(1);
  941. reim.initload(true);
  942. });
  943. }
  944. });
  945. return false;
  946. },
  947. editpass:function(bt,cse){
  948. if(!bt)bt='修改密码';
  949. if(!cse)cse='';
  950. js.tanbody('winiframe',bt,350,300,{
  951. html:'<div style="height:250px;overflow:hidden"><iframe src="" name="openinputiframe" width="100%" height="100%" frameborder="0"></iframe></div>',
  952. bbar:'none',
  953. closed:cse
  954. });
  955. openinputiframe.location.href='?m=index&d=we&a=editpass&hideheader=true&ofrom=reim';
  956. },
  957. changecom:function(){
  958. js.tanbody('winiframe','切换单位',350,300,{
  959. html:'<div style="height:250px;overflow:hidden"><iframe src="" name="openinputiframe" width="100%" height="100%" frameborder="0"></iframe></div>',
  960. bbar:'none'
  961. });
  962. openinputiframe.location.href='?m=index&d=we&a=company&hideheader=true&ofrom=reim';
  963. },
  964. changecomok:function(){
  965. js.tanclose('winiframe');
  966. js.msgok('切换成功');
  967. location.reload();
  968. },
  969. exitlogin:function(bo){
  970. if(!bo){
  971. js.confirm('确定要退出系统吗?',function(jg){
  972. if(jg=='yes')reim.exitlogin(true);
  973. });
  974. return;
  975. }
  976. if(nwjsgui){
  977. js.loading('退出中...');
  978. js.ajax(this.getapiurl('login','loginexit'),{},function(ret){
  979. js.setoption('autologin', '0');
  980. js.location('?d=reim&a=login&a=xin');
  981. });
  982. }else{
  983. window.close();
  984. }
  985. },
  986. getsound:function(){
  987. var lx = js.getoption('soundcog'),chs=false;
  988. if(lx=='')lx='1';
  989. if(lx==1)chs=true;
  990. return chs;
  991. },
  992. setsound:function(o1){
  993. var lx=(o1.checked)?'1':'2';
  994. js.setoption('soundcog', lx);
  995. notifyobj.setsound(o1.checked);
  996. },
  997. getzhuom:function(){
  998. var lx = js.getoption('zhuomcog'),chs=false;
  999. if(lx=='')lx='1';
  1000. if(lx==1)chs=true;
  1001. return chs;
  1002. },
  1003. setzhuom:function(o1){
  1004. var lx=(o1.checked)?'1':'2';
  1005. js.setoption('zhuomcog', lx);
  1006. },
  1007. cogshow:function(){
  1008. var chs= (this.getsound())?'checked':'';
  1009. var ch1= (this.getzhuom())?'checked':'';
  1010. var num = 'userinfo_cogshow';
  1011. var s = '<div align="center"><div align="left" style="width:300px;margin-top:50px">';
  1012. s+=' <div style="line-height:30px"><b>设置</b></div>';
  1013. s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid"><label><input '+ch1+' onclick="reim.setzhuom(this)" type="checkbox">新信息桌面提醒</label></div>';
  1014. s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid"><label><input '+chs+' onclick="reim.setsound(this)" type="checkbox">新信息声音提示</label></div>';
  1015. if(nwjsgui){
  1016. var ips = nwjs.getipmac();
  1017. s+='<div style="padding:10px 0px;border-top:1px #eeeeee solid">我局域网IP:'+ips.ip+'</div>';
  1018. s+='<div style="padding:10px 0px;border-top:1px #eeeeee solid">我的MAC地址:'+ips.mac+'</div>';
  1019. }
  1020. s+=' <div style="padding:10px 0px;border-top:1px #eeeeee solid">网络IP:'+this.myip+'</div>';
  1021. s+=' <div style="padding-top:10px;"><input onclick="reim.closetabs(\''+num+'\')" type="button" value="关闭" class="btn btn-danger"></div>';
  1022. s+='</div></div>';
  1023. this.addtabs(num,s);
  1024. },
  1025. //内部服务处理
  1026. serverdata:function(a){
  1027. var lx = a.atype;
  1028. if(lx=='focus')nwjs.winshow();
  1029. if(lx=='crop')this.cropScreen(true);
  1030. if(lx=='notify')this.shownotify(a);
  1031. if(lx=='openchat')this.openchat(a.id,a.type);
  1032. if(lx=='getlogin')return {uid:adminid,uname:adminname,face:adminface};
  1033. if(lx=='getipmac')return nwjs.getipmac();
  1034. if(lx=='office')nwjs.editoffice(a.paramsstr);
  1035. if(lx=='upfile')return nwjs.filetobase64(a.path);
  1036. if(lx=='gpath')return nwjs.getpath();
  1037. }
  1038. };
  1039. function chatcreate(cans){
  1040. for(var i in cans)this[i]=cans[i];
  1041. strformat.emotspath='web/';
  1042. var me = this;
  1043. this._init = function(){
  1044. this.minid = 999999999;
  1045. this.showobj = $('#viewcontent_'+this.num+'');
  1046. this.inputobj = $('#input_content_'+this.num+'');
  1047. this.sendbtn = $('#chatsendbtn_'+this.num+'');
  1048. this.listdata = {};
  1049. this.loadci = 0;
  1050. this.objstr = 'reim.chatobj[\''+this.num+'\']';
  1051. this.sendbtn.click(function(){
  1052. me.sendcont();
  1053. });
  1054. $('#chatclosebtn_'+this.num+'').click(function(){
  1055. me.closechat();
  1056. });
  1057. this.inputobj.keydown(function(e){
  1058. return me.onkeydown(e);
  1059. });
  1060. $('#toolsliao_'+this.num+'').find('span').click(function(e){
  1061. me.clicktools(this);
  1062. return false;
  1063. });
  1064. this.showtitle();
  1065. this.loaddata();
  1066. get('tabs_'+this.num+'').addEventListener('drop', function(e) {
  1067. var files = e.dataTransfer;
  1068. me.filedrop(files);
  1069. }, false);
  1070. };
  1071. this.showtitle=function(){
  1072. var o = $('#viewtitle_'+this.num+''),s='';
  1073. var od = this.receinfo;
  1074. if(!od)od={deptid:'-1'};
  1075. s+='<table width="100%"><tr>';
  1076. s+='<td width="30" align="center"><div style="padding:0px 10px;padding-right:8px;height:30px;overflow:hidden"><img style="border-radius:0px" src="'+this.face+'" height="30" width="30"></div></td>';
  1077. s+='<td height="50" width="100%">';
  1078. s+=' <div><b style="font-size:16px;">'+this.name+'</b>';
  1079. if(this.type=='group' && this.usershu)s+='('+this.usershu+')';
  1080. if(this.type=='group'){
  1081. if(od.deptid=='1')s+=' <span class="reimlabel">全员</span>';
  1082. if(od.deptid>'1')s+=' <span class="reimlabel1">部门</span>';
  1083. }
  1084. if(od.ranking)s+=' <span style="font-size:12px;color:#aaaaaa">('+od.ranking+')</span>';
  1085. s+=' </div>';
  1086. if(od.unitname)s+='<div style="font-size:12px;color:#aaaaaa">'+od.unitname+'</div>';
  1087. s+='</td>';
  1088. if(this.type=='group'){
  1089. if(!od.deptid || od.deptid=='0'){
  1090. s+='<td width="30" title="邀请" id="yaoqingchat_'+this.num+'" class="chattitbtn" nowrap><i class="icon-plus"></i></td>';
  1091. s+='<td width="30" title="退出会话" id="tuichuchat_'+this.num+'" class="chattitbtn" nowrap><i class="icon-signout"></i></td>';
  1092. }
  1093. s+='<td width="30" title="会话里的人员" id="tuiuserlist_'+this.num+'" class="chattitbtn" nowrap><i class="icon-group"></i></td>';
  1094. }
  1095. s+='</tr></table>';
  1096. o.html(s);
  1097. $('#yaoqingchat_'+this.num+'').click(function(){
  1098. me.yaoqing();
  1099. });
  1100. $('#tuichuchat_'+this.num+'').click(function(){
  1101. me.exitgroup();
  1102. });
  1103. $('#tuiuserlist_'+this.num+'').click(function(){
  1104. me.showhuilist();
  1105. });
  1106. };
  1107. this.loaddata=function(o1, iref){
  1108. if(this.boolload)return;
  1109. var iref = (!iref)?false:true;
  1110. var minid= 0;
  1111. if(iref)minid=this.minid;
  1112. if(o1)$(o1).html('<img src="images/loadings.gif" height="14" width="15" align="absmiddle"> 加载中...');
  1113. this.boolload = true;
  1114. this.isshangla = false;
  1115. reim.ajax(reim.getapiurl('reim','getrecord'),{type:this.type,gid:this.gid,minid:minid,loadci:this.loadci},function(ret){
  1116. if(o1)$(o1).html('');
  1117. var da = ret.data;
  1118. if(me.loadci==0){
  1119. me.showobj.html('');
  1120. me.sendinfo = da.sendinfo;
  1121. me.receinfo = da.receinfor;
  1122. me.usershu = me.receinfo.utotal;
  1123. me.showtitle();
  1124. me.showobj.perfectScrollbar();
  1125. }
  1126. me.loadci++;
  1127. me.boolload = false;
  1128. me.loaddatashow(da, iref);
  1129. });
  1130. };
  1131. this.loaddatashow=function(ret,isbf, isls){
  1132. var a = ret.rows;
  1133. this.lastdt = ret.nowdt;
  1134. var i,len = a.length,cont,lex,nas,fase,nr,d,na=[],rnd,sid;
  1135. $('#loadmored_'+this.num+'').remove();
  1136. if(isbf){
  1137. if(len>0)this.showobj.prepend('<div class="showblanks">---------↑以上是新加载---------</div>');
  1138. na = a;
  1139. }else{
  1140. for(i= len-1; i>=0; i--)na.push(a[i]);
  1141. }
  1142. for(i= 0; i<len; i++){
  1143. d = na[i];
  1144. sid = parseFloat(d.id);
  1145. lex = 'right';
  1146. nas = '我';
  1147. fase= this.sendinfo.face;
  1148. if(d.sendid!=this.sendinfo.id){
  1149. lex='left';
  1150. nas= d.sendname;
  1151. fase= d.face;
  1152. }
  1153. nr = this.contshozt(d.filers);
  1154. if(nr=='')nr= jm.base64decode(d.cont);
  1155. rnd = 'mess_'+sid+'';
  1156. if(get('qipaocont_'+rnd+''))continue;
  1157. cont= strformat.showqp(lex,nas,d.optdt,nr ,'', fase, rnd);
  1158. if(!isbf){
  1159. this.addcont(cont, isbf);
  1160. }else{
  1161. this.showobj.prepend(cont);
  1162. }
  1163. this.listdata[rnd]=d;
  1164. $('#qipaocont_'+rnd+'').contextmenu(function(e){
  1165. me.contright(this,e);
  1166. return false;
  1167. });
  1168. if(sid<this.minid)this.minid=sid;
  1169. }
  1170. if(len>0 && !isls){
  1171. var s = '<div class="showblanks" >';
  1172. if(ret.wdtotal==0){
  1173. s+='---------↑以上是历史记录---------';
  1174. if(len>=5){
  1175. this.showobj.prepend('<div id="loadmored_'+this.num+'" class="showblanks" ><a href="javascript:;" onclick="'+this.objstr+'.loadmoreda(this)"><i class="icon-time"></i> 查看更多消息</a></div>');
  1176. this.isshangla = true;
  1177. }
  1178. }else{
  1179. s+='---↑以上是历史,还有未读信息'+ret.wdtotal+'条,<a href="javascript:;" onclick="'+this.objstr+'.loaddata(this)">点击加载</a>---';
  1180. }
  1181. s+='</div>';
  1182. if(!isbf)this.addcont(s);
  1183. if(isbf)this._addclickf();
  1184. }
  1185. };
  1186. //邀请
  1187. this.yaoqing=function(){
  1188. if(this.type!='group')return;
  1189. js.changeuser(false,'usercheck','邀请人到会话中', {
  1190. onselect:function(sna,sid){
  1191. if(!sid)return;
  1192. me.yaoqings(sid);
  1193. }
  1194. });
  1195. };
  1196. this.yaoqings=function(sid){
  1197. js.msg('wait','邀请中...');
  1198. reim.ajax(reim.getapiurl('reim','yaoqinguid'),{val:sid,gid:this.gid},function(da){
  1199. js.msg();
  1200. if(da.success){
  1201. js.msgok('邀请成功');
  1202. me.userlistarr=false;
  1203. me.getreceinfor();
  1204. }else{
  1205. js.msg('msg',da);
  1206. }
  1207. });
  1208. };
  1209. this.getreceinfor=function(){
  1210. reim.ajax(reim.getapiurl('reim','getreceinfor'),{type:this.type,gid:this.gid},function(ret){
  1211. me.receinfo = ret.data.receinfor;
  1212. me.usershu = me.receinfo.utotal;
  1213. me.showtitle();
  1214. });
  1215. };
  1216. this.exitgroup=function(){
  1217. if(this.type!='group')return;
  1218. js.confirm('确定要此退出会话吗?',function(lx){
  1219. if(lx=='yes'){
  1220. me.exitgroups();
  1221. }
  1222. });
  1223. };
  1224. this.showhuilist=function(){
  1225. var s = '<div id="showuserlist" style="height:250px;overflow:auto;padding:5px 10px"><div align="center" style="padding:10px;"><img src="images/mloading.gif" align="absmiddle">&nbsp;加载人员...</div></div>';
  1226. js.tanbody('syscogshow','会话上人员('+this.usershu+')',420,100,{html:s});
  1227. if(!this.userlistarr){
  1228. reim.ajax(reim.getapiurl('reim','getgroupuser'),{type:this.type,gid:this.gid},function(ret){
  1229. me.showusershow(ret.data.uarr);
  1230. },'get');
  1231. }else{
  1232. this.showusershow(this.userlistarr);
  1233. }
  1234. };
  1235. this.showusershow=function(a){
  1236. this.userlistarr = a;
  1237. var i,len=a.length,s='',oi=0;
  1238. s+='<table width="100%"><tr>';
  1239. for(i=0;i<len;i++){
  1240. oi++;
  1241. 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 style="color:#888888">'+a[i].name+'</div></div></td>';
  1242. if(oi%5==0)s+='</tr><tr>';
  1243. }
  1244. s+='</tr></table>';
  1245. $('#showuserlist').html(s);
  1246. };
  1247. this.exitgroups=function(){
  1248. js.msg('wait','退出中...');
  1249. reim.ajax(reim.getapiurl('reim','exitgroup'),{gid:this.gid}, function(da){
  1250. js.msgok('成功退出此会话,无法在此会话发消息了');
  1251. });
  1252. };
  1253. this.contshozt=function(d){
  1254. return strformat.contshozt(d,'web/');
  1255. };
  1256. this.addcont=function(cont, isbf){
  1257. var o = this.showobj;
  1258. if(cont){if(isbf){o.prepend(cont);}else{o.append(cont);}}
  1259. clearTimeout(this.scrolltime);
  1260. this.scrolltime = setTimeout(function(){
  1261. me.scrollboot();
  1262. me._addclickf();
  1263. }, 50);
  1264. };
  1265. //滚动条到最下面
  1266. this.scrollboot=function(){
  1267. this.showobj.animate({scrollTop:get('viewcontent_'+this.num+'').scrollHeight},100);
  1268. };
  1269. this._addclickf=function(){
  1270. var o = this.showobj.find('img[fid]');
  1271. o.unbind('click');
  1272. o.click(function(){
  1273. me.clickimg(this);
  1274. });
  1275. };
  1276. this.clickimg=function(o1){
  1277. var o=$(o1);
  1278. var fid=o.attr('fid');
  1279. var src = o1.src.replace('_s.','.');
  1280. $.imgview({url:src,ismobile:false});
  1281. };
  1282. this.loadmoreda=function(o1){
  1283. this.loaddata(o1, true);
  1284. };
  1285. this.sendcont=function(ssnr){
  1286. if(this.sendbool)return;
  1287. js.msg('none');
  1288. var o = this.inputobj;
  1289. var nr = strformat.sendinstr(o.val());
  1290. nr = nr.replace(/</gi,'&lt;').replace(/>/gi,'&gt;').replace(/\n/gi,'<br>');
  1291. if(ssnr)nr=ssnr;
  1292. if(isempt(nr))return false;
  1293. var conss = jm.base64encode(nr);
  1294. if(conss.length>3998){
  1295. js.msg('msg','发送内容太多了');
  1296. return;
  1297. }
  1298. var nuid= js.now('time'),optdt = js.serverdt();
  1299. if(optdt==this.nowoptdt){
  1300. js.msg('msg','消息发太快了');
  1301. return;
  1302. }
  1303. this.nowoptdt = optdt;
  1304. var cont= strformat.showqp('right','我',optdt, nr, nuid, this.sendinfo.face, nuid);
  1305. this.addcont(cont);
  1306. o.val('').focus();
  1307. this.sendconts(conss, nuid, optdt, 0);
  1308. return false;
  1309. };
  1310. //收到推送消息来了
  1311. this.receivedata=function(d){
  1312. var minid=this.minid;
  1313. reim.ajax(reim.getapiurl('reim','getrecord'),{type:this.type,gid:this.gid,minid:0,lastdt:this.lastdt,loadci:this.loadci},function(ret){
  1314. me.loaddatashow(ret.data, false, true);
  1315. });
  1316. };
  1317. this.onshow=function(){
  1318. if(this.newbool){
  1319. this.scrollboot();
  1320. }
  1321. this.newbool = false;
  1322. };
  1323. this.onkeydown=function(e){
  1324. var code = e.keyCode;
  1325. if(code==13 && !e.ctrlKey){
  1326. this.sendcont();
  1327. return false;
  1328. }
  1329. if(e.altKey && code==83){
  1330. this.sendcont();
  1331. return false;
  1332. }
  1333. if(e.altKey && code==67){
  1334. this.closechat();
  1335. return false;
  1336. }
  1337. if(e.ctrlKey && code==13){
  1338. this.addinput('\n');
  1339. return false;
  1340. }
  1341. return true;
  1342. };
  1343. this.sendconts=function(conss, nuid, optdt, fid){
  1344. this.sendbool = true;
  1345. var d = {cont:conss,gid:this.gid,type:this.type,nuid:nuid,optdt:optdt,fileid:fid};
  1346. reim.ajax(reim.getapiurl('reim','sendinfor'),d,function(ret){
  1347. me.sendsuccess(ret.data,nuid);
  1348. },'post',function(){
  1349. me.senderror(nuid);
  1350. });
  1351. var s1='';
  1352. if(this.type=='group')s1=jm.base64encode(''+adminname+':');
  1353. //显示到会话里
  1354. reim.showhistorys({
  1355. 'cont' : s1+d.cont,
  1356. 'name' : this.receinfo.name,
  1357. 'face' : this.receinfo.face,
  1358. 'optdt' : d.optdt,
  1359. 'type' : this.type,
  1360. 'receid' : this.gid,
  1361. 'stotal' : 0
  1362. }, true, true);
  1363. };
  1364. this.senderror=function(nuid){
  1365. get(nuid).src='images/error.png';
  1366. get(nuid).title='发送失败';
  1367. this.sendbool=false;
  1368. };
  1369. this.sendsuccess=function(d,nuid){
  1370. this.sendbool = false;
  1371. if(!d.id){
  1372. this.senderror(nuid);
  1373. return;
  1374. }
  1375. $('#'+d.nuid+'').remove();
  1376. var bo = false;
  1377. d.messid=d.id;
  1378. d.face = this.sendinfo.face;
  1379. if(this.type=='group')d.gface=this.receinfo.face;
  1380. this.listdata[nuid]=d;
  1381. //添加右键事件
  1382. $('#qipaocont_'+nuid+'').contextmenu(function(e){
  1383. me.contright(this,e);
  1384. return false;
  1385. });
  1386. reim.serversend(d);
  1387. };
  1388. this.addinput=function(s){
  1389. var val = this.inputobj.val()+s;
  1390. this.inputobj.val(val).focus();
  1391. };
  1392. this.closechat=function(){
  1393. if(this.sendbool)return;
  1394. reim.chatobj[this.num]=false;
  1395. reim.closetabs(this.num);
  1396. };
  1397. this.clicktools=function(o1){
  1398. var o = $(o1);
  1399. var lx = o.attr('tools');
  1400. if(lx=='emts')this.getemts(o);
  1401. if(lx=='file')this.sendfile(o);
  1402. if(lx=='paste')this.pasteimg();
  1403. if(lx=='crop')this.cropScreen();
  1404. };
  1405. this.getemts=function(o){
  1406. if(!get('aemtsdiv')){
  1407. var s = '<div id="aemtsdiv" style="width:400px;height:200px;overflow-y:auto;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">';
  1408. s+='<div style="padding:5px">';
  1409. s+=this.getemtsbq('qq',0, 104, 11, 24);
  1410. s+='</div>';
  1411. s+='</div>';
  1412. $('body').append(s);
  1413. js.addbody('emts','hide','aemtsdiv');
  1414. }
  1415. var o1 = $('#aemtsdiv');
  1416. o1.toggle();
  1417. var off = o.offset();
  1418. o1.css({'top':''+(off.top-205)+'px','left':''+(off.left)+'px'});
  1419. };
  1420. this.getemtsbq=function(wj, oi1,oi2, fzd, dx){
  1421. var i,oi=0,j1 = js.float(100/fzd);
  1422. var s = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
  1423. for(i=oi1; i<=oi2; i++){
  1424. oi++;
  1425. 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>';
  1426. if(oi % fzd==0)s+='</tr><tr>';
  1427. }
  1428. s+='</tr></table>';
  1429. return s;
  1430. };
  1431. this.sendfile=function(bo){
  1432. uploadobj.nownum = this.num;
  1433. uploadobj.click();
  1434. };
  1435. this.sendfileshow=function(f){
  1436. f.face = this.sendinfo.face;
  1437. var fa = strformat.showupfile(f);
  1438. var cont= fa.cont;
  1439. this.upfilearr = fa;
  1440. this.addcont(cont);
  1441. };
  1442. this.sendfileok=function(f,str){
  1443. var a=js.decode(str);
  1444. if(!a.id){
  1445. js.msg('msg', str);
  1446. this.senderrornss();
  1447. return;
  1448. }
  1449. var tm= this.upfilearr,conss='';
  1450. f = a;
  1451. strformat.upsuccess(a);
  1452. if(js.isimg(f.fileext)){
  1453. conss = '[图片 '+f.filesizecn+']';
  1454. this._addclickf();
  1455. }else{
  1456. conss = '['+f.filename+' '+f.filesizecn+']'
  1457. }
  1458. this.sendconts(jm.base64encode(conss), tm.nuid, tm.optdt, a.id);
  1459. };
  1460. this.senderrornss=function(){
  1461. this.senderror(this.upfilearr.nuid);
  1462. };
  1463. this.readclip=function(evt){
  1464. var clipboardData = evt.clipboardData;
  1465. if(!clipboardData)return;
  1466. for(var i=0; i<clipboardData.items.length; i++){
  1467. var item = clipboardData.items[i];
  1468. if(item.kind=='file'&&item.type.match(/^image\//i)){
  1469. var blob = item.getAsFile(),reader = new FileReader();
  1470. reader.onload=function(){
  1471. var cont=this.result;
  1472. me.readclipshow(cont);
  1473. }
  1474. reader.readAsDataURL(blob);
  1475. }
  1476. }
  1477. };
  1478. this.readclipshow=function(snr){
  1479. var fa = strformat.showupfile({face:this.sendinfo.face}, snr);
  1480. var cont= fa.cont;
  1481. this._sssnuid = fa.nuid;
  1482. this._sssoptdt = fa.optdt;
  1483. this.upfilearr = fa;
  1484. this.addcont(cont);
  1485. };
  1486. this.sendbase64 = function(strnr){
  1487. uploadobj.nownum = this.num;
  1488. uploadobj.sendbase64(strnr);
  1489. };
  1490. this.clipobj = function(){
  1491. if(!this.clipobj1)this.clipobj1 = nw.Clipboard.get();
  1492. return this.clipobj1;
  1493. };
  1494. this.pasteimg=function(){
  1495. var snr = this.clipobj().get('png');
  1496. //console.log(this.clipobj().readAvailableTypes());
  1497. if(!snr){
  1498. //js.msgerror('剪切板上没有图片');
  1499. return;
  1500. }
  1501. this.readclipshow(snr);
  1502. };
  1503. this.cropScreen=function(){
  1504. this.clipobj().clear();
  1505. jietubool = true;
  1506. im.cropScreen();
  1507. };
  1508. this.filedrop=function(o1){
  1509. uploadobj.nownum = this.num;
  1510. uploadobj.change(o1, 0);
  1511. };
  1512. this.contright=function(o1,e){
  1513. var o=$(o1),rnd=o.attr('rand');
  1514. this.rightqipao(o1,e,rnd);
  1515. };
  1516. this.rightqipao=function(o1,e,rnd){
  1517. if(!this.rightqipaoobj)this.rightqipaoobj=$.rockmenu({
  1518. data:[],
  1519. width:130,
  1520. itemsclick:function(d){
  1521. me.rightqipaoclick(d);
  1522. }
  1523. });
  1524. this.randmess = rnd;
  1525. this.rightdata= this.listdata[rnd];
  1526. var d=[{name:'复制',lx:0},{name:'删除',lx:1}];
  1527. if(this.type=='group')d.push({name:'@TA',lx:3});
  1528. var chehui = reim.showconfigarr.chehui;
  1529. if(o1.className.indexOf('right')>0 && chehui>0){
  1530. var t1 = js.now('time', this.rightdata.optdt),t2 = js.now('time');
  1531. var t3 = (t2-t1)*0.001;
  1532. if(t3<chehui*60)d.push({name:'撤回',lx:2});
  1533. }
  1534. this.rightqipaoobj.setData(d);
  1535. this.rightqipaoobj.showAt(e.clientX,e.clientY);
  1536. };
  1537. this.rightqipaoclick=function(d){
  1538. var lx=d.lx;
  1539. var ids = this.rightdata.id;
  1540. if(lx==0){
  1541. var cont = $('#qipaocont_'+this.randmess+'').text();
  1542. if(cont)js.setcopy(cont);
  1543. }
  1544. if(lx==1){
  1545. $('#ltcont_'+this.randmess+'').remove();
  1546. if(!isNaN(ids)){
  1547. reim.ajax(reim.getapiurl('reim','clearrecord'),{type:this.type,gid:this.gid,ids:ids});
  1548. }
  1549. }
  1550. if(lx==3){
  1551. var cont = $('#ltname_'+this.randmess+'').text();
  1552. if(cont)this.addinput('@'+cont+' ');
  1553. }
  1554. if(lx==2 && !isNaN(ids)){
  1555. var o1dd = $('#qipaocont_'+this.randmess+'')
  1556. o1dd.html(js.getmsg('撤回中...'));
  1557. reim.ajax(reim.getapiurl('reim','chehuimess'),{type:this.type,gid:this.gid,ids:ids}, function(ret){
  1558. o1dd.html(js.getmsg(ret.data.msg1,'green'));
  1559. },'get', function(){
  1560. o1dd.html(js.getmsg('撤回失败','red'));
  1561. });
  1562. }
  1563. };
  1564. this._init();
  1565. }
  1566. //相关回调
  1567. var im = {
  1568. clickqipao:function(o1,e){
  1569. },
  1570. rightqipao:function(o1,e,rnd){
  1571. reim.chatobj[reim.nowtabs].rightqipao(o1,e,rnd);
  1572. },
  1573. backemts:function(s){
  1574. reim.chatobj[reim.nowtabs].addinput(s);
  1575. $('#aemtsdiv').hide();
  1576. },
  1577. sendfileshow:function(f){
  1578. var num = uploadobj.nownum;
  1579. reim.chatobj[num].sendfileshow(f);
  1580. },
  1581. upprogresss:function(per){
  1582. var num = uploadobj.nownum;
  1583. strformat.upprogresss(per);
  1584. },
  1585. sendfileok:function(f,str){
  1586. var num = uploadobj.nownum;
  1587. reim.chatobj[num].sendfileok(f, str);
  1588. },
  1589. senderror:function(){
  1590. var num = uploadobj.nownum;
  1591. reim.chatobj[num].senderrornss();
  1592. },
  1593. readclip:function(num,e){
  1594. reim.chatobj[num].readclip(e);
  1595. },
  1596. upbase64:function(nuid){
  1597. var o = get('jietuimg_'+nuid+'');
  1598. reim.chatobj[reim.nowtabs].sendbase64(o.src);
  1599. },
  1600. cropScreen:function(){
  1601. if(nwjsgui){
  1602. var oatg = nwjs.getpath();
  1603. nw.Shell.openItem(''+oatg+'/images/reimcaptScreen.exe');
  1604. }
  1605. },
  1606. windowfocus:function(){
  1607. if(jietubool){
  1608. reim.chatobj[reim.nowtabs].pasteimg();
  1609. }
  1610. jietubool = false;
  1611. nwjs.jumpclear();
  1612. },
  1613. fileyulan:function(pn,fid){
  1614. var url = '?m=public&a=fileviewer&id='+fid+'';
  1615. js.open(url, 800, 500);
  1616. }
  1617. }
  1618. //下载文件预览的,glx0预览,1下载
  1619. strformat.onopenfile=function(da,glx){
  1620. var url = da.upurl;
  1621. if(glx==0 && da.isimg=='1'){
  1622. strformat.imgview(url);
  1623. }else{
  1624. if(glx==1){
  1625. js.location(url);
  1626. }else{
  1627. js.open(url, 1000,600);
  1628. }
  1629. }
  1630. return true;
  1631. }