You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
4.2 KiB
107 lines
4.2 KiB
{layout name="public/layout" /}
|
|
<style>
|
|
.chatcontent p{padding:0px 8px !important;margin:0px !important;font-size:1.2rem !important;line-height:1.8rem !important;}
|
|
.chatcontent .title{font-size:1.4rem !important;;line-height:1.8rem !important;margin:10px 0px;display:block;}
|
|
.chatcontent img{max-width:100%;}
|
|
</style>
|
|
<div class="chatbox">
|
|
<div class="container">
|
|
<ul class="chatlist">
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="chatinput">
|
|
<div class="input">
|
|
<input type="text" name="word" id="word">
|
|
</div>
|
|
<div class="button">
|
|
<button id="send">发送</button>
|
|
</div>
|
|
</div>
|
|
<script src="{$yf_theme_path}public/js/layer/layer.js"></script>
|
|
<script>
|
|
var catehtml='';
|
|
var qlist=[];
|
|
var rlist=[];
|
|
var first=true;
|
|
function getTime(){
|
|
var myDate=new Date();
|
|
return myDate.getHours()+":"+myDate.getMinutes();
|
|
}
|
|
|
|
function scrollToEnd(){
|
|
var h = $(document).height()-$(window).height();
|
|
$('html,body').animate({scrollTop:h},800);
|
|
}
|
|
function postHistory(fields){
|
|
var url="{:url('bbs/history',['uid'=>$uid,'type'=>$type])}";
|
|
$.post(url,fields,function(data){});
|
|
}
|
|
function getlogs(){
|
|
var url="{:url('bbs/ajaxchat',['uid'=>$uid,'type'=>$type])}";
|
|
$.get(url,function(data){
|
|
var res=data.data;
|
|
if(res.length){
|
|
var html='';
|
|
res.forEach(function(item,key){
|
|
var poster=item.poster;
|
|
if(typeof poster=='undefined'||poster==''){
|
|
poster="{$yf_theme_path}/public/img/peo.png";
|
|
}
|
|
{if condition="$type eq 'replay'"}
|
|
if(typeof item.ques!='undefined'&&item.ques){
|
|
html+='<li class="chatitem right"><div class="chatbody"><span class="datetime">'+item.nickname+','+item.time+'<i class="zmdi zmdi-check-all text-primary"></i></span>';
|
|
html+='<div class="msgrow "><div class="chatcontent">'+item.ques+'</div></div></div></li>';
|
|
}
|
|
if(typeof item.ans!='undefined'&&item.ans){
|
|
html+='<li class="chatitem "><div class="avatar"><img src="'+poster+'" οnerrοr="javascript:this.src=\'{$yf_theme_path}/public/img/peo.png\';" /></div>';
|
|
html+='<div class="chatbody"><span class="datetime">'+item.nickname+','+item.time+'</span><div class="msgrow"><div class="chatcontent">'+item.ans+'</div></div></div></li>';
|
|
}
|
|
{else}
|
|
if(typeof item.ques!='undefined'&&item.ques){
|
|
html+='<li class="chatitem "><div class="avatar"><img src="'+poster+'" οnerrοr="javascript:this.src=\'{$yf_theme_path}/public/img/peo.png\';" /></div>';
|
|
html+='<div class="chatbody"><span class="datetime">'+item.nickname+','+item.time+'</span><div class="msgrow"><div class="chatcontent">'+item.ques+'</div></div></div></li>';
|
|
}
|
|
if(typeof item.ans!='undefined'&&item.ans){
|
|
html+='<li class="chatitem right"><div class="chatbody"><span class="datetime">'+item.nickname+','+item.time+'<i class="zmdi zmdi-check-all text-primary"></i></span>';
|
|
html+='<div class="msgrow "><div class="chatcontent">'+item.ans+'</div></div></div></li>';
|
|
}
|
|
{/if}
|
|
});
|
|
$(".chatlist").html(html);
|
|
}
|
|
scrollToEnd();
|
|
});
|
|
}
|
|
$(function(){
|
|
getlogs();
|
|
setInterval(function(){
|
|
getlogs();
|
|
},20000);
|
|
$("#send").click(function(){
|
|
var index=layer.load(1, {shade: [0.1,'#fff']});
|
|
var word=$("#word").val();
|
|
word=word.trim();
|
|
if(typeof word=='undefined'||word==''){
|
|
return false;
|
|
}
|
|
var poster="{$poster}";
|
|
if(typeof poster=='undefined'||poster==''){
|
|
poster="{$yf_theme_path}/public/img/peo.png";
|
|
}
|
|
var html='<li class="chatitem"><div class="avatar"><img src="'+poster+'" οnerrοr="javascript:this.src=\'{$yf_theme_path}/public/img/peo.png\';" /></div><div class="chatbody"><span class="datetime">{$nickname},'+getTime()+'<i class="zmdi zmdi-check-all text-primary"></i></span>';
|
|
html+='<div class="msgrow "><div class="chatcontent">'+word+'</div></div></div></li>';
|
|
|
|
$(".chatlist").append(html);
|
|
scrollToEnd();
|
|
$("#word").val('');
|
|
layer.close(index);
|
|
{if condition="$type eq 'replay'"}
|
|
postHistory({'ans':word});
|
|
{else}
|
|
postHistory({'ques':word});
|
|
{/if}
|
|
});
|
|
});
|
|
</script>
|