纯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 ...
随机推荐
- WPF技术触屏上的应用系列(一): 3D 图片(照片)墙、柱面墙(凹面墙或者叫远景墙、凸面墙或者叫近景墙)实现
原文:WPF技术触屏上的应用系列(一): 3D 图片(照片)墙.柱面墙(凹面墙或者叫远景墙.凸面墙或者叫近景墙)实现 去年某客户单位要做个大屏触屏应用,要对档案资源进行展示之用.客户端是Window7 ...
- MongoDB学习笔记-认识MongoDB
学习参考地址 http://www.runoob.com/mongodb NoSql 流行的数据库Oracle,SqlServer,MySql为关系性数据库,相对的,也有非关系性数据库,统称为NoSq ...
- C++类实现最大数的输出
Description 判断整数的大小,输入n个数,找出最大的数并输出. Input 有多组测试实例,输入n,并输入n个数. Output 输出的最大的数,每个输出结果占一行. Sample Inpu ...
- 得到View Frustum的6飞机
笔者:i_dovelemon 资源:CSDN 日期:2014 / 9 / 30 主题:View Frustum, Plane, View Matrix, Perspective Projection ...
- .NET读写Excel工具Spire.Xls使用(1)入门介绍
原文:[原创].NET读写Excel工具Spire.Xls使用(1)入门介绍 在.NET平台,操作Excel文件是一个非常常用的需求,目前比较常规的方法有以下几种: 1.Office Com组件的方式 ...
- Hadoop之—— CentOS Warning: $HADOOP_HOME is deprecated解
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46389499 启动Hadoop时报了一个警告信息.我安装的Hadoop版本号是ha ...
- MVC5+EF6 入门完整教程 总目录
本系列文章会从一个主干开始,逐渐深入,初步规划30篇.初级10篇,中级10篇,综合项目实战10篇 初级10篇 MVC5+EF6 入门完整教程10:多对多关联表更新&使用原生SQL@201505 ...
- 行政歌节 · 萧谱1
4之前听 陈越 的<绿野仙踪> 版权声明:本文博客原创文章,博客,未经同意,不得转载.
- Swift1_关闭
// main.swift // swift1_关闭 // Created by beyond on 15/6/12. // Copyright (c) 2015年 beyond.com All ri ...
- 玩转Web之JavaScript(二)-----javaScript语法总结(二) 涉及Date与数组的语法
Date: document.write(document.lastModified) 网页最后一次更新时间 a=new Date(); //创建 a 为一个新的时期象 y=a.getY ear( ...