/* For ZBlogPHP erx_Call [ https://app.zblogcn.com/?id=18334 ] */
$(function(){
var erxCallDom = `
在线客服·电话咨询中心
×
-
江江00:00:00
微笑你好,我是专属在线顾问,请问是否想了解虚拟人直播软件嘛~
-
江江00:00:00
请告诉我您的需求和电话,我们会尽快联系您~
-
江江00:00:00
收到,我们会马上联系您!关闭对话框
`;
zbp.cookie.get("erxcalltel") == null ? $("body").append(erxCallDom) : '';
var erxCallAuto = '';
window.setTimeout(function(){
$(".erx-call-mbox").addClass("erxact");
$(".erx-call-mbox .ec-item").each(function(i){
let $self = $(this);
window.setTimeout(function(){
$self.slideDown();
$self.find(".ec-time").html(erxCallTime());
}, i * 1 * 1000);
});
}, 1 * 1000);
$(".erx-call-mbox .a-wx").click(function(){
let $self = $(this), href = $self.attr("href"), text = $self.text();
if(href == text){
$(this).children(".qrcode").toggle();
return false;
}
});
$(".erx-call-mbox .ec-close").click(function(){
if(zbp.cookie.get("erxcalltel") != null){
$(".erx-call-mbox, .erx-call-rbox").remove();
return false;
}
$(".erx-call-mbox").removeClass("erxact");
$(".erx-call-rbox").slideDown();
window.setTimeout(function(){
erxCallTipScroll();
}, 500);
});
$(".erx-call-rbox .erx-call-tel .int").bind('input focus', function() {
clearTimeout(erxCallAuto);
});
$(".erx-call-rbox .ec-close").click(function(){
if(zbp.cookie.get("erxcalltel") == null){
$(".erx-call-rbox").slideUp();
$(".erx-call-mbox").addClass("erxact");
clearTimeout(erxCallAuto);
}else{
$(".erx-call-mbox, .erx-call-rbox").remove();
}
});
$(".erx-call-tel .btn").click(function(){
let $self = $(this), $tel = $self.prev(), num = $tel.val(), $name = $self.parents(".erx-call-con").find(".name"), $company = $self.parents(".erx-call-con").find(".company");
if($name.val().length < 2){
$self.next().show().html('请正确填写称呼!').delay(2000).fadeOut();
$name.focus();
return;
}
if($company.val().length < 5){
$self.next().show().html('请正确填写公司名称!').delay(2000).fadeOut();
$company.focus();
return;
}
if(!/^1[345789]\d{9}$/.test(num) && !/^0\d{2,3}-?\d{7,8}$/.test(num)){
$self.next().show().html(zbp.cookie.get("erxcalltel") == null ? '⚠\u53f7\u7801\u683c\u5f0f\u4e0d\u6b63\u786e' : '⚠\u60a8\u5df2\u63d0\u4ea4\u8fc7\u4e86').delay(2000).fadeOut();
$tel.focus();
return;
}
$tel.val('\u6b63\u5728\u63d0\u4ea4...');
$.post(bloghost + "zb_users/plugin/erx_Call/" + "post" + "." + "php", {
"name":$name.val(),
"company":$company.val(),
"content":num.replace("-",""),
"url":location.href,
}, function(data){
let s =data;
if((s.search("faultCode")>0)&&(s.search("faultString")>0)){
$self.next().show().html('⚠'+(s.match(".+?")[0].replace("","").replace("",""))).delay(2000).fadeOut();
$tel.val('');
}else{
$(".erx-call-tip").delay(800).slideDown().find(".ec-time").html(erxCallTime());
$(".erx-call-tel .int").val("");
$(".erx-call-tel .phone").attr({disabled: true, placeholder: num + ' ' + s});
zbp.cookie.set("erxcalltel", 1, 7);
window.setTimeout(function(){
erxCallTipScroll();
}, 900);
}
}
);
});
$(".erx-call-tip em").click(function(){
$(".erx-call-mbox, .erx-call-rbox").remove();
});
$(".erx-call-tool a").click(function(){
if($(this).attr("href").indexOf("javascript:")>-1){
return false;
}
});
$(document).on("click", function(e){
if(!$(e.target).closest(".erx-call-tool .a-wx").length){
$(".erx-call-tool .qrcode").hide();
}
});
function erxCallTipScroll(){
let $tip = $(".erx-call-rbox .erx-call-tip"), wth1 = $tip.width(), wth2 = $tip.children("span").width();
if(wth2 > wth1){
$tip.hover(function(){
$(this).children("span").stop(true,true).animate({left:-(wth2-wth1)},800);
}, function(){
$(this).children("span").stop(true,true).animate({left:0},800);
})
}
}
function erxCallTime(){
let d = new Date(), h = d.getHours(), m = d.getMinutes(), s = d.getSeconds();
m < 10 ? m = "0"+m : m;
s < 10 ? s = "0"+s : s;
return h+":"+m+":"+s;
}
});