reim_xina.js 81 KB

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