/*-------------------
*Description:        By www.yiwuku.com
*Website:            https://app.zblogcn.com/?id=15900
*Author:             尔今 erx@qq.com
*update:             2020-08-27(Last:2022-02-22)
-------------------*/

try {
	$(function(){
		if($(".erx-weixin-top").length){
			$("body").prepend('<div class="erx-weixin-blank"></div>');
		}
		if($(".erx-weixin-bot").length){
			$("body").append('<div class="erx-weixin-blank"></div>');
		}
		if($(".erx-wx-tel").length){
			var teldom = $(".erx-wx-tel").children("div"), telnum = teldom.html();
			teldom.html(telnum.replace(/\B(?=(\d{4})+(?!\d))/g, '-'));
			teldom.parent().click(function () {
				$(this).toggleClass("erxact");
			});
		}
		$(".erx-wx-close").click(function () {
			$(".erx-weixin-open").removeClass("erxact");
		});
		$.getScript(typeof(bloghost)=="undefined"?'/':bloghost+"zb_users/plugin/erx_Weixin/js/clipboard.min.js",function() {
			new ClipboardJS('.erx-wx-show, .erx-weixin-auto .erx-wx-btn').on('success', function(e) {
				$(".erx-weixin-copy").addClass("erxact");
				$(".erx-wx-ow .qrcode-ez").addClass("erxshow");
			}).on('error', function(e) {
				alert('\u590d\u5236\u5931\u8d25\uff01');
			});
		});
		$(".erx-weixin-insert .erx-wx-show").click(function () {
			$(".erx-wx-ow .qrcode-ez").removeClass("erxshow");
		});
		var erxWeixinAutoTimer, erxWeixinAuto_days = $(".erx-weixin-auto").attr("data-cookie")*1;
		erxWeixinAuto();
		$(".erx-wx-icon-close").click(function () {
			erxWeixinAuto();
		});
		$(".erx-weixin-auto .erx-wx-btn, .erx-wx-close.erx-wx-btn").click(function () {
			$(".erx-weixin-auto").removeClass("erxact");
			$(".erx-wx-ow .qrcode-ez").removeClass("erxshow");
			clearTimeout(erxWeixinAutoTimer);
			zbp.cookie.set("erxWeixinAuto", 1, erxWeixinAuto_days);
		});
		function erxWeixinAuto(){
			if($(".erx-weixin-auto").length){
				var atime = $(".erx-weixin-auto").attr("data-time")*1,
					cookie = zbp.cookie.get("erxWeixinAuto");
				if(cookie ==  null){
					erxWeixinAutoTimer = setTimeout(function() {
						if(!$(".erx-weixin-copy").hasClass("erxact")){
							$(".erx-weixin-auto").addClass("erxact");
							$(".erx-wx-ow .qrcode-ez").addClass("erxshow");
						}
					}, atime*1000);
				}
			}
		}
	});
} catch(e) {
	if(!window.jQuery && window.console && window.console.error){
		console.error("很遗憾，微信营销客服插件无法启用！原因是当前主题jQuery加载异常，可能缺失或不规范导致，建议联系主题作者修复或换用其它主题。");
	}
}


























//若无十足把握，切勿修改以上代码，容易出错 作者QQ：77940140 https://app.zblogcn.com/?auth=3ec7ee20-80f2-498a-a5dd-fda19b198194
