//弹框 var timer=null; function showToast(msg){ console.log(msg); $('.toast span').html(msg) $('.toast ').removeClass('hide'); clearTimeout(timer); timer= setTimeout(function(){ $('.toast ').addClass('hide'); },1500); } //验证手机号是否合法 function ValiDateMobile(telphone) { var myreg = /^1[3-9]\d{9}$/; if (!myreg.test(telphone)) { return false; } return true; }; $(function(){ window.wx_num = ""; $.ajax({ type:"get", url:'//phone.qinggan.anslib.com/huazhen/getWechatNumbers' + '?d=' + (new Date()).valueOf() + '&__p=' + location.pathname, success:function(data){ window.wx_num = data['common']; } }); var codeFlag = true; //验证码按钮有无点击 var TextTime; //获取验证码 function ValiDateCode() { if(codeFlag){ codeFlag = false; if (ValiDateMobile($('#tel').val())) { //变成不可点击样式 $('.get-code').css({ color : 'white', background : '#c5c5c5' }); var Times = 59; TextTime= setInterval(function () { if (Times <= 0) { clearInterval(TextTime); $('.get-code').text("重新获取").attr('style',''); codeFlag = true; return; } $('.get-code').text(Times); Times--; }, 1000); $.ajax({ type: "get", url: "//tg.api.qinggan.anslib.com/huazhen/api/v1/code/sms", dataType: 'json', data: { mobile:$('#tel').val(), is_use_captcha_code:1, is_show:1 }, success:function(msg){ showToast('发送成功'); }, error: function () { showToast('获取验证码失败,请重新获取'); } }); }else{ showToast('请输入正确的手机号码'); codeFlag = true; } } }; //点击出现手机号弹框 $('.btn').click(function(){ $('#tel').val(''); $('#code').val(''); codeFlag=true; clearInterval(TextTime); var dataIdx=$(this).attr('data-idx'); $('.get-code').text("获取验证码").css({ 'background':'#ffa000', 'color':'#fff' }); console.log(dataIdx); if(dataIdx==0){ //wx_two $('.wx-mask .hfwj').text('聊天秘籍'); $('.wx-mask .wxh').text(window.wx_num); $('.copy-btn').attr('data-clipboard-text',window.wx_num); }else if(dataIdx==1){ $('.wx-mask .hfwj').text('挽回秘籍'); $('.wx-mask .wxh').text(window.wx_num); $('.copy-btn').attr('data-clipboard-text',window.wx_num); }else if(dataIdx==2){ $('.wx-mask .hfwj').text('挽回攻略'); $('.wx-mask .wxh').text(window.wx_num); $('.copy-btn').attr('data-clipboard-text',window.wx_num); }else if(dataIdx==3){ $('.wx-mask .hfwj').text('高逼格朋友圈建设'); $('.wx-mask .wxh').text(window.wx_num); $('.copy-btn').attr('data-clipboard-text',window.wx_num); } //$('.wx-mask').removeClass('hide'); $('.login-mask').removeClass("hide"); //确认提交 $('.login-btn').unbind('click'); $('.login-btn').on('click',function () { if(!ValiDateMobile($('#tel').val())){ showToast('请输入正确的手机号码'); $('#tel').val('') return; } $.ajax({ type: 'post', url: '//tg.api.qinggan.anslib.com/huazhen/api/v1/willInput', dataType: 'json', data:{ channel:'SEO-恋爱&挽回秘籍', channel_code:'ab541d874c7bc19ab77642849e02b89f', telphone:$('#tel').val(), sms_code:$('#code').val(), is_validate_sms:1 }, success: function (data) { showToast('提交成功'); $('.login-mask').addClass('hide'); $('.wx-mask').removeClass('hide'); if(typeof yxdArticle == "function" && typeof data == "object"){ yxdArticle(data); } }, error: function (err) { if(err.responseJSON.error_code == 80003){ showToast('提交成功'); $('.login-mask').addClass('hide'); $('.wx-mask').removeClass('hide'); return false; } showToast(err.responseJSON.msg); } }); $.ajax({ type: "post", url: "//tg.api.qinggan.anslib.com/huazhen/api/v1/logForm", data:{ channel:'SEO-恋爱&挽回秘籍', channel_code:'ab541d874c7bc19ab77642849e02b89f', telphone:$('#tel').val(), sms_code:$('#code').val(), is_validate_sms:1 }, dataType: "json" }) }); }); //获取验证码 $('.get-code').click(function(){ console.log(123); ValiDateCode(); }); $('.content-1').click(function(e){ e.stopPropagation(); }); //点击遮罩消失 $('.login-mask').click(function(){ $(this).addClass('hide'); }); $('.wx-mask .close').click(function(){ $('.wx-mask').addClass('hide'); }); var clipboard = new ClipboardJS('.copy-btn'); clipboard.on('success', function(e) { showToast('复制成功') e.clearSelection(); window.location.href = "weixin://"; }); });