纯js客服插件集qq、旺旺、skype、百度hi、msn
原文 纯js客服插件集qq、旺旺、skype、百度hi、msn
客服插件,集qq、旺旺、skype、百度hi、msn 等 即时通讯工具,并可自己添加支持的通讯工具,极简主义,用法自己琢磨。我的博客 http://www.qiling.org
<script>
//在线客服插件 powered by casejs 极简主义 http://www.mlrzw.cn
function CaseService(caseServiceConfig) {
this.config = caseServiceConfig;
this.elementId = this.config.elementId ;
this.tpl = {
'qq' : {
'href' : 'http://wpa.qq.com/msgrd?v=3&uin={#account#}&site=qq&menu=yes',
'img' : 'http://wpa.qq.com/pa?p=2:{#account#}:{#style#}&time={#rand#}'
},'wangwang' : {
'href' : 'http://www.taobao.com/webww/ww.php?ver=3&touid={#account#}&siteid=cntaobao&status={#style#}&charset=utf-8',
'img' : 'http://amos.alicdn.com/online.aw?v=2&uid={#account#}&site=cntaobao&s=1&charset=utf-8'
},'skype' : {
'href' : 'skype:{#account#}?call',
'img' : 'http://mystatus.skype.com/smallclassic/{#account#}'
},'baiduhi' : {
'href' : 'baidu://message/?id={#account#}',
'img' : 'http://tieba.baidu.com/tb/img/hi/hiOnline.gif'
},'msn' : {
'href' : 'msnim:chat?contact={#account#}',
'img' : 'http://tieba.baidu.com/tb/img/hi/hiOnline.gif'
}
};
//创建html
this.buildHtml(); //设置关闭
var that = this;
document.getElementById(this.elementId + '_sBtnClose').onclick = function(){
that.hide();
};
//设置打开
document.getElementById(this.elementId + '_sBtnOpenArea').onclick = function(){
that.show();
};
//将html对象赋值给element
this.element = document.getElementById(this.config.elementId);
//判断是否显示
this.config.isOpen ? this.show() : this.hide();
//最后滚动到的位置
this.lastScrollY = 0;
//滚动
this.slide();
}
//显示浮动窗口
CaseService.prototype.show = function() {
document.getElementById(this.elementId + "_sBtnOpenArea").style.display = 'none';
document.getElementById(this.elementId + "_serviceWin").style.display = 'block';
};
//隐藏浮动窗口
CaseService.prototype.hide = function() {
document.getElementById(this.elementId + "_serviceWin").style.display = 'none';
document.getElementById(this.elementId + "_sBtnOpenArea").style.display = 'block';
//如果设置了隐藏的时候关闭 取消事件 并清空 dom
if(this.config.closeAsHide == false){
if(this.interval){
window.clearInterval(this.interval);
}
//清空dom
this.element.innerHTML = '';
}
};
//滚动浮动窗口
CaseService.prototype.slide = function() {
//自动设置 定时事件
if(!this.interval){
var that = this;
this.interval = window.setInterval(function(){
that.slide();
},1);
}
//获取距离顶部的距离
if (document.documentElement && document.documentElement.scrollTop){
var diffY = document.documentElement.scrollTop;
}else{
var diffY = document.body.scrollTop
}
var percent = .1 * ( diffY - this.lastScrollY);
percent = (percent > 0)?Math.ceil(percent):Math.floor(percent);
this.element.style.top = parseInt(this.element.style.top) + percent + "px";
this.lastScrollY += percent;
};
CaseService.prototype.buildHtml = function(){
//设置关闭事件
var accountList = '';
for (i = 0;i < this.config.accountArray.length ; i++ ){
accountList += (function(){/*
<div class="sItem">
<label>{#label#}</label>
<a target="_blank" href="{#href#}" title="{#tip#}">
<img src="{#img#}" alt="{#tip#}" />
</a>
</div>
*/}.toString().replace(/^.+?\*|\\(?=\/)|\*.+?$/gi, ""))
//替换链接和状态图片 必须在前边
.replace(/{#href#}/g , this.tpl[this.config.accountArray[i].type].href)
.replace(/{#img#}/g , this.tpl[this.config.accountArray[i].type].img)
//替换其他参数
.replace(/{#label#}/g , this.config.accountArray[i].label)
.replace(/{#account#}/g , this.config.accountArray[i].account)
.replace(/{#style#}/g , this.config.accountArray[i].style)
.replace(/{#tip#}/g , this.config.accountArray[i].tip)
.replace(/{#rand#}/g , this.config.accountArray[i].rand);
};
var css = (function(){/*
<style type="text/css">
.caseService {font-family:'微软雅黑';text-align: left;}
.caseService .serviceWin {width:168px;height:auto;border:2px solid {#cssColor#};z-index:999999;}
.caseService .sTitle {background:{#cssColor#};padding:8px 10px;font-size:14px;color:#FFF;position:relative}
.caseService .sBtnClose {width: 25px;height: 25px;cursor: pointer;position: absolute;top: 3px;right: 10px;font-size: 25px;line-height: 25px;text-align: right;}
.caseService .sList {font-size: 14px;color: #444;font-size: 13px;line-height: 20px;padding: 10px;background: #FFF}
.caseService .sList .sItem{height:30px}
.caseService .sList label{display:block;width:47%;text-align:right;overflow:hidden;white-space:nowrap;height:30px;float:left}
.caseService .sList a{display:block;width:52%;float:left;overflow:hidden;height:30px;border:0;padding:0;margin:0}
.caseService .sList img{display:inline-block;border:0;padding:0;margin:0}
.caseService .other{border-top:1px dotted #ccc;margin-top:10px;font-size:17px;text-align:center;line-height:28px;padding-top:5px}
.caseService .sBtnOpenArea {background:{#cssColor#};height: auto;padding: 15px 0;width: 31px;display:none;color:#FFF;font-size:15px;text-align:center;line-height:20px;cursor:pointer}
.caseService .sBtnOpen{font-size: 24px;height: 25px;}
</style>
*/}.toString().replace(/^.+?\*|\\(?=\/)|\*.+?$/gi, "")).replace(/{#cssColor#}/g,this.config.color); var tpl = (function(){/*
<div id="{#elementId#}" class="caseService" style="{#style#}" >
<div id="{#elementId#}_sBtnOpenArea" class="sBtnOpenArea">
<div class="sBtnOpen">+</div>
{#closeTitle#}
</div>
<div id="{#elementId#}_serviceWin" class="serviceWin" style="{#width#}">
<div class="sTitle">{#openTitle#}
<div id="{#elementId#}_sBtnClose" class="sBtnClose">×</div>
</div>
<div class="sList">
{#accoundList#}
<div class="other">
{#other#}
</div>
</div>
</div>
</div>
*/}.toString().replace(/^.+?\*|\\(?=\/)|\*.+?$/gi, ""));
//拼接Html
serviceWinTpl = css + tpl
.replace(/{#elementId#}/g,this.config.elementId)
.replace('{#other#}',this.config.other)
.replace('{#accoundList#}',accountList)
.replace('{#width#}',this.config.width)
.replace('{#style#}',this.config.style)
.replace('{#closeTitle#}',this.config.closeTitle)
.replace('{#openTitle#}',this.config.openTitle);
document.write(serviceWinTpl);
}; //在线客服插件 powered by casejs
new CaseService( {
"elementId": "myServiceWin",
"color": "#266ed2",
"openTitle": "客服中心",
"closeTitle": "联<br/>系<br/>我<br/>们",
"style": "right:0px; top:180px;position: absolute;",
"width": "width:170px;",
"isOpen": "true",
"closeAsHide": "true",
"other": "服务热线<br />0546-8238915",
"accountArray": [
{
"type": "qq",
"label": "在线客服:",
"account": "2095128673",
"tip": "客服当前在线,欢迎与我联系",
"style": "1"
},
{
"type": "qq",
"label": "在线客服:",
"account": "1113635625",
"tip": "客服在线",
"style": "1"
},
{
"type": "qq",
"label": "技术QQ:",
"account": "781787584",
"tip": "点击和我联系",
"style": "7"
},
{
"type": "wangwang",
"label": "技术旺旺:",
"account": "炫彩七零",
"tip": "点击与我联系",
"style": "1"
},
{
"type": "msn",
"label": "技术MSN:",
"account": "王磊芝",
"tip": "点击和我联系",
"style": "0"
},
{
"type": "skype",
"label": "Skype:",
"account": "15154625521",
"tip": "我在线请和我联系",
"style": "0"
}
]
} );
</script>
纯js客服插件集qq、旺旺、skype、百度hi、msn的更多相关文章
- 纯js的统计图插件-统计图
第一次写博客,写的不到望大家见谅! 今天给大家分享一个纯js的插件(统计图),有知道的可以在下面评论一起谈论一下,刚学着的时候,我是看了好久才看懂的一个基本结构,到后来我才知道原来直接去原网站上找到复 ...
- QQ客服出现“企业QQ在线咨询无权限在当前场景使用!” 问题
加入了QQ“多客服”功能 会出现这个问题 解决办法: 在平台http://wp.qq.com/ 上设置,只需两步骤 步骤一:在http://wp.qq.com/set.html 里,安全级别选项,选择 ...
- kPagination纯js实现分页插件
kPagination分页插件 纯js分页插件,压缩版本~4kb,样式可以自定义 demo 使用方法 <div id="pagination"></div> ...
- 网页客服思路以及QQ截图粘贴到聊天框功能
功能: 1.客服需登录进入客服页面.用户无需登录,进入用户页面,直接获取sessionId作为id值. 2.用户进入页面并且发送消息时,客服才会获取到该用户,并在左侧列表显示. 3.点击用户名即可切换 ...
- PHP如何使用免费在线客服插件
1 你可以从以下网址下载http://www.hur.cn/Soft/2011/12448.html 2 解压并放到任意文件夹下 3 在安装之前,先在数据库中创建一个完整的数据库,因为待会儿安装完成之 ...
- 微信多客服插件获取openid
<!doctype html> <html> <head> <meta http-equiv="Content-Type" content ...
- js和html插件集
1.UEditor编辑器 UEditor是由百度web前端研发部开发所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点,开源基于MIT协议,允许自由使用和修改代码... 2.echar ...
- vue日历(纯 js,没用任何插件和组件)
效果图: 代码: <template> <div class="calender"> <div class="top"> ...
- js生成qq客服在线代码
说到QQ客服在线代码,随便那么百度谷歌一下就会出来,一般都是 <a target="blank" href="http://wpa.qq.com/msgrd?V=1 ...
随机推荐
- 在borland c++ builder 中使用 google test (gtest)
google test version: 1.6 c++ builder version: xe6 1 download google test 1.6 2 unzip the zip file. T ...
- 制作简易计算器处理过程Servlet
CalculationServlet.java: package com.you.servlet; import java.io.IOException; import java.io.PrintWr ...
- 懒与馋的平衡:餐饮O2O市场广阔,发展不易
餐饮行业是众多行业中O2O起步较早的,现在方兴未艾的团购站点中最先涉足的领域就有餐饮版块.长时间的合作推广,很多餐饮商家已经从中尝到甜头,可以说餐饮行业市场基础培育的比較好,所以餐饮O2O 已经是大势 ...
- cygwin,在win中开发linux程序
cygwin,在win中开发linux程序 http://www.cygwin.cn/site/info/show.php?IID=1001 很多用windows的朋友不习惯于用linux的开发环境 ...
- Windows 8实例教程系列 - 布局控制
原文:Windows 8实例教程系列 - 布局控制 与传统应用类似,Windows store应用允许开发人员通过布局控件管理应用UI. 本篇将讨论Windows8布局设计控制. Windows 8布 ...
- 【网络流量最大流量】poj3281Dining
/* EK算法版本号,哦,慢.....见下文dinic版本号 ----------------------------------------- 最大的问题是网络流量问题 -------------- ...
- mysql5.6设置主从报错1236,Increase max_allowed_packet on master,原因却是Binlog偏移量不对
在试Mysql5.6,搭了个主从: CHANGE MASTER TO MASTER_HOST='1.2.3.4', master_user='slave', master_password='xxxq ...
- 在 Ubuntu 12.04 上安装 GitLab7.x
安装环境: 操作系统: Ubuntu 12.4 LTS 英文 数据库: postgresql webserver: nginx 能够说到7.x的时候,GitLab的文档已经相当完好 ...
- HDU 4946 Area of Mushroom 凸包
链接:pid=4946">http://acm.hdu.edu.cn/showproblem.php?pid=4946 题意:有n个人.在位置(xi,yi),速度是vi,假设对于某个点 ...
- 【高德地图API】从头德国高中生JS API(三)覆盖物——大喊|折线|多边形|信息表|聚合marker|点蚀图|照片覆盖
覆盖物,是一张地图的灵魂.有覆盖物的地图.才是完整的地图.在一张地图上,除了底层的底图(瓦片图,矢量图),控件(有功能可操作的工具).最重要最必不可少的就是覆盖物了.覆盖物有多种.包含.标注.折线.多 ...