第一步:引入div
<div id="service"></div>
第二步:引入css
<link rel="stylesheet" href="qq.css">
qq.css内容:
body {
background: #f2f2f2;
}
.g-animateBar {
40px;
height: 120px;
position: fixed;
right: 122px;
z-index: 9999;
bottom: 220px;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAB4CAYAAACTp/BuAAABS2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxMzggNzkuMTU5ODI0LCAyMDE2LzA5LzE0LTAxOjA5OjAxICAgICAgICAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIi8+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgo8P3hwYWNrZXQgZW5kPSJyIj8+IEmuOgAABj1JREFUaIHtWz1vo0gYfvZDjHQnqCbSnXCFVqcg3V64BldO5SquslW6/V/7C1J5K3dUS2UqXOFqKk/lqYZqaHJFMrPGxtkZTBKd5EeyIojNPLzf7zvw7uHhAa+E9wA+AUgA/Pv0N/n4Qov9BuDz3mJ/A/h9/4tDEPjjaYGrp08C4C8AH2x+7EKgU4RPBHrjGAFrEZ6KjzhRhKfi3cMrukEX3r/l4mcCZwJnAmcCvQkwxiCEAABIKVFV1csTEEJASgkAKMsSm83GkCmKojcB63ScZRkuLy+RJEnrPOcchBCUZdk6H8cxCCHDETgGIQQIIViv1wAeVRIEAaIoenkCVVVBKYW7uzsQQsA5R5ZluLu7s75Gby9omsboXikFANhut/B93+k6vQlst1sAAKXUEBFCIAiC1yEQhiFub28xHo/BGAPnHIwxRFHkd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wqRPW0LIoiM8CwhZMKlFJmRrSL8XhsRnNCCKd5sTUBPZiazWYHBaduy/M8h1LKKRtaE1BKPTt40LahZ0eDEtCi1+35vhsqpbBcLs30xGVgbWWEdV0bF8zz/GBEo+dHt7e34JyjKArrvQPn5lTXf5pAVVUYjUat8qurkT2ZwEvhzfeOnUY0tkFG9w6DElBKHfR8ui7cr4JcxnUn2YC2ftu434U3t4EzgTOBMwGrOCCE6Kz3dWnWFXTG47FVMLKKhMd2SJ/LeLa7Juds+OYEnPoCxphJQMewu50/OAGNL1++dJ5/tRnRjx8/+vxsOALj8bjzvOu+cW8Cb/r8AICjrZdrY9qbwKnbNCcTcB3FnUxASnkwlDgGxhiklNbTcisCTdMY/eqn53YzXdM0ZgtXSgkp5cFG1jE4JSPd+epx/G5/qB/nury8tH6c04nAfD5HXdeI49jsnO9CP+xWVRUIIdZPVTrtmNhsx+pJ+qt0RkPgzdPxmcCZwJnAmcBHAH/i56t7+s26T3glcu+OROKu1/0+P51/FQJd+IDH1wD3Xw086YVHFwLHoN9X7KXCIQh0wVqFL0WgC7sq/Ofpb/If3xJQQexsAE4AAAAASUVORK5CYII=);
background-repeat: no-repeat;
right: 120px;
}
.g-resetBar {
40px;
height: 126px;
position: fixed;
z-index: 9999;
right: 0px;
bottom: 220px;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAACKCAYAAADc39i1AAABS2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxMzggNzkuMTU5ODI0LCAyMDE2LzA5LzE0LTAxOjA5OjAxICAgICAgICAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLX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+HVBu8GpMBvzK//fmegv8c1Jp5lWUgEgBBxLioFy2cHmzmAedTIFAULJo/n2zxgHjh7LlguC8x9CWUQIAwyzE14AFE3EbyWGxzFVX1YIXHgYaBB2CjQJViR6TL7RRFo9jwPnncjsb+fdF7PgxN1EfYant+H+SqAdBYgouDDzouW4yur9dGwH42yfqTu+jVzcdYP1f8ABUd/GGuZtd4AAAAASUVORK5CYII=);
background-repeat: no-repeat;
display: none;
}
.g-toolsFixed {
120px;
position: fixed;
z-index: 999;
right: 0px;
bottom: 220px;
background: #FFF;
}
.g-toolsFixed p {
background-color: #2D8CF0 !important;
height: 32px;
text-align: center;
line-height: 32px;
margin: 0 0 11px;
}
.g-toolsFixed .u-qq a{
color: #FFF;
font-size: 16px;
text-decoration: none;
}
.g-toolsFixed .u-qq-list {
padding: 0;
padding-top: 6px;
}
.g-toolsFixed ul {
list-style: none;
}
.g-toolsFixed .u-qq-list li{
margin-bottom: 6px;
text-align: center;
line-height: 23px;
height: 25px;
}
.qq_icon {
float: left;
vertical-align: middle;
display: inline-block;
20px;
height: 22px;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAWCAYAAADAQbwGAAABS2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxMzggNzkuMTU5ODI0LCAyMDE2LzA5LzE0LTAxOjA5OjAxICAgICAgICAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIi8+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgo8P3hwYWNrZXQgZ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5yb5uFD4F4axRoWikeTq5UsH3//kHOaMTc89m2kdGKZQ8vBlMwRyU0htgGJIUfQ0+aqDbViEE82Elnawu+cDzqfT+C0LBVut1d+47bGZqRzkCrTfsZpF92+k/Kc/YF8aR61YRm2yjdLEOGIpapsSRJJtWM2tSFsbods7CN+7E44dw1QKEXmC9WvuuBQLhwWQQ93dkt+4RT5saZZ3Qsj5N94QV0QKIjItIkURKYtISURyIlLWWg7s3y+A+A1DgpblWanU2PD0zMwUsGLV9m3oYB1Xjh+lCCxPNGEAYcADtOOgbZuq1rNkiUZpTSYB8Dyv1zCMRmsiM9npQQnIjafT0fgzB7hr+RKq2RxzNm3A8zxc18W9rot4iIBlGHw1MDALK2WsESEMhK6h7JFFC++U6+WKSKVSkbJtS7FUkulCQbJTU5LOZMRxtIyMjkmkfoEAP71mYm67K8YDnSGW3Rr89JO+S/kzvaVNd397o6rxzxJOOxrPE8TzEAS/3080EuHyVYft236Anj75cteDsSd3f7+BlgYLJf++BVp9CpEdOlv83s9+PnjvlLtF7Xz4IPMWdxBrgoavr6cqkJ1w+KLvNG+/fpDW8N859FTyjK85fJRp+SVpL6emj92CXZKgmJQTbaDaPQb/eYUvLkepWiuYk7iT4Wz95yNle7CjpbJldOQjjMpJblucZ+6GuVAwSF+AyknjRwGHV9XkX29GPJQVkofMEI94mvYa04xZdkXbA5lR/7B74snflfe+l4HPnqnpcuLqAV8yPte1aiIzZbdEVca8fuOD/q98z8+EjMx/AVDV7b206tsYAAAAAElFTkSuQmCC);
background-repeat: no-repeat;
margin: 0px 0px 0px 14px;
}
.g-toolsFixed .u-qq-list li a {
display: inline-block;
font-size: 12px;
border: 1px solid #f93f54;
border-radius: 2px;
75px;
height: 22px;
overflow: hidden;
border-color: #2D8CF0 !important;
color: #2D8CF0 !important;
}
第二步:引入js 文件
<script src="qq.js"></script>
qq.js内容:
var service = document.getElementById("service")
var qq = 787592699;
var linkman = '阿三';
var wx = null;
window.onload = function () {
console.log(1);
if (service) {
var outservice_info =
'<div class="service-container">
<div class="g-animateBar"></div>
<div class="g-resetBar"></div>
<div class="g-toolsFixed">
<!-- 咨询客服 QQ -->
<div class="m-showBox u-qq">
<p><a href="javascript:void(0)">咨询客服</a></p>
<ul class="u-qq-list">
<li><div class="qq_icon"></div><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=' + qq + '&site=qq&menu=yes">' + linkman + '</a></li>
</ul>
</div>';
if (wx && wx != '') {
outservice_info += '<div style="padding-top:5px;position: absolute;"><img src="' + wx + '" alt="客服二维码" width="120" height="120"></div>';
}
outservice_info += '</div>
</div>';
service.innerHTML = outservice_info;
}
$(".g-animateBar").click(function () {
var e = $(".g-toolsFixed").width();
$(".g-toolsFixed").animate({right: -e});
$(".g-animateBar").animate({right: -e}, function () {
$(".g-resetBar").show();
});
})
$(".g-resetBar").click(function () {
var e = $(".g-toolsFixed").width();
$(".g-resetBar").hide();
$(".g-toolsFixed").animate({right: 0});
$(".g-animateBar").animate({right: e});
})
}