/* For ZBlogPHP erx_Call [ https://app.zblogcn.com/?id=18334 ] */
$(function(){
var erxCallDom = `
为提升效率,我们可以电话联系
×
-
齐经理00:00:00
微笑你好,我是您的专属在线顾问,请问有什么可以帮您?我的电话是:15964514888
-
齐经理00:00:00
请告诉我您的电话,我为您提供一对一服务
-
齐经理00:00:00
收到,我们会马上联系您!
填错/重填关闭对话框
`;
zbp.cookie.get("erxcalltel") == null && typeof(erxCallnos) == "undefined" ? $("body").append(erxCallDom) : '';
var erxCallAuto = '', erxCallPost = 0;
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 * 2 * 1000);
});
}, 2 * 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();
if(zbp.cookie.get("erxcalltel") == null){
erxCallAuto = window.setTimeout(function(){
$(".erx-call-rbox").hide();
$(".erx-call-mbox").addClass("erxact");
}, 20 * 1000);
}
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 .e-btn").click(function(){
let $self = $(this), $tel = $self.prev(), num = $tel.val();
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", {
"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{
erxCallPost ? $(".erx-call-tip .ec-msg span").remove() : '';
$(".erx-call-tip").delay(800).slideDown().find(".ec-time").html(erxCallTime());
$(".erx-call-tel .int").val("").attr({disabled: true, placeholder: num + ' ' + s});
zbp.cookie.set("erxcalltel", 1, 3);
window.setTimeout(function(){
erxCallTipScroll();
}, 900);
}
}
);
});
$(".erx-call-tip .ec-reset").click(function(){
$(".erx-call-tip").slideUp();
$(".erx-call-tel .int").val("").attr({disabled: false, placeholder: ""}).focus();
erxCallPost = 1;
zbp.cookie.set("erxcalltel", '', -1);
});
$(".erx-call-tip .ec-finish").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;
}
});