12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391 |
- (function($){
-
- var $this;// this对象
- var phoneArray = new Array();
- var othendn = "";
- var interval;
- //软电话核心对象
- qlSoftPhone = {
- init: function(options) {
- var o = $.extend({
- host: "http://localhost",
- contentPath:"",
- agentId:"",
- agentName:"",
- extension:"",
- password:"null",
- url:"",
- autoLogin:false,
- isDefaultSkill:true,//是否默认一个技能组
- isDisableAcw:false,//是否禁用后处理操作
- hangupTransferSatis:false,//是否挂机转满意度
- autoEndWrapUpTime:-1,//自动结束后处理时间(单位:毫秒),-1时则不自动结束后处理
- softPhoneType:"",
- marginBottom:0,//底部间距
- marginTop:0,//顶部间距
- marginLeft:0,//顶部间距
- tenant:"tenant1",// 租户
- platformFlag:"aspect", //平台名称,华为:huawei,Aspect:aspect,Awaya:awaya,思科:cisco, 中兴:zte
- platformVersion:"",// 平台版本号
- agentType:"common",// 座席类型 (common:普通座席, manager:管理员)
- skillGroupCode:"-1",// 技能组编号
- skillGroupName:"默认技能组", // 技能组名称
- consultativeGroup :"{\"-1\":\"默认技能组\"}", // 可咨询组
- transferGroup :"{\"-1\":\"默认技能组\"}", // 可咨询组
- manageGroup:"{\"-1\":\"默认技能组\"}",//可管理组
- isGetEvent:"false",//是否开始轮询
- ejectScreen: function(data) {},//连接服务器成功回调事件
- onDial: function(extension,phone,bussiness) {}, //外呼成功回调事件
- onCall: function(data) {}, //接通成功回调事件
- onWrapUp: function(data){},//后处理事件
- wrapUp: function(data) {},
- hangUp: function(data) {},
- addRecord: function(data) {},//挂断成功回调事件
- logout:function(data){},
- logOff:function(data){},//登出事件回调
- login:function(data){},// 登录事件回调
- notReady:function(data){},// 未就绪事件回调
- ready:function(data){},// 就绪事件回调
- hold:function(data){},// 保持事件回调
- consultDial:function(data){},// 咨询外呼事件回调
- consult:function(data){},// 咨询接通事件回调
- conference:function(data){}, // 会议事件回调
- error:function(data){}// 错误事件回调
- }, options );
-
- //组装软电话中间件URL
- if(o.url === "") o.url = o.host+o.contentPath;
-
- $this = this;
-
- $this.data('softphones', o).addClass("softPhoneTopBox").html(softTopObj.initSoftPage());
-
-
- if(o.extension != ""){
- $("input[name='softExtensionIpt']").val(o.extension);
- }
- if(o.agentId != ""){
- $("input[name='softAgentIpt']").val(o.agentId);
-
- //开始登录
- if(o.autoLogin){
- $("input[name='softAgentIpt']").attr("disabled",true);
- $("input[name='softExtensionIpt']").attr("disabled",true);
- $(".loginInf .loginBtn").addClass("dis");
- $(".status-text").text("登录中");
- $(".timing").text("00:00:00");
- qlSoftPhone.login();
- }
- }
-
-
- //登录绑定事件
- $(".loginInf .loginBtn").bind("click",function(){
- if($(this).hasClass("dis")) return false;
-
- o.agentId = $("input[name='softAgentIpt']").val().trim();
- o.agentName = $("input[name='softAgentIpt']").val().trim();
- o.extension = $("input[name='softExtensionIpt']").val().trim();
-
- //如果默认密码,则密码和工号一样
- if(o.password == 'null') o.password=o.agentId;
-
- $this.data('softphones', o)
- if(o.agentId==""){
- alert("请输入工号!");
- return false;
- }
- if(o.extension==""){
- alert("请输入分机!");
- return false;
- }
-
- //开始登录
- $(".loginInf .loginBtn").addClass("dis");
- $(".status-text").text("登录中");
- $(".timing").text("00:00:00");
- qlSoftPhone.login();
- });
-
- //绑定登出事件
- $(".loginInf .logOffBtn").bind("click",function(){
- if($(this).hasClass("dis")) return false;
- qlSoftPhone.logOff();
- });
-
- //电话历史委派事件
- $(".telRecordBox").delegate(".make-call-history", "click", function(e) {
- $("input[name='phoneNumIpt']").val($(this).attr("phone"));
- }).delegate(".make-call-history", "dblclick",function(){
- $(".callInfo").find(".activeCall").text("主叫:" + $("input[name='softExtensionIpt']").val());
- $(".callInfo").find(".passiveCall").text("被叫:" + $(this).attr("phone"));
- $(".callInfo").find(".phone-text").show();
- $(".consultatio-div,soft-agent-search").hide();//隐藏咨询框
- $("input[name='phoneNumIpt']").val($(this).attr("phone"));
- //初始化拨号键点击事件
- qlSoftPhone.makeCall($(this).attr("phone"),"");
- });
-
- $(".organUser").find("label").bind("dblclick", function(){
- qlSoftPhone.makeCall($(this).attr("extension"),"");
- });
-
- //事件冒泡。父元素上绑定事件在子元素上不执行
- $(this).dblclick(function(e){
- e.stopPropagation();
- });
-
- //顶部间距
- if(o.marginTop>0){
- $this.css("top",o.marginTop);
- }
-
- //左面间距
- if(o.marginLeft>0){
- $this.css("left",o.marginLeft);
- }
- //开始计时
- commonObj.startCountTime();
- return qlSoftPhone;
- },
-
- //软电话状态
- statusFlag:"",
-
- //未就绪原因
- noReadyReason:"",
-
- //是否登录成功
- loginFlag:false,
-
- //装满意度随路数据
- transferSatisBusiness:"",
-
- //是否正在获取事件
- getEventing:false,
-
- //获取时间异常次数
- anomalyCount:0,
-
- lastEventTime:0,
-
- /**
- * <p>登录方法<p>
- * @param tenant 租户
- * @param platform 平台名称,华为:huawei,Aspect:aspect
- * @param version 版本号
- * @param agentType 坐席类型(common:普通座席, manager:管理员)
- * @param skillGroupCode 技能组编号
- * @param skillGroupName 技能组名称
- * @param consultativeGroup 可咨询组
- * @param transferGroup 可转接组
- * @param manageGroup 可管理组
- */
- login:function(){
- var o = $this.data('softphones');
- var data = {
- agentId:o.agentId,
- agentName:o.agentName,
- password:o.password,
- extension:o.extension,
- tenant:o.tenant,
- platform:o.platformFlag,
- version:o.platformVersion,
- agentType:o.agentType,
- skillGroupCode:o.skillGroupCode,
- skillGroupName:o.skillGroupName,
- consultativeGroup:o.consultativeGroup,
- transferGroup:o.transferGroup,
- manageGroup:o.manageGroup
- };
- this.agentType = o.agentType;
- qlSoftPhone.sendAjax("login",data,"qlSoftPhone.loginSuccess");
- },
-
- //改变座席状态为示忙
- setNotReady:function(notreadyreason){
- var o = $this.data("softphones");
- qlSoftPhone.sendAjax("notReady",{token:o.token,reason:notreadyreason},"qlSoftPhone.functionCallBack");
- },
-
- //改变座席状态为示闲
- setReady:function(){
- var o = $this.data("softphones");
- qlSoftPhone.sendAjax("ready",{token:o.token},"qlSoftPhone.functionCallBack");
- },
-
- //拨打号码
- makeCall:function(phone,businessParam){
- var o = $this.data("softphones");
- if(phone==undefined || phone==null || phone=="" ){
- alert("请输入电话号码!");
- return false;
- }
- var reg = /^[0-9]*$/;
- if(!reg.test(phone)){
- alert("电话号码格式不正确!");
- return false;
- }
-
- if(qlSoftPhone.statusFlag != "AS_IDLE" && qlSoftPhone.statusFlag != "AS_NOT_READY"){
- alert("当前状态下不允许外呼!");
- return false;
- }
-
- var serviceId = $("#soft_skills").val();
- if(serviceId == '0' || serviceId == 0){
- serviceId = $(".selectGroup").find(".skill_sed").attr("value");
- if(serviceId == '0' || serviceId == 0){
- alert("请先选择技能组再外呼!");
- return false;
- }
- }
- $(".status-text").text("拨号中");
- $(".timing").text("00:00:00");
- qlSoftPhone.statusFlag = "AS_IDLEING";
- qlSoftPhone.sendAjax("dial",{token:o.token,phoneNumber:phone,serviceId:serviceId,type:"external",business:businessParam},"qlSoftPhone.functionCallBack");
- // 回调外呼方法
- o.onDial(o.extension,phone,businessParam);
- },
-
- //接听方法
- answerCall:function(){
- var o = $this.data('softphones');
- this.sendAjax("answer",{token:o.token},"qlSoftPhone.functionCallBack");
- },
-
- //设置技能组
- setSkill:function(skillCode){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("setSkill", {agentId:o.agentId, token:o.token, skillId:skillCode}, "qlSoftPhone.functionCallBack");
- },
-
- //挂断电话
- releaseCall:function(){
- var o = $this.data('softphones');
-
- if(o.hangupTransferSatis && qlSoftPhone.statusFlag == "AS_ACTIVE"){
- qlSoftPhone.sendAjax("transferSatis",{token:o.token,business:qlSoftPhone.transferSatisBusiness},"qlSoftPhone.functionCallBack");
- qlSoftPhone.transferSatisBusiness = "";
- }else{
- qlSoftPhone.sendAjax("hangUp",{token:o.token},"qlSoftPhone.functionCallBack");
- }
- },
-
- //数字按键
- sendDigit:function(number){
- var o = $this.data('softphones');
- this.sendAjax("pressDigit",{token:o.token,number:number},"qlSoftPhone.functionCallBack");
- },
-
- //保持
- holdCall:function(){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("hold",{token:o.token},"qlSoftPhone.functionCallBack");
- },
-
- //结束后处理
- completeCall:function(completeCode){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("completeCall",{token:o.token,completeCode:completeCode},"qlSoftPhone.functionCallBack");
- },
-
- //转接
- transfer:function(phoneOrAgentId,type,business){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("transfer",{token:o.token,phoneNumber:phoneOrAgentId,type:type,applicant:phoneOrAgentId,callNumber:"",business:business},"qlSoftPhone.functionCallBack");
- },
-
- //恢复
- retrieveCall:function(){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("retrieve",{token:o.token},"qlSoftPhone.functionCallBack");
- },
-
- //咨询
- consult:function(phoneOrAgentId,type,otherdn,business){
- var o = $this.data('softphones');
-
- //技能组
- var serviceId = $("#soft_skills").val();
- if(serviceId == '0' || serviceId == 0){
- serviceId = $(".selectGroup").find(".skill_sed").attr("value");
- if(serviceId == '0' || serviceId == 0){
- alert("请先选择技能组再咨询!");
- return false;
- }
- }
-
- qlSoftPhone.sendAjax("consult",{token:o.token,consultNumber:phoneOrAgentId,type:type,applicant:o.agentId,callNumber:otherdn,serviceId:serviceId,business:business},"qlSoftPhone.functionCallBack");
- },
-
- //咨询转接
- consultTransfer:function(){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("consultTransfer",{token:o.token},"qlSoftPhone.functionCallBack");
- },
-
- //会议
- conferenceCall:function(){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("conference",{token:o.token},"qlSoftPhone.functionCallBack");
- },
-
- //退出会议
- exitConference:function(){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("exitConference",{token:o.token},"qlSoftPhone.functionCallBack");
- },
- //转满意度
- transferSatis:function(){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("transferSatis",{token:o.token},"qlSoftPhone.functionCallBack");
- },
-
- //获取可转接,咨询技能组
- getSkills:function(type){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("getSkill",{type:type,token:o.token},"qlSoftPhone.transferSkillsCallBack");
- },
-
- //根据技能组code获取就绪坐席
- getReadyAgentBySkill:function(skillCode){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("getReadyAgentBySkill",{skillCode:skillCode,token:o.token},"qlSoftPhone.getReadyAgentCallBack");
- },
-
- //登录成功回调事件
- loginSuccess:function(data){
- var o = $this.data('softphones');
- var token = data.success;
- if(token){
- o.isGetEvent = true;
- o.token = token;
- $this.data('softphones', o);
- qlSoftPhone.getEvent();
-
- //时隔30秒轮询
- interval = setInterval(function(){
- var time = new Date().getTime();
- if(time - qlSoftPhone.lastEventTime >30000 ){
- qlSoftPhone.getEvent();
- }
- },30000);
-
-
- //切换成就绪状态
- qlSoftPhone.setReady();
-
- o.login();//登录成功回调
- }else{
- alert(data.fail);
- $(".loginInf .loginBtn").removeClass("dis");
- $(".status-text").text("登录失败");
- }
- },
-
- //除登录,外呼,登出以外的请求回调函数
- functionCallBack:function(data){
- if(data.fail){
- alert(data.fail);
- softTopObj.onError();
- }
- },
-
- //登出方法
- logOff : function(){
- var o = $this.data('softphones');
-
- if(qlSoftPhone.statusFlag != "AS_IDLE" && qlSoftPhone.statusFlag != "AS_NOT_READY"){
- alert("当前状态下不允许退出!");
- return false;
- }
-
- qlSoftPhone.sendAjax("logout",{token:o.token},"qlSoftPhone.logOutSuccess");
- },
-
- //登出回调成功事件
- logOutSuccess:function(data){
- if(data.fail) alert(data.fail);
- },
-
- //获取可转接咨询的技能组
- transferSkillsCallBack:function(data){
- var html = "";
- var flag = true;
- for(var i in data){
- if(flag){
- html+="<a class='sed' href='javascript:void(0);' organCode='"+i+"'>"+data[i]+"</a>";
- //加载第一个技能组的所有坐席
- qlSoftPhone.getReadyAgentBySkill(i);
- flag = false;
- }else{
- html+="<a href='javascript:void(0);' organCode='"+i+"'>"+data[i]+"</a>";
- }
- }
- $(".organGroup").html(html);
-
- $(".organGroup").find("a").bind("click", function(){
- $(this).addClass("sed").siblings().removeClass("sed");
- qlSoftPhone.getReadyAgentBySkill($(this).attr("organCode"));
- });
- },
-
- //获取所有示闲的坐席
- getReadyAgentCallBack:function(data){
- var o = $this.data('softphones');
- if (data != null && data != undefined) {
- var consuleHtml = "";
- for (var i in data) {
- consuleHtml += "<label extension='"+o.extension+"'><input type='radio' class='radio' name='agentRedio' agentId='"+i+"'><span class='radio'>"+data[i]+"</span></label>";
- }
- $(".organUser").html(consuleHtml);
- }else{
- $(".organUser").html("");
- }
-
- $(".organUser").find("label").bind("dblclick", function(){
- qlSoftPhone.transfer($(this).find("input").attr("agentid"),"internal");
- });
- },
-
- //通知后台拿到事件了
- eventNotice:function(eventName){
- var o = $this.data('softphones');
- qlSoftPhone.sendAjax("eventNotice",{name:eventName,token:o.token},"qlSoftPhone.noticeCallBack");
- },
-
- //拿到事件回调函数
- noticeCallBack:function(data){
- if(data.fail) alert(data.fail);
- qlSoftPhone.getEvent();
- },
-
- //发送ajax请求的方法
- sendAjax:function(methodName,data,callBackName){
- var o = $this.data('softphones');
- $.ajax({
- type: "post",
- async:true,
- timeout:15000,
- url: o.url + "/" + methodName,
- data: data,
- dataType: "jsonp",
- jsonpCallback : callBackName,
- complete : function(XMLHttpRequest, status) {
- if(XMLHttpRequest.status==200){
- return false;
- }
- if(XMLHttpRequest.status==0 || status=="timeout") {
- alert("请求超时,请检查网路连接!");
- } else {
- alert("网络异常["+ XMLHttpRequest.status +", "+ status +"]");
- console.log("网络异常["+ XMLHttpRequest.status +", "+ status +"]");
- }
- }
- });
- },
-
- //获取事件
- getEvent : function(){
- var o = $this.data('softphones');
- qlSoftPhone.lastEventTime = new Date().getTime();
- //判断是否停止轮询
- if(o.isGetEvent){
- //判断是否轮询中
- if(!qlSoftPhone.getEventing){
- qlSoftPhone.getEventing = true;
- var date = new Date();
- var yrd = "" + date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate() + "_" + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + "." + date.getMilliseconds() + "_" + Math.round(Math.random()*1000);
- $.ajax({
- type: "post",
- async:true,
- timeout:25000,
- url: o.url + "/getEventACK?yrd=" + yrd,
- data: {token:o.token},
- dataType: "jsonp",
- jsonpCallback : "qlSoftPhone.qlEventCallBack",
- complete : function(XMLHttpRequest, status) {
- if(XMLHttpRequest.status==200){
- return false;
- }
- qlSoftPhone.getEventing = false;
- qlSoftPhone.anomalyCount = qlSoftPhone.anomalyCount + 1;
- setTimeout(function(){qlSoftPhone.getEvent();}, 1000);
- var statusText = $(".status-text").text();
- if(XMLHttpRequest.status==0 || status=="timeout") {
- console.log("获取事件请求超时,请检查网路连接!");
- $(".status-text").text(statusText + ".");
- } else {
- $(".status-text").text(statusText + "["+ XMLHttpRequest.status +"]");
- //连续异常超过5次,提醒坐席
- if(qlSoftPhone.anomalyCount>=5){
- // 获取事件成功,清0
- qlSoftPhone.anomalyCount = 0;
- alert("获取事件网络异常["+ XMLHttpRequest.status +", "+ status +"]");
- }
- console.log("获取事件网络异常["+ XMLHttpRequest.status +", "+ status +"]");
- }
- }
- });
- }
- }
- },
-
- qlEventCallBack:function(data){
- qlSoftPhone.getEventing = false;
- qlSoftPhone.anomalyCount = 0; // 获取事件成功,清0
- if(data != undefined && data != null && !jQuery.isEmptyObject(data)) console.log(data);
- var o = $this.data("softphones");
- var eventName = data.name;
- var data = data.data;
-
- //通知收到事件
- if(eventName) qlSoftPhone.eventNotice(eventName);
-
- switch (eventName){
- case "qlEvent_Login"://登录
- softTopObj.logonSuccess(o,data);
- qlSoftPhone.loginFlag=true;
- o.login(data);
- break;
- case "qlEvent_notReady"://未就绪,示忙
- softTopObj.notReadySuccess(data);
- o.notReady(data);
- break;
- case "qlEvent_Ready"://就绪,示闲
- softTopObj.readySuccess(data);
- o.ready(data);
- break;
- case "qlEvent_Dial"://外呼
- softTopObj.dailSuccess(data);
- o.ejectScreen(data);
- break;
- case "qlEvent_Active":
- softTopObj.activeSuccess(data);
- o.onCall(data);
- break;
- case "qlEvent_Alerting":
- softTopObj.alertingSuccess(data);
- if(data.callType != "cons") o.ejectScreen(data);
- break;
- case "qlEvent_HangUp":
- o.hangUp(data);
- break;
- case "qlEvent_WrapUp":
- softTopObj.wrapUpSuccess(o,data);
- o.wrapUp(data);
- break;
- case "qlEvent_Hold":
- softTopObj.hodeSuccess(data);
- o.hold(data);
- break;
- case "qlEvent_Record":
- o.addRecord(data);
- break;
- case "qlEvent_ConsultDial":
- softTopObj.consultDialSuccess(data);
- o.consultDial(data);
- break;
- case "qlEvent_Consult":
- softTopObj.consultSuccess(data);
- o.consult(data);
- break;
- case "qlEvent_Consult_Tran":
- break;
- case "qlEvent_Conference":
- softTopObj.conferenceSuccess(data);
- o.conference(data);
- break;
- case "Session Timeout":
- alert("Session Timeout");
- softTopObj.logOutSuccess({success:"Session Timeout"});
- break;
- case "qlEvent_Logout":
- o.isGetEvent = false;
- window.clearInterval(interval);//删除30秒轮询对象
- $this.data('softphones', o);
- qlSoftPhone.loginFlag=false;
- softTopObj.logOutSuccess(data);
- o.logout(data);
- break;
- case "qlEvent_Error":
- alert(data);
- softTopObj.onError();
- o.error(data);
- break;
- default:
- qlSoftPhone.getEvent();
- }
- }
- };
-
- //顶部软电话对象
- var softTopObj = {
- //登录成功回调事件
- logonSuccess:function(o,data){
- //关闭所有的按钮
- softTopObj.closeAllBtn()
- //显示状态
- $(".status-text").text("登录成功");
-
- qlSoftPhone.statusFlag="AS_LOGIN";
-
- $(".loginInf").find("input[name='softAgentIpt']").attr("disabled",true);
- $(".loginInf").find("input[name='softExtensionIpt']").attr("disabled",true);
- $(".loginInf .logOffBtn").removeClass("dis");
-
- //显示技能组
- var currentSkills = data.serviceList;
- if(currentSkills != null && currentSkills != undefined && currentSkills.length > 0) {
- if(o.isDefaultSkill) $(".selectGroup").find("#soft_skills").html('');
- else $(".selectGroup").find("#soft_skills").html('<label value="0">请选择技能组</label>');
- for(var i=0;i<currentSkills.length;i++){
- $(".selectGroup").find("#soft_skills").append('<label value="'+currentSkills[i].key+'">'+currentSkills[i].value+'</label>');
- }
-
- //是否默认一个技能组
- if(o.isDefaultSkill){
- $(".selectGroup").removeClass("selectGroup_dis").find(".skill_sed").text($(".selectGroup").find("#soft_skills").find("label:first").text()).attr("value",$(".selectGroup").find("#soft_skills").find("label:first").attr("value"));
- }else{
- $(".selectGroup").removeClass("selectGroup_dis").find("#soft_skills").find("label").unbind().bind("click",function(){
- $(".selectGroup").find(".skill_sed").text($(this).text()).attr("value",$(this).attr("value"));
- });
- }
- }else alert("没有获取到该工号的技能组");
-
- //组装示忙原因
- var html="<span>未就绪原因</span>";
- for(var i=0;i<data.notReadyReasonList.length;i++){
- html+="<label key='"+data.notReadyReasonList[i].key+"'>"+data.notReadyReasonList[i].value+"</label>";
- }
- $(".state").find(".readyKey").html(html);
- },
-
- //示闲成功回调事件
- readySuccess:function(data){
- //关闭所有的按钮
- softTopObj.closeAllBtn();
- //显示状态
- $(".status-text").text("就绪");
-
- qlSoftPhone.statusFlag="AS_IDLE";
-
- //绑定示闲可以点击
- $(".ready").bind("click", function(){
- var $readyKey = $(".ready").find(".readyKey");
- if($readyKey.is(":hidden")) {
- $readyKey.show();
- } else {
- $readyKey.hide();
- }
- });
- $(".ready").removeClass("sm_dis").addClass("sm").show().find("label").bind("click", function(){
- qlSoftPhone.noReadyReason=$(this).text();
- qlSoftPhone.setNotReady($(this).attr("key"));
- });
- $(".idle").hide();
-
- //外呼拨号
- $(".softPhoneTopBox").find(".dial-num").addClass("on").find(".bh").unbind().bind("click",function(){
- if($(".pt-input-num-box").attr("isShow") == undefined || $(".pt-input-num-box").attr("isShow") == "0" ){
- $(".pt-input-num-box").attr("isShow","1");
- //初始化拨号键
- softTopObj.openPhoneNum();
- $(".pt-input-num-box").show().find(".make-call-box").unbind().bind("click",function(){
- var phone = $("input[name='phoneNumIpt']").val();
- phone = phone.replace(/\s/g, "");
- if(phone!=undefined && phone!=null && phone!=""){
- $(".callInfo").show().find(".activeCall").text("主叫:"+$("input[name='softExtensionIpt']").val());
- $(".callInfo").find(".passiveCall").text("被叫:"+phone);
- $(".callInfo").removeClass("hide");
- $(".softPhoneBox").find("input[name='phoneNumIpt']").val(phone);
- //拨号
- var userdata = $(".inputNumBox").find(".addCode").attr("userdata");
- //设置电话历史
- var phoneObj = {};
- phoneObj.phone=phone;
- softTopObj.setPhoneHistory(phoneObj);
- }
-
- qlSoftPhone.makeCall(phone,userdata);
- });
- }else{
- $(".pt-input-num-box").removeAttr("isShow").hide();
- }
- });
- },
-
- //示忙成功回调事件
- notReadySuccess:function (data){
- //关闭所有的按钮
- softTopObj.closeAllBtn()
- //打开拨号键盘盘
- $(".pt-input-num-box").hide();//隐藏拨号键
- $(".consu-input-div").hide();//隐藏咨询框
- $(".callInfo").find(".phone-text").hide();
- if(qlSoftPhone.noReadyReason == "") $(".status-text").text("未就绪");//显示状态
- else $(".status-text").text(qlSoftPhone.noReadyReason);//显示状态
-
- //设置软电话状态
- qlSoftPhone.statusFlag="AS_NOT_READY";
-
- //绑定示闲可以点击
- $(".idle").removeClass("sx_dis").addClass("sx").show().bind("click",function(){
- qlSoftPhone.setReady();
- }).siblings().hide();
-
- //外呼拨号
- $(".softPhoneTopBox").find(".dial-num").addClass("on").find(".bh").unbind().bind("click",function(){
- if($(".pt-input-num-box").attr("isShow") == undefined || $(".pt-input-num-box").attr("isShow") == "0" ){
- $(".pt-input-num-box").attr("isShow","1");
- //初始化拨号键
- softTopObj.openPhoneNum();
- $(".pt-input-num-box").show().find(".make-call-box").unbind().bind("click",function(){
- var phone = $("input[name='phoneNumIpt']").val();
- phone = phone.replace(/\s/g, "");
- if(phone!=undefined && phone!=null && phone!=""){
- $(".callInfo").show().find(".activeCall").text("主叫:"+$("input[name='softExtensionIpt']").val());
- $(".callInfo").find(".passiveCall").text("被叫:"+phone);
- $(".callInfo").removeClass("hide");
- $(".softPhoneBox").find("input[name='phoneNumIpt']").val(phone);
- //拨号
- var userdata = $(".inputNumBox").find(".addCode").attr("userdata");
- //设置电话历史
- var phoneObj = {};
- phoneObj.phone=phone;
- softTopObj.setPhoneHistory(phoneObj);
- }
-
- qlSoftPhone.makeCall(phone,userdata);
- });
- }else{
- $(".pt-input-num-box").removeAttr("isShow").hide();
- }
- $("input[name='phoneNumIpt']").focus(); //号码输入框获取焦点
- });
-
- },
- //外呼振铃操作
- dailSuccess:function(data){
- //关闭所有的按钮
- softTopObj.closeAllBtn()
- $(".callInfo").css("display","");
- othendn = data.dnis;
- //显示状态
- $(".status-text").text("外呼中");
-
- qlSoftPhone.statusFlag="AS_DAIL";
-
- //外呼拨号
- $(".softPhoneTopBox").find(".answer-call").addClass("on").find("a").unbind().bind("click",function(){
- qlSoftPhone.releaseCall();
- }).removeClass("jt").addClass("gd").text("挂断");
- },
-
- //呼入振铃操作
- alertingSuccess:function(data){
- //关闭所有的按钮
- softTopObj.closeAllBtn()
- //显示状态
- $(".status-text").text("呼入中");
-
- if(data.callType == "cons") qlSoftPhone.statusFlag="AS_CONSULTDIAL";
- else qlSoftPhone.statusFlag="AS_ALERTING";
-
- $(".callInfo").find(".activeCall").text("主叫:"+data.ani);
- $(".callInfo").find(".passiveCall").text("被叫:"+data.dnis);
- $(".callInfo").css("display","");
-
- if(data.callType == "in") $(".softPhoneBox").find("input[name='phoneNumIpt']").val(data.ani);
- else $(".softPhoneBox").find("input[name='phoneNumIpt']").val(data.dnis);
-
- //外呼拨号
- $(".softPhoneTopBox").find(".answer-call").addClass("on").find("a").unbind().bind("click",function(){
- qlSoftPhone.answerCall();
- });
- },
-
- //接通操作
- activeSuccess:function(data){
- //关闭所有的按钮
- softTopObj.closeAllBtn();
- $(".callInfo").css("display","");
- //打开拨号键盘盘
-
- //挂断
- $(".softPhoneTopBox").find(".answer-call").addClass("on").find("a").unbind().bind("click",function(){
- qlSoftPhone.releaseCall();
- }).removeClass("jt").addClass("gd").text("挂断");
- $(".status-text").text("通话中");//显示状态
- qlSoftPhone.statusFlag = "AS_ACTIVE";
-
- // 显示示忙按钮
- // 通话之前是示闲状态时才显示
- if($(".idle").is(":hidden")){
- $(".ready").bind("click", function(){
- var $readyKey = $(".ready").find(".readyKey");
- $readyKey.show();
- });
- $(".ready").removeClass("sm_dis").addClass("sm").show().find("label").bind("click", function(){
- $(".idle").removeClass("sx_dis").addClass("sx").show();
- $(".ready").hide();
- qlSoftPhone.noReadyReason=$(this).text();
- qlSoftPhone.setNotReady($(this).attr("key"));
- //将示闲按钮禁用
- $(".state .sr").find(".idle").removeClass("sx").addClass("sx_dis").unbind();
- });
- }
-
- //保持
- $(".softPhoneTopBox").find(".hode").addClass("on").find("a").unbind().bind("click",function(){
- qlSoftPhone.holdCall();
- }).addClass("bc").removeClass("hf").text("保持");
-
- //转接
- $(".softPhoneTopBox").find(".transfer").addClass("on").find("a").unbind().bind("click",function(){
- softTopObj.openTransferBtn(data);
- });
-
- //外呼拨号
- $(".softPhoneTopBox").find(".dial-num").addClass("on").find("a").unbind().bind("click",function(){
- if($(".pt-input-num-box").attr("isShow") == undefined || $(".pt-input-num-box").attr("isShow") == "0" ){
- $(".pt-input-num-box").attr("isShow","1").show();
- //数字按键
- $(".inputKey").find(".num").unbind().bind("click",function(){
- $("input[name='phoneNumIpt']").val($("input[name='phoneNumIpt']").val()+$(this).text());
- qlSoftPhone.sendDigit($(this).text());
- });
- }else{
- $(".pt-input-num-box").removeAttr("isShow").hide();
- }
- });
-
- },
-
- //后处理
- wrapUpSuccess:function(o,data){
- //关闭所有的按钮
- softTopObj.closeAllBtn();
- $(".status-text").text("通话结束");
-
- //更新软电话状态
- qlSoftPhone.statusFlag="AS_ACW";
-
- //是否禁用结束后处理操作
- if(!o.isDisableAcw){
-
- var html = "<div class='why'>";
- for(var i=0;i<data.wrapUpReasons.length;i++){
- html+="<label key='"+data.wrapUpReasons[i].key+"'>"+data.wrapUpReasons[i].value+"</label>";
- }
- $(".softPhoneTopBox").find(".hcl").append(html+"</div>");
-
- //结束后处理操作
- $(".softPhoneTopBox").find(".back-handle").addClass("on").find("label").bind("click", function(){
- $(".softPhoneTopBox").find(".hcl").find("div").remove();
- qlSoftPhone.completeCall($(this).attr("key"));
- });
-
- // 自动结束后处理
- if(o.autoEndWrapUpTime > 0){
- // 定时结束后处理
- var key = $(".softPhoneTopBox").find(".hcl").find("div").children().first().attr("key");
- setTimeout(function () {
- if(qlSoftPhone.statusFlag == 'AS_ACW'){
- qlSoftPhone.completeCall(key);
- }
- }, o.autoEndWrapUpTime);
- }
- }
- // 回调
- o.onWrapUp();//后处理事件
- },
-
- //保持操作
- hodeSuccess:function(data){
- //关闭所有的按钮
- softTopObj.closeAllBtn();
- //显示状态
- $(".status-text").text("保持中");
- //更新软电话状态
- qlSoftPhone.statusFlag="AS_HOLD";
-
- //咨询
- $(".softPhoneTopBox").find(".consultation").addClass("on").find("a").unbind().bind("click",function(){
- softTopObj.openConsultationBtn(data);
- });
-
- //恢复
- $(".softPhoneTopBox").find(".hode").addClass("on").find("a").unbind().bind("click",function(){
- qlSoftPhone.retrieveCall();
- }).addClass("hf").removeClass("bc").text("恢复");
-
- },
-
- //咨询外呼振铃事件
- consultDialSuccess:function(data){
-
- //关闭所有的按钮
- softTopObj.closeAllBtn();
-
- //显示状态
- $(".status-text").text("咨询外呼中");
-
- //绑定咨询按钮显示隐藏咨询框
- $(".softPhoneTopBox").find(".consultation").addClass("on").find("a").unbind().bind("click",function(){
- if($(".consultationBox").attr("isShow") == undefined || $(".consultationBox").attr("isShow") == 0){
- $(".consultationBox").show().attr("isShow",1);
- }else{
- $(".consultationBox").hide().removeAttr("isShow");
- return false;
- }
- });
-
- qlSoftPhone.statusFlag="AS_CONSULTDIAL";
-
- $(".consultationBox .zxBtn").html("<a href='javascript:void(0);' class='release-btn'>挂断</a>");
-
- //挂断咨询按钮
- $(".consultationBox .zxBtn").find(".release-btn").unbind().bind("click", function(){
- qlSoftPhone.releaseCall();
- });
- },
-
- //咨询成功回调事件
- consultSuccess:function(data){
-
- //显示状态
- $(".status-text").text("咨询中");
-
- qlSoftPhone.statusFlag="AS_CONSULT";
-
- //咨询转接
- $(".consultationBox .zxBtn").html("<a href='javascript:void(0);' class='transfer-btn'>转接</a><a href='javascript:void(0);' class='release-btn'>挂断</a>")
-
- //咨询转接按钮点击事件
- $(".consultationBox .zxBtn").find(".transfer-btn").bind("click", function(){
- qlSoftPhone.consultTransfer();
- $(".consultationBox").hide().find("input[name='consultation-ipt']").val("");
- });
-
- //挂断咨询按钮
- $(".consultationBox .zxBtn").find(".release-btn").bind("click", function(){
- qlSoftPhone.releaseCall();
- });
-
- //绑定会议点击事件
- $(".softPhoneTopBox").find(".meeting").addClass("on").find("a").unbind().bind("click",function(){
- qlSoftPhone.conferenceCall();
- $(".consultationBox").hide().find("input[name='consultation-ipt']").val("");
- });
-
- },
-
- //会议成功回调事件
- conferenceSuccess:function(data){
-
- //关闭所有的按钮
- softTopObj.closeAllBtn();
- //显示状态
- $(".status-text").text("会议中");
-
- qlSoftPhone.statusFlag="AS_CONFERENCE";
-
- //咨询转接
- $(".call-btn").html("<a href='javascript:void(0);' class='release-btn'>结束会议</a>")
-
- //挂断
- $(".softPhoneTopBox").find(".answer-call").addClass("on").find("a").unbind().bind("click",function(){
- qlSoftPhone.exitConference();
- }).removeClass("jt").addClass("gd").text("挂断");
-
- },
-
- //点亮转接按钮
- openTransferBtn:function(data){
-
- if($(".transferBox").attr("isShow") == undefined || $(".transferBox").attr("isShow") == 0){
- $(".transferBox").show().attr("isShow",1);
- }else{
- $(".transferBox").hide().removeAttr("isShow");
- return false;
- }
-
- //获取所有空闲坐席
- qlSoftPhone.getSkills("transferGroup");
-
- //内外线切换
- $(".transferBox .adSearch").find("i").unbind().bind("click",function(){
- if($(this).hasClass("you")){
- $(".transferOutLine").hide();
- $(".transferInLine").show();
- $(this).removeClass("you").addClass("zuo");
- }else{
- $(".transferOutLine").show();
- $(".transferInLine").hide();
- softTopObj.transferPhoneNum();
- $(this).removeClass("zuo").addClass("you");
- }
- });
-
- //刷新按钮
- $(".transferBox .zxBtn").find(".reflush-btn").unbind().bind("click", function(){
- qlSoftPhone.getSkills("transferGroup");
- });
-
- //转接按钮
- $(".transferBox .zxBtn").find(".transfer-btn").unbind().bind("click", function(){
-
- var phone = "",targetType = "";
- if($(".transferBox .adSearch").find("i").hasClass("zuo")){
- phone = $(".transferBox").find("input[name='agentRedio']:checked").attr("agentid");
- targetType="internal";
- }else{
- targetType="external";
- phone = $("input[name='transfer-ipt']").val()
- }
-
- if(phone==undefined || phone==null || phone==""){
- alert("请选择一个坐席");
- return false;
- }
- $(".status-text").text("转接中");
- qlSoftPhone.transfer(phone,targetType,null);
- $(".transferBox").hide().find("input[name='transfer-ipt']").val();
- });
- },
-
- //打开咨询框
- openConsultationBtn:function(data){
-
- if($(".consultationBox").attr("isShow") == undefined || $(".consultationBox").attr("isShow") == 0){
- $(".consultationBox").show().attr("isShow",1);
- }else{
- $(".consultationBox").hide().removeAttr("isShow");
- return false;
- }
-
- //获取所有空闲坐席
- qlSoftPhone.getSkills("consultativeGroup");
-
- //内外线切换
- $(".consultationBox .adSearch").find("i").unbind().bind("click",function(){
- if($(this).hasClass("you")){
- $(".consultationOutLine").hide();
- $(".consultationInLine").show();
- $(this).removeClass("you").addClass("zuo");
- }else{
- $(".consultationOutLine").show();
- $(".consultationInLine").hide();
- softTopObj.consultationPhoneNum();
- $(this).removeClass("zuo").addClass("you");
- }
- });
-
- //添加刷新,监听,强插按钮
- var str = "<a href='javascript:void(0)'; class='reflush-btn'>刷新</a>"
- + "<a href='javascript:void(0)'; class='consultation-btn'>咨询</a>"
- $(".consultationBox .zxBtn").html(str);
-
- //刷新按钮
- $(".consultationBox .zxBtn").find(".reflush-btn").unbind().bind("click", function(){
- //获取所有空闲坐席
- qlSoftPhone.getSkills("consultativeGroup");
- });
-
- //咨询按钮
- $(".consultationBox .zxBtn").find(".consultation-btn").unbind().bind("click", function(){
- var phone = "";
- var targetType="internal";
- if($(".consultationBox .adSearch").find("i").hasClass("zuo")){
- targetType="internal";
- phone = $(".consultationBox").find("input[name='agentRedio']:checked").attr("agentid");
- }else{
- targetType="external";
- phone = $("input[name='consultation-ipt']").val()
- }
-
- if(phone==undefined || phone==null || phone==""){
- alert("请选择一个坐席");
- return false;
- }
- $(".status-text").text("咨询拨号中");
- $(".timing").text("00:00:00");
- qlSoftPhone.consult(phone,targetType,othendn,null);
- });
-
- },
-
- //退出成功
- logOutSuccess:function(){
- //关闭所有的按钮
- softTopObj.closeAllBtn()
- //显示状态
- $(".status-text").text("签出成功");
- qlSoftPhone.statusFlag = "AS_LOGOFF";
-
- //绑定登录按钮可以
- $(".loginInf").find("input[name='softAgentIpt']").removeAttr("disabled");
- $(".loginInf").find("input[name='softExtensionIpt']").removeAttr("disabled")
- $(".selectGroup").addClass("selectGroup_dis").find(".skill_sed").text("技能组").attr("value","0");
-
- $(".loginInf .loginBtn").removeClass("dis");
- $(".loginInf .logOffBtn").addClass("dis")
- },
-
- //初始化咨询区
- initConsultArea:function(){
- //打开拨号键盘盘
- $(".pt-input-num-box").hide();//打开拨号键
- $(".adSearch .nw-line").show();//隐藏咨询框
- $(".telRecordBox").hide();//隐藏电话历史
- $(".outLine").hide();//隐藏电话历史
- $(".consultatio-div").show();//隐藏电话历史
- $(".soft-agent-search").find("i").removeClass("right").addClass("left");
- },
-
- //转接外线键盘
- transferPhoneNum:function(){
- //拨号键盘点击事件
- $(".transferOutLine .inputKey").find(".num").unbind().bind("click",function(){
- $("input[name='transfer-ipt']").val($("input[name='transfer-ipt']").val()+$(this).text());
- });
-
- //拨号删除键实现长按删除电话号码
- var time;
- $(".transferOutLine .inputKey").find(".del").unbind().bind("mouseup",function(){
- clearTimeout(time);
- }).bind("mousedown",function(){
- time = setTimeout(function() {
- $("input[name='transfer-ipt']").val("");
- }, 700);
- }).bind("click",function(){
- var phone = $("input[name='transfer-ipt").val();
- $("input[name='transfer-ipt']").val(phone.substring(0,phone.length-1));
- });
- },
-
- //咨询外线键盘
- consultationPhoneNum:function(){
- //拨号键盘点击事件
- $(".consultationOutLine .inputKey").find(".num").unbind().bind("click",function(){
- $("input[name='consultation-ipt']").val($("input[name='consultation-ipt']").val()+$(this).text());
- });
-
- //拨号删除键实现长按删除电话号码
- var time;
- $(".consultationOutLine .inputKey").find(".del").unbind().bind("mouseup",function(){
- clearTimeout(time);
- }).bind("mousedown",function(){
- time = setTimeout(function() {
- $("input[name='consultation-ipt']").val("");
- }, 700);
- }).bind("click",function(){
- var phone = $("input[name='consultation-ipt").val();
- $("input[name='consultation-ipt']").val(phone.substring(0,phone.length-1));
- });
- },
-
- //打开拨号键
- openPhoneNum:function(){
- $("input[name='phoneNumIpt']").val("");
- //拨号键盘点击事件
- $(".pt-input-num-box .inputKey").find(".num").unbind().bind("click",function(){
- $("input[name='phoneNumIpt']").val($("input[name='phoneNumIpt']").val()+$(this).text());
- });
-
- //键盘收缩隐藏
- $(".pt-input-num-box .inputNumBox").find(".key-set-xy").unbind().bind("click",function(){
- if($(this).hasClass("jpss")){
- $(".pt-input-num-box .inputKey").show();
- $(this).removeClass("jpss").addClass("jpzk");
- $(".telRecordBox").hide();
- }else{
- $(this).removeClass("jpzk").addClass("jpss");
- $(".pt-input-num-box .inputKey").hide();
- $(".telRecordBox").show();
- }
- });
-
- //拨号删除键实现长按删除电话号码
- var time;
- $(".pt-input-num-box .inputKey").find(".del").unbind().bind("mouseup",function(){
- clearTimeout(time);
- }).bind("mousedown",function(){
- time = setTimeout(function() {
- $("input[name='phoneNumIpt']").val("");
- }, 700);
- }).bind("click",function(){
- var phone = $("input[name='phoneNumIpt']").val();
- $("input[name='phoneNumIpt']").val(phone.substring(0,phone.length-1));
- });
- },
-
- //关闭所有的按钮
- closeAllBtn:function(){
- $(".state .sr").find(".idle").removeClass("sx").addClass("sx_dis").unbind();//解除示闲示忙操作
- $(".state .sr").find(".ready").removeClass("sm").addClass("sm_dis").unbind().find("label").unbind();//解除示闲示忙操作
- $(".timing").text("00:00:00");
- $(".pt-input-num-box").hide().removeAttr("isShow");
- $(".softPhoneTopBox").find("em").removeClass("on").find(".softBtn").unbind();
- $(".inputKeyBox").find(".make-call-box").unbind()
- $(".softPhoneTopBox").find(".answer-call").find("a").removeClass("gd").addClass("jt").text("接听");
- $(".transferBox").hide().removeAttr("isShow");
- $(".consultationBox").hide().removeAttr("isShow");
- },
-
- //咨询外线键盘
- consultPhoneNum:function(){
- //拨号键盘点击事件
- $(".outLine .inputKey").find(".num").unbind().bind("click",function(){
- if($("input[name='cons-tran-ipt']").val().length<12)
- $("input[name='cons-tran-ipt']").val($("input[name='cons-tran-ipt']").val()+$(this).text());
- });
-
- //键盘收缩隐藏
- $(".outLine .inputNumBox").find(".key-set-xy").unbind().bind("click",function(){
- if($(this).hasClass("jpss")){
- $(".inputKey").show();
- $(this).removeClass("jpss").addClass("jpzk");
- }else{
- $(this).removeClass("jpzk").addClass("jpss");
- $(".inputKey").hide();
- }
- });
-
- //拨号删除键实现长按删除电话号码
- var time;
- $(".outLine .inputKey").find(".del").unbind().bind("mouseup",function(){
- clearTimeout(time);
- }).bind("mousedown",function(){
- time = setTimeout(function() {
- $("input[name='cons-tran-ipt']").val("");
- }, 700);
- }).bind("click",function(){
- var phone = $("input[name='cons-tran-ipt']").val();
- $("input[name='cons-tran-ipt']").val(phone.substring(0,phone.length-1));
- });
-
- },
-
- //设置拨打电话历史
- setPhoneHistory:function(phoneObj){
- var myDate = new Date();
- phoneObj.time=myDate.getHours()+":"+(myDate.getMinutes()<10?'0'+myDate.getMinutes():myDate.getMinutes());
- //电话数组最多存放5个历史电话
- if(phoneArray.length>=5){
- for(var i=1;i<=phoneArray.length;i++){
- phoneArray[i-1]=phoneArray[i];
- }
- }
- phoneArray[phoneArray.length]=phoneObj;
- softTopObj.getPhoneHistory();
- },
- //设置拨打电话历史
- getPhoneHistory:function(){
-
- var html = "<div class='tit'>电话记录</div>";
- for(var i=phoneArray.length-1;i>=0;i--){
- if(phoneArray[i]==undefined) continue;
- html+="<dl class='ls'><dd class='make-call-history' phone='"+phoneArray[i].phone+"'>"+phoneArray[i].phone+"</dd><dt>"+phoneArray[i].time+"</dt></dl>";
- }
- $(".telRecordBox").html(html);
- },
-
-
- initSoftPage:function(){
-
- var html = '<div class="qlSoftPhoneBox"><div class="loginBox_phone loginInf"><input class="gh" type="text" name="softAgentIpt" placeholder="工号..." />';
- html += '<input class="fjh" type="text" name="softExtensionIpt" placeholder="分机号..." value=""/><div>';
- html += '<button type="button" class="qr loginBtn">登入</button><button type="button" class="qc dis logOffBtn">登出</button></div></div>';
- html += '<div class="state"><div class="sr"><b class="sx_dis idle"><i></i>未就绪</b><b class="sm_dis ready" style="display:none;"><i></i>就绪<div class="why readyKey"></div></b></div></div> ';
- html += '<em class="answer-call"><a class="jt softBtn" href="javascript:void(0);">接听</a></em>';
- html += '<em class="dial-num"><a class="bh softBtn" href="javascript:void(0);">拨号</a><div class="inputKeyBox pt-input-num-box" style="display:none;">';
- html += '<div class="outLine"><div class="inputNumBox"><i class="jpzk key-set-xy"></i><input type="text" name="phoneNumIpt" placeholder="请输入号码"/><i class="bd make-call-box"></i></div>';
- html += '<div class="telRecordBox" style="display:none;"><div class="tit">电话记录</div><dl class="ls">暂时还没有拨打记录!</dl></div>';
- html += '<div class="inputKey clear"><ul><li class="border1 num">1</li><li class="border1 num">2</li><li class="border2 num">3</li></ul>';
- html += '<ul><li class="border1 num">4</li><li class="border1 num">5</li><li class="border2 num">6</li></ul>';
- html += '<ul><li class="border1 num">7</li><li class="border1 num">8</li><li class="border2 num">9</li></ul>';
- html += '<ul><li class="border3 num">#</li><li class="border3 num">0</li><li class="del"></li></ul></div></div></div></em>';
- html += '<em class="hode"><a class="bc softBtn" id="qlSoftPhoneHoldBtn" href="javascript:void(0);">保持</a></em>';
- html += '<em class="back-handle"><a class="hcl softBtn" href="javascript:void(0);">后处理 </a></em>';
- html += '<div class="state"><div class="sl"><b class="blue status-text">未登录</b>';
- html += '<i class="timing" >00:00:00</i><div class="why callInfo hide"><label class="activeCall"></label><label class="passiveCall"></label></div></div></div></div>';
- return html;
- },
-
- //错误处理
- onError:function(){
- if(!qlSoftPhone.loginFlag) $(".loginInf .loginBtn").removeClass("dis");
- if(qlSoftPhone.statusFlag == "AS_IDLEING") {
- if($(".ready").hasClass("sm")){
- $(".status-text").text("就绪");
- qlSoftPhone.statusFlag = "AS_IDLE";
- } else {
- $(".status-text").text("未就绪");
- qlSoftPhone.statusFlag = "AS_NOT_READY";
- }
- $(".timing").text("00:00:00");
- }
- }
- };
-
- //公共对象
- var commonObj = {
- //开始计时
- startCountTime:function(){
- timeFlag = true;
- setInterval(function(){
- commonObj._countTime()//开始时间计时
- },1000);
- },
-
- //计时器
- _countTime:function(){
- if(timeFlag){
- var times = $(".timing").text().split(":");
- var HH=parseInt(times[0]),MM=parseInt(times[1]),SS=parseInt(times[2]),str = "";
- if(++SS==60){
- if(++MM==60){
- HH++;
- MM=0;
- }
- SS=0;
- }
- str+=HH<10?"0"+HH:HH;
- str+=":";
- str+=MM<10?"0"+MM:MM;
- str+=":";
- str+=SS<10?"0"+SS:SS;
- $(".timing").text(str);
- }
- },
-
- //重写startsWith方法
- startsWith:function(str,subStr){
- if(subStr==null||subStr==""||str.length==0||subStr.length>str.length)
- return false;
- if(str.substr(0,subStr.length)==subStr)
- return true;
- else
- return false;
- return true;
- }
- };
-
- $.fn.softphones = function(method) {
- if (qlSoftPhone[method]) {
- return qlSoftPhone[method].apply(this, Array.prototype.slice.call(arguments, 1));
- } else if (typeof method === 'object' || !method) {
- return qlSoftPhone.init.apply(this, arguments);
- } else {
- $.error('Method ' + method + ' does not exist on softphones');
- }
- };
- })(jQuery);
|