信呼OA版本v2.3.8
This commit is contained in:
257
webmain/we/chat/chat.js
Normal file
257
webmain/we/chat/chat.js
Normal file
@@ -0,0 +1,257 @@
|
||||
var im={
|
||||
minid:999999999,
|
||||
init:function(){
|
||||
strformat.emotspath='web/';
|
||||
this.type = receinfor.type;
|
||||
this.gid = receinfor.gid;
|
||||
this.showobj = $('#showview');
|
||||
this.inputobj = $('#contentss');
|
||||
$('#btn').click(function(){
|
||||
im.sendcont();
|
||||
});
|
||||
this.loaddata();
|
||||
this.readinforshow();
|
||||
|
||||
im.touchobj = $('#showview').rockdoupull({
|
||||
downbgcolor:'',
|
||||
downbool:true,
|
||||
ondownsuccess:function(){
|
||||
im.dropdown_success();
|
||||
}
|
||||
});
|
||||
this.resizehei();
|
||||
$(window).resize(this.resizehei);
|
||||
},
|
||||
submitinput:function(){
|
||||
try{im.sendcont();}catch(e){}
|
||||
return false;
|
||||
},
|
||||
getheight:function(ss){
|
||||
var hei = 50;if(!ss)ss=0;
|
||||
if(get('header_title'))hei+=50;
|
||||
return $(window).height()-hei+ss;
|
||||
},
|
||||
resizehei:function(){
|
||||
var h = im.getheight();
|
||||
im.showobj.css('height',''+h+'px');
|
||||
im.touchobj.resize();
|
||||
},
|
||||
loaddata:function(o1, iref){
|
||||
if(this.boolload)return;
|
||||
var iref = (!iref)?false:true;
|
||||
var minid= 0;
|
||||
if(iref)minid=this.minid;
|
||||
if(o1)$(o1).html('<img src="images/loadings.gif" height="14" width="15" align="absmiddle"> 加载中...');
|
||||
this.boolload = true;
|
||||
this.isshangla = false;
|
||||
js.ajax('reim','getrecord',{type:this.type,gid:this.gid,minid:minid,lastdt:''},function(ret){
|
||||
if(o1)$(o1).html('');
|
||||
im.boolload = false;
|
||||
im.loaddatashow(ret, iref);
|
||||
},'none', false,false,'get');
|
||||
},
|
||||
readinforshow:function(){
|
||||
setTimeout('im.readinforshows()',1000*10);
|
||||
},
|
||||
readinforshows:function(){
|
||||
var minid=this.minid;
|
||||
js.ajax('reim','getrecord',{type:this.type,gid:this.gid,minid:0,lastdt:this.lastdt},function(ret){
|
||||
im.loaddatashow(ret, false, true);
|
||||
im.readinforshow();
|
||||
},'none', false,false,'get');
|
||||
},
|
||||
loaddatashow:function(ret,isbf, isls){
|
||||
var a = ret.rows;
|
||||
this.lastdt = ret.nowdt;
|
||||
var i,len = a.length,cont,lex,nas,fase,nr,d,na=[],rnd,sid;
|
||||
$('#loadmored').remove();
|
||||
if(isbf){
|
||||
if(len>0)this.showobj.prepend('<div class="showblanks">---------↑以上是新加载---------</div>');
|
||||
na = a;
|
||||
}else{
|
||||
for(i= len-1; i>=0; i--)na.push(a[i]);
|
||||
}
|
||||
for(i= 0; i<len; i++){
|
||||
d = na[i];
|
||||
sid = parseFloat(d.id);
|
||||
lex = 'right';
|
||||
nas = '我';
|
||||
fase= adminface;
|
||||
if(d.sendid!=adminid){
|
||||
lex='left';
|
||||
nas= d.sendname;
|
||||
fase= d.face;
|
||||
}
|
||||
nr = this.contshozt(d.filers);
|
||||
if(nr=='')nr= jm.base64decode(d.cont);
|
||||
rnd = 'mess_'+sid+'';
|
||||
cont= strformat.showqp(lex,nas,d.optdt,nr ,'', fase, rnd);
|
||||
if(!isbf){
|
||||
this.addcont(cont, isbf);
|
||||
}else{
|
||||
this.showobj.prepend(cont);
|
||||
}
|
||||
if(sid<this.minid)this.minid=sid;
|
||||
}
|
||||
if(len>0 && !isls){
|
||||
var s = '<div id="histordiv" class="showblanks" >';
|
||||
if(ret.wdtotal==0){
|
||||
s+='---------↑以上是历史记录---------';
|
||||
if(len>=5){
|
||||
//this.showobj.prepend('<div id="loadmored" class="showblanks" ><a href="javascript:;" onclick="im.loadmoreda(this)">点击加载更多...</a></div>');
|
||||
this.isshangla = true;
|
||||
}
|
||||
}else{
|
||||
s+='---↑以上是历史,还有未读信息'+ret.wdtotal+'条,<a href="javascript:;" onclick="im.loaddata(this)">点击加载</a>---';
|
||||
}
|
||||
s+='</div>';
|
||||
if(!isbf)this.addcont(s);
|
||||
if(isbf)this._addclickf();
|
||||
}
|
||||
if(im.touchobj)im.touchobj.ondownok();
|
||||
},
|
||||
dropdown_success:function(){
|
||||
if(this.isshangla){
|
||||
this.loadmoreda(false);
|
||||
}else{
|
||||
setTimeout(function(){im.touchobj.ondownok()},1000);
|
||||
}
|
||||
},
|
||||
loadmoreda:function(o1){
|
||||
this.loaddata(o1, true);
|
||||
},
|
||||
addcont:function(cont, isbf){
|
||||
var o = this.showobj;
|
||||
if(cont){if(isbf){o.prepend(cont);}else{o.append(cont);}}
|
||||
clearTimeout(this.scrolltime);
|
||||
this.scrolltime = setTimeout(function(){
|
||||
im.showobj.animate({scrollTop:get('showview').scrollHeight},100);
|
||||
im._addclickf();
|
||||
}, 50);
|
||||
},
|
||||
_addclickf:function(){
|
||||
var o = this.showobj.find('img[fid]');
|
||||
o.unbind('click');
|
||||
o.click(function(){
|
||||
im.clickimg(this);
|
||||
});
|
||||
},
|
||||
clickimg:function(o1){
|
||||
var o=$(o1);
|
||||
var fid=o.attr('fid');
|
||||
var src = o1.src.replace('_s.','.');
|
||||
$.imgview({url:src,ismobile:true});
|
||||
},
|
||||
contshozt:function(d){
|
||||
return strformat.contshozt(d,'web/');
|
||||
},
|
||||
sendcont : function(ssnr){
|
||||
if(js.ajaxbool)return;
|
||||
js.msg('none');
|
||||
var o = this.inputobj;
|
||||
var nr = strformat.sendinstr(o.val());
|
||||
nr = nr.replace(/</gi,'<').replace(/>/gi,'>').replace(/\n/gi,'<br>');
|
||||
if(ssnr)nr=ssnr;
|
||||
if(isempt(nr))return false;
|
||||
var conss = jm.base64encode(nr);
|
||||
if(conss.length>500){
|
||||
js.msg('msg','发送内容太多了');
|
||||
return;
|
||||
}
|
||||
var nuid= js.now('time'),optdt = js.serverdt();
|
||||
var cont= strformat.showqp('right','我',optdt, nr, nuid, adminface);
|
||||
this.addcont(cont);
|
||||
o.val('').focus();
|
||||
this.sendconts(conss, nuid, optdt, 0);
|
||||
return false;
|
||||
},
|
||||
sendconts:function(conss, nuid, optdt, fid){
|
||||
var d = {cont:conss,gid:this.gid,type:this.type,nuid:nuid,optdt:optdt,fileid:fid};
|
||||
js.ajax('reim','sendinfor',d,function(ret){
|
||||
im.sendsuccess(ret,nuid);
|
||||
},'none',false,function(){
|
||||
im.senderror(nuid);
|
||||
});
|
||||
},
|
||||
senderror:function(nuid){
|
||||
js.ajaxbool = false;
|
||||
get(nuid).src='images/error.png';
|
||||
get(nuid).title='发送失败';
|
||||
},
|
||||
sendsuccess:function(d,nuid){
|
||||
this.bool = false;
|
||||
if(!d.id){
|
||||
this.senderror(nuid);
|
||||
return;
|
||||
}
|
||||
$('#'+d.nuid+'').remove();
|
||||
var bo = false;
|
||||
d.messid=d.id;
|
||||
d.face = adminface;
|
||||
},
|
||||
addinput:function(s){
|
||||
var val = this.inputobj.val()+s;
|
||||
this.inputobj.val(val).focus();
|
||||
},
|
||||
showemit:function(){
|
||||
var da = [];
|
||||
var a = strformat.emotsarr,i;
|
||||
for(i=1;i<50;i++)da.push({name:' <img src="web/images/im/emots/qq/'+(i-1)+'.gif" align="absmiddle"> '+a[i], num:a[i]});
|
||||
js.showmenu({
|
||||
data:da,width:150,align:'left',
|
||||
onclick:function(d){
|
||||
im.addinput(d.num);
|
||||
}
|
||||
});
|
||||
},
|
||||
sendfile:function(){
|
||||
if(typeof(uploadobj)=='undefined')uploadobj = $.rockupload({
|
||||
inputfile:'allfileinput',
|
||||
updir:'reimchat',
|
||||
urlparams:{noasyn:'yes'}, //不需要同步到文件平台上
|
||||
initpdbool:true,
|
||||
onchange:function(d){
|
||||
im.sendfileshow(d);
|
||||
},
|
||||
onprogress:function(f,per,evt){
|
||||
strformat.upprogresss(per);
|
||||
},
|
||||
onsuccess:function(f,str,o1){
|
||||
im.sendfileok(f,str);
|
||||
},
|
||||
onerror:function(str){
|
||||
js.msg('msg', str);
|
||||
im.senderror(im.upfilearr.nuid);
|
||||
}
|
||||
});
|
||||
strformat.upobj = uploadobj;
|
||||
uploadobj.click();
|
||||
},
|
||||
sendfileshow:function(f){
|
||||
f.face = adminface;
|
||||
var fa = strformat.showupfile(f);
|
||||
var cont= fa.cont;
|
||||
this.upfilearr = fa;
|
||||
this.addcont(cont);
|
||||
},
|
||||
sendfileok:function(f,str){
|
||||
var tm= this.upfilearr,conss='';
|
||||
var a = js.decode(str);
|
||||
a.isimg = f.isimg;
|
||||
strformat.upsuccess(a);
|
||||
if(f.isimg){
|
||||
conss = '[图片 '+a.filesizecn+']';
|
||||
}else{
|
||||
conss = '['+f.filename+' '+f.filesizecn+']'
|
||||
}
|
||||
this.sendconts(jm.base64encode(conss), tm.nuid, tm.optdt, a.id);
|
||||
},
|
||||
fileyulan:function(pn,fid){
|
||||
var url = '?m=public&a=fileviewer&id='+fid+'';
|
||||
js.location(url);
|
||||
}
|
||||
}
|
||||
|
||||
strformat.clickfile=function(fid,lx){
|
||||
js.fileopt(fid,lx);
|
||||
}
|
||||
21
webmain/we/chat/chatAction.php
Normal file
21
webmain/we/chat/chatAction.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
class chatClassAction extends ActionNot{
|
||||
|
||||
public function initAction()
|
||||
{
|
||||
$this->mweblogin(0, true);
|
||||
}
|
||||
|
||||
public function defaultAction()
|
||||
{
|
||||
//if(getconfig('platdwnum'))return '平台模式请使用REIM通信平台会话';
|
||||
$type = $this->get('type');
|
||||
$uid = (int)$this->get('uid');
|
||||
$db = m('reim');
|
||||
$arr = $db->getreceinfor($type, $uid);
|
||||
if(!isset($arr['name']))exit('error');
|
||||
$this->title = $arr['name'];
|
||||
if(isset($arr['utotal']))$this->title.='('.$arr['utotal'].')';
|
||||
$this->assign('arr', $arr);
|
||||
}
|
||||
}
|
||||
69
webmain/we/chat/tpl_chat.html
Normal file
69
webmain/we/chat/tpl_chat.html
Normal file
@@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
|
||||
<title><?=$da['title']?></title>
|
||||
<link rel="stylesheet" type="text/css" href="mode/weui/weui.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="web/res/fontawesome/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="webmain/css/rui.css">
|
||||
<link rel="stylesheet" type="text/css" href="web/res/css/chat.css">
|
||||
<script type="text/javascript" src="js/jquery.js"></script>
|
||||
<script type="text/javascript" src="js/js.js"></script>
|
||||
<script type="text/javascript" src="js/jswx.js"></script>
|
||||
<script type="text/javascript" src="js/base64-min.js"></script>
|
||||
<script type="text/javascript" src="web/res/js/strformat.js"></script>
|
||||
<script type="text/javascript" src="webmain/we/chat/chat.js"></script>
|
||||
<script type="text/javascript" src="mode/plugin/jquery-rockdoupull.js"></script>
|
||||
<style>
|
||||
body,html{background-color:#f1f1f1;overflow:hidden}
|
||||
.showblanks{padding:10px;color:#aaaaaa;font-size:12px;text-align:center}
|
||||
.qipao .qipaocont{font-size:16px}
|
||||
.qipao .qipaoface{}
|
||||
<?php
|
||||
$maincolor = getconfig('apptheme','#1389D3');
|
||||
$maincolora= c('image')->colorTorgb($maincolor);
|
||||
$maincolors= ''.$maincolora[0].','.$maincolora[1].','.$maincolora[2].'';
|
||||
echo 'body{--main-color:'.$maincolor.'}.qipao .qipaocontright{background:rgba('.$maincolors.',0.4)}.qipao .qipaoright{border-color: transparent transparent transparent rgba('.$maincolors.',0.4)}';
|
||||
?>
|
||||
</style>
|
||||
<script>
|
||||
ismobile = 1;
|
||||
var receinfor=<?=json_encode($arr)?>;
|
||||
function initbody(){
|
||||
adminid = js.getoption('adminid');
|
||||
adminface = js.getoption('adminface','images/noface.png');
|
||||
adminame = js.getoption('adminame','我');
|
||||
im.init();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<?php if($showheader==1){?>
|
||||
<div>
|
||||
<div class="r-header">
|
||||
<div onclick="location.reload()" id="header_title" class="r-header-text"><?=$da['title']?></div>
|
||||
<span onclick="js.back()" class="r-position-left r-header-btn"><i class="icon-chevron-left"></i></span>
|
||||
</div>
|
||||
<div class="blank50"></div>
|
||||
</div>
|
||||
<?php }?>
|
||||
|
||||
<div class="r-touch" style="height:300px;" id="showview"></div>
|
||||
|
||||
<div class="blank50"></div>
|
||||
<div class="r-chat r-border-t">
|
||||
<form onsubmit="return im.submitinput()">
|
||||
<table cellspacing="0" cellpadding="0" width="100%"><tr>
|
||||
<td style="padding-left:10px"><i style="color:#888888;font-size:20px" class="icon-folder-close" onclick="im.sendfile()"></td>
|
||||
<td width="100%" style="padding:10px"><input autocomplete="off" maxlength="500" type="text" id="contentss" class="r-chat-input"></td>
|
||||
<td style="padding-right:10px"><i style="color:#888888;font-size:24px" class="icon-heart" onclick="im.showemit();return false;"></td>
|
||||
<td style="padding-right:10px"><button style="border-radius:5px" type="button" id="btn" class="r-chat-btn r-btn-active" value="">发送</button></td>
|
||||
</tr></table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="web/res/js/jquery-imgview.js"></script>
|
||||
<script type="text/javascript" src="web/res/js/jquery-rockupload.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user