1
0

reim_xina.js 76 KB

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