1.html部分
<!--底部咨询-->
<div id='botChatRect'>
<div class='chatZxbox'>
<!--第一部分头部-->
<header class='chatHeader'>
<img src="http://bd.jgyljt.com/jgswt/img/bdjgAddon/heightLine.png" />
<span class='closeChatRect'></span>
<nav>
<p>白癜风专家在线解答</p>
<a href="tel:0551-65692323" class="bdzxTel">
<img src="http://bd.jgyljt.com/jgswt/img/bdjgAddon/addontell.png"> 0551-65692323
</a>
</nav>
</header>
<!--第二部分对话页面的主节点-->
<div id="jgChatMain">
<!--对话聊天记录窗口节点-->
<section class='bdChatKuang' id="jgChatHistory">
<div id='nowChatTime' class='nowChatTime'></div>
<!--自动弹出对话-->
<div class="botKefu botKefu1">
<div class='kefuLeft botDuiImg'>
<img src='http://bd.jgyljt.com/jgswt/img/bdjgAddon/dibuxyh.jpg'>
<!--客服消息模块消息内容-->
<div class="kefuHuida jgLeftMsg">
<i></i>
<p>你好,有什么白斑或白癜风问题,可以咨询我</p>
</div>
</div>
</div>
<div class="botKefu botKefu2">
<div class='kefuLeft botDuiImg'>
<img src='http://bd.jgyljt.com/jgswt/img/bdjgAddon/dibuxyh.jpg'>
<!--客服消息模块消息内容-->
<div class="kefuHuida jgLeftMsg">
<i></i>
<p>先了解你的症状,白斑在哪个部位?</p>
</div>
</div>
</div>
<!--客服消息界面默认-->
<div id="jgNewAgentMsg" class="botKefu" style="display: none;">
<div class="kefuLeft botDuiImg">
<img src="http://bd.jgyljt.com/jgswt/img/bdjgAddon/dibuxyh.jpg" />
<!--客服消息模块消息内容-->
<div class="kefuHuida jgLeftMsg">
<i></i>客服模板隐藏
</div>
</div>
</div>
<!--客户消息界面默认html-->
<div id="jgNewClientMsg" class="botKehu" style="display: none;">
<div class="kehuRight botDuiImg">
<img src="http://bd.jgyljt.com/jgswt/img/bdjgAddon/bdToux.png" />
<!--客户消息模块消息内容-->
<div class="kehuWenti jgRightMsg">
<i></i> 客户模板隐藏
</div>
</div>
</div>
<div style="clear:both;"></div>
<!--显示客服正在输入的特效-->
<div class="botZhengzai" id="jgNewMsgIng" style="display: none;">
<div>
<div class="duihHzImg"><img src="http://bd.jgyljt.com/jgswt/img/bdjgAddon/bdToux.png" /></div>
<div class="duihHzText jgRightMsg"><i></i>客户模板隐藏
</div>
</div>
</div>
</section>
</div>
<!--第三部分底部发送-->
<footer class='chatBottom' id="jgChatDiv">
<div class="chatBotTel">
<a href="tel:0551-62625555"></a>
</div>
<div class='chatFaMsg'>
<!--客户输入的input-->
<input type="text" name="" id="jgChatInput" class="duihIntI" placeholder="请输入您的问题或电话" />
<!--客户输入内容对应的点击发送按钮-->
<input type="submit" id="jgChatSendBut" class="duihIntBtn" onclick="jgSendMsg();return false;" value="发送" />
</div>
<!--再次请求对话的Div模块id-->
<section class="botRechat" id="jgRechat" style="display: none;">
<a class="botRechatZx">
<img src="http://bd.jgyljt.com/jgswt/img/bdjgAddon/zixun.png" /> 继续咨询
</a>
<a href="tel:0551-65692323" class="botRechatTel">
<img src="http://bd.jgyljt.com/jgswt/img/bdjgAddon/tel1.png" /> 电话咨询
</a>
</section>
<!--苹果手机百度浏览器显示-->
<div id="botHideShow">
老牌北大-看白癜风-就是放心
</div>
</footer>
</div>
</div>
<!--底部咨询结束-->
2.css部分
/*底部咨询开始*/
body {
margin: 0 auto;
padding: 0;
}
#botChatRect{
background:#eee;
box-sizing: border-box;
font-size: 0.28rem;
7.5rem;
z-index: 9999999;
position: fixed;
bottom: 0;
left:50%;
margin-left:-3.75rem;
display:none;
}
/*1.咨询头部*/
.chatHeader {
color: #fff;
100%;
height:0.8rem;
background: #393a3f;
position: relative;
top:-0.2rem;
}
.chatHeader>img {
position: absolute;
top: -0.08rem;
100%;
}
.chatHeader .closeChatRect{
line-height:0.8rem;
text-decoration: none;
color: #fff;
text-align:center;
float: left;
1.0rem;
height:0.8rem;
background: url('http://bd.jgyljt.com/jgswt/img/bdjgAddon/wechat.png') no-repeat scroll 20px 11px;
}
.chatHeader nav{
height:0.8rem;
}
.chatHeader nav p{
line-height:0.8rem;
}
.chatHeader .bdzxTel{
position:absolute;
top:0.2rem;
color:#fff;
text-decoration:none;;
right:0.1rem;
}
.bdzxTel img{
vertical-align: middle;
0.42rem;
margin-right: 0.1rem;
float:none;
}
/*2.对话页面*/
.nowChatTime {
font-size:0.28rem;
color: #fff;
text-align: center;
margin-top: 0.1rem;
margin-left: 45%;
border-radius: 3px;
1.0rem;
height:0.5rem;
line-height:0.5rem;
background: #ccc;
overflow: hidden;
}
#jgChatMain{
max-height:9.0rem;
overflow-y:scroll;
background:#eee;
}
.bdChatKuang{
margin-bottom:2.0rem;
}
#jgChatHistory{overflow-y:scroll ;}
.botKefu,
.botKehu {
100%;
overflow: hidden;
min-height:1.2rem;
}
.botDuiImg img{
2.2rem;
}
.botDuiImg>img{
0.8rem;
}
/*2.1左边客服*/
.botKefu1,.botKefu2{
display:none;
}
.kefuHuida,.kehuWenti {
position: relative;
float: left;
max- 64%;
margin: 0.1rem 0.2rem;
padding: 0.1rem 0.2rem;
border: 1px solid #ccc;
line-height:0.4rem;
background: #fff;
border-radius:5px;
}
.kefuLeft img{
float:left;
margin-left:0.2rem;
}
.kefuHuida i {
position: absolute;
top:0.1rem;
left: -0.18rem;
0.2rem;
height:0.2rem;
background:url('http://bd.jgyljt.com/jgswt/img/bdjgAddon/wechat.png') no-repeat scroll 0 -200px;
transform:rotate(-180deg);
}
.kefuHuida p {
line-height: 0.4rem;
display: block;
-webkit-margin-before: 0px;
-webkit-margin-after: 0px;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
margin:0!important;
}
.kefuHuida strong font,
.kefuHuida strong,
.kefuHuida span font {
font-weight: lighter;
}
.kefuHuida font,.kefuHuida div {
font-size: 0.28rem!important;
font-family: "Microsoft YaHei"!important;
}
.kefuHuida button{
background:#f59f2f;
color:#fff;
border:none;
border-radius:5px;
padding:0.1rem;
}
/*2.2右边客户*/
.kehuWenti {
float: right;
}
.kehuRight img{
float: right;
margin-right: 0.2rem;
}
.kehuWenti i {
position: absolute;
top:0.1rem;
right: -0.2rem;
0.2rem;
height:0.2rem;
background:url('http://bd.jgyljt.com/jgswt/img/bdjgAddon/wechat.png') no-repeat scroll 0 -200px;
}
/*2.3再次请求对话*/
.botRechat{
position:absolute;
top: 0;
7.5rem;
height: 0.9rem;
}
.botRechatZx{
display: inline-block;
50%;
text-align: center;
line-height: 0.9rem;
color: #FFFFFF;
float: left;
background: #ff6005;
}
.botRechatZx img{
vertical-align: middle;
0.46rem;
margin-right: 0.1rem;
}
.botRechatTel{
text-decoration:none;
display: inline-block;
50%;
text-align: center;
line-height: 0.9rem;
color: #FFFFFF;
float: left;
background: #26c540;
}
.botRechatTel img{
vertical-align: middle;
0.46rem;
margin-right: 0.1rem;
}
/*3.底部输入*/
.chatBottom {
100%;
bottom: 0;
position: absolute;
background: #FFF;
border-top: 1px solid #bfbfbf;
}
.chatBottom .chatBotTel a {
float: left;
15%;
height:1.1rem;
background:url('http://bd.jgyljt.com/jgswt/img/bdjgAddon/wechat.png') no-repeat scroll 9px -89px;
}
/*底部输入文字*/
#jgChatInput {
outline: none;
65%;
height:0.6rem;
margin-top:0.2rem;
border: none;
border-bottom: 1px solid #ccc;
}
#jgChatSendBut {
outline: none;
18%;
height:0.6rem;
margin-top:0.2rem;
color: #fff;
font-size: 0.3rem;
background: #009944;
border: none;
border-radius:5px;
}
/*苹果手机百度浏览器显示*/
#botHideShow{
display:none;
100%;
height:1.0rem;
line-height:1.0rem;
text-align: center;
color: #094eaa;
font-size: 0.28rem;
background: #ebf3fb;
}
3.js部分
<script>
/*获取时间开始*/
var chatTimeNow = new Date();
var chatTimeH = chatTimeNow.getHours();
var chatTimeM = chatTimeNow.getMinutes();
var nowChatTime = document.getElementById("nowChatTime");
getChatTime = function(obj) {
if(obj < 10) return "0" + obj;
else return obj;
}
nowChatTime.innerHTML = getChatTime(chatTimeH) + ":" + getChatTime(chatTimeM);
/*获取时间结束*/
/*定时显示对话框*/
var showBotChat = function(num) {
setTimeout(function() {
$('#botChatRect').show();
}, 2000 + 1000 * num);
if(!localStorage.getItem('jgClientMsgCnt')) {
setTimeout(function() {
$('.botKefu1').show();
}, 3000 + 1000 * num);
setTimeout(function() {
$('.botKefu2').show();
}, 4000 + 1000 * num);
}
}
var clickNum = 1;
showBotChat(clickNum);
/*关闭对话框按钮*/
$('.closeChatRect').on('click', function() {
clickNum++;
$('#botChatRect').hide();
$('.botKefu1').hide();
$('.botKefu2').hide();
showBotChat(clickNum);
})
/*触摸上拉对话框开始*/
var botChatSlide = document.querySelector('#botChatRect header');
var botChatRect = document.querySelector('#botChatRect');
//获取设备高度
var deviceHei = document.documentElement ? document.documentElement.clientHeight : document.body.clientHeight;
//绑定事件
botChatSlide.ontouchstart = function(ev) {
/*计算手指刚触摸时的y坐标*/
var beiginY = ev.targetTouches[0].clientY;
/*盒子原来的高度*/
var firstHei = parseInt(window.getComputedStyle(botChatRect).height);
this.ontouchmove = function(ev) {
/*计算手指滑动时的y坐标*/
var endY = ev.targetTouches[0].clientY
/*计算滑动了多少距离*/
var moveY = (beiginY - endY);
//限制高度
if(((firstHei + moveY) > 250) && ((firstHei + moveY) < (deviceHei * 0.8))) {
/*盒子动态变高度*/
botChatRect.style.height = firstHei + moveY + "px";
document.querySelector('#jgChatHistory').style.height = firstHei + moveY - 120 + "px";
setTimeout(jgScrollPage, 300);
}
}
}
botChatSlide.touchend = function() {
this.ontouchmove = function() {
}
}
/*触摸上拉对话框结束*/
/*苹果百度浏览器*/
if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent) && /baiduboxapp/i.test(navigator.userAgent)) {
setTimeout(function() {
document.querySelector('#botHideShow').style.display = 'block';
}, 30);
}
/*咨询对话开始*/
jgSwtConfig.ignoreWelcome = 2; // 忽略咨询开场白
var myDate = new Date();
var jgJump = false;
if(jgSwtConfig.nightHour > 8) {
jgJump = myDate.getHours() >= jgSwtConfig.nightHour || myDate.getHours() < jgSwtConfig.dayHour;
} else {
jgJump = myDate.getHours() >= jgSwtConfig.nightHour && myDate.getHours() < jgSwtConfig.dayHour;
}
if(jgJump) {
jgSendMsg = function() {
window.location = jgSwtConfig.yejianUrl;
}
} else {
var script = document.createElement('script');
script.src = jgSwtConfig.server + '/jgswt/chat.js';
script.id = 'chatjs';
document.body.appendChild(script);
}
/*咨询对话结束*/
</script>