reim_xina.js 79 KB

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