纯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 ...
随机推荐
- Cocos-2dx-Lua中使用Luaj的完整示例(转)
如何使用Luaj进行java与Lua之间的交互调用 一.主要分为两个大步骤,Lua工程的修改,android工程的修改 二.工程环境 开发工具:Cocos-Code-IDE Lua版本 : Lua 5 ...
- sql语句中单引号嵌套问题
在sql语句中,我们难免会用到单引号嵌套的时候,但是直接嵌套肯定是不行的,java中用反斜杠做转义符也是不行的,在sql中是用单引号来做转义符的. 比如下面例子是存储过程里查询时的语句示例 exec ...
- 关与 Visual.Assist.X.V10.7.1912的Crack破解补丁(vs 番茄插件的key破解方法)
在win7系统下, 我用的是vs2012版本号. Visual Assist沿用了快10年的界面,最终有了更新,变得更加适合Win8 以及 VS2012的主题风格了 ,这也是以后软件的发展趋势,仅仅是 ...
- 几种流行Webservice控制框架
转会[http://blog.csdn.net/thunder4393/article/details/5787121],写的非常好,以收藏. 1 摘要 开发webservice应用程序中 ...
- NET5 Web应用程序
ASP.NET5 Web应用程序结构 本文参考ASP.NET5 官方文档 Understanding ASP.NET 5 Web Apps,加入了一些个人理解,理解不对的地方希望大家能指出,互相学习. ...
- [渣译文] SignalR 2.0 系列: 支持的平台
原文:[渣译文] SignalR 2.0 系列: 支持的平台 英文渣水平,大伙凑合着看吧,并不是逐字翻译的…… 这是微软官方SignalR 2.0教程Getting Started with ASP. ...
- Libgdx Box2D现实------这缓释微丸(一个:项目介绍)
它花了两个星期的假写物理游戏,在几次课逃逸,是大学,因为大部分时间点!今天,我基本上一直每节课的点1-3有时它,哎,这似乎是不再逃跑.不知道值没有值得,仅仅是简单地想做自己喜欢的事情,而不是跟老师大眼 ...
- POJ 2217 Secretary (后缀数组)
标题效果: 计算两个公共串串最长的字符串的长度. IDEAS: 这两个组合的字符串. 然后直接确定运行后缀数组height 然后,你可以直接扫描一次height .加个是不是在一个串中的推断就能够了. ...
- JAVA Socket传输Object(对象)注意的问题
在java中,可以通过socket将一个对象进行传递,通过ObjectOutputStream,ObjectInputStream来进行写入和读取(具体的方法参考http://blog.csdn.ne ...
- 算法 《霍纳的方法java实践》
[历史背景] 霍纳的方法是中国南宋时期的数学家秦九韶表述求解一元高次多项式的值的算法--正负开方术. 它也能够配合牛顿法用来求解一元高次多项式的根.在西方被称作霍纳算法(Horner algorith ...