var countDown = '',count_down = ''; var source = ''; var scrollTop = ''; var scrollTop02 = ''; var qs = parseQueryString(window.location.href); $().ready(function () { // document.body.addEventListener('focusout', function () { // window.scrollTo(0,0); // scrollToEnd(); // }); if(qs.source) {source = qs.source} var downLoad = [{ source:'30042', title:'好借', img:'./img/doudou.png', bgImg:'./img/past-trial-bg.png', color:'#fda31b' },{ source:'30041', title:'小雨点网贷', img:'./img/xiaoyudian.png', bgImg:'./img/past-trial-bg02.png', color:'#C32018' },{ source:'30070', title:'小树时代', img:'./img/xiaoshu.png', bgImg:'./img/past-trial-bg03.png', color:'#ED6C29' }] downLoad.forEach(function (item, index) { if(source == item.source){ $(".appTitle span").html(item.title) $(".appTitle img").attr('src',item.img) $(".bgImg").attr('src',item.bgImg) $('body').css('background',item.color) return; } }) $(window).scroll(function(){ scrollTop = $(this).scrollTop(); //scrollTop() 方法返回或设置匹配元素的滚动条的垂直位置 }) }) //点击获取验证码 function getYzmEvent () { var myreg = /^[0-9]{11}$/; if (!myreg.test($("#phone").val())) { //手机号码未填写及填写不正确 showMsg('请正确填写手机号') return; } //----------- countDown = 60; count_down = countDown; var that = this; $("#getYzm").attr("disabled","true").css({'color':"#ccc"}); $("#getYzm").html(count_down); count_down = count_down-1; var time = setInterval(function () { $("#getYzm").html(count_down); count_down--; if(count_down < 0){ $("#getYzm").removeAttr("disabled") .html('发送验证码') .css({'color':'#F63439'}); clearInterval(time); count_down = countDown; } },1000) //----------- // $("#mask").css({'visibility': 'visible'}); // $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val() + "&time=" + new Date().getTime()) // scrollTop02 = scrollTop; // $('body').css({'position':'fixed',"top":-scrollTop}); } //关闭弹层 function closePanel(){ $('#mask').css({'visibility': 'hidden'}); //$('#maskMoney').css({'visibility': 'hidden'}); $("#imgYzm").val(''); $("body").css({"position":"initial"}); $(window).scrollTop(scrollTop02); } /* 点击更换图片验证码*/ function getChangeCodeImg(){ $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val() + "&time=" + new Date().getTime()); } // 输入图片验证码后点击确定请求短信验证码 function goResPanel(){ if($("#imgYzm").val() == ''){ showMsg('请输入图片验证码') return; } registerSecond(); } //发送短信验证码 function registerSecond () { $.ajax({ type:"post", url:"/user/user/registerSecond", dataType:'json', data:{ phone:$("#phone").val(), smstype:1, qrcode:2, image_code:$("#imgYzm").val(), source:source }, success:function (res){ console.log(res) if(res && res.errno == 0){ closePanel(); countDown = res.rst.wait_time; count_down = countDown; var that = this; $("#getYzm").attr("disabled","true").css({'color':"#ccc"}); $("#getYzm").html(count_down); count_down = count_down-1; var time = setInterval(function () { $("#getYzm").html(count_down); count_down--; if(count_down < 0){ $("#getYzm").removeAttr("disabled") .html('发送验证码') .css({'color':'#F63439'}); clearInterval(time); count_down = countDown; } },1000) }else{ showMsg(res.err) } } }); } //登录 function loginEvent () { var myreg = /^[0-9]{11}$/; if (!myreg.test($("#phone").val()) && $("#phone").val() == '15313295256') { //手机号码未填写及填写不正确 showMsg('请正确填写手机号') return; } if($("#phoneYzm").val() !== "123456"){ showMsg('请正确输入短信验证码') return; } if(source == '30070'){ window.location.href='./borrow-money.html' } if(source == '30042'){ window.location.href='./borrow-money02.html' } if(source == '30041'){ window.location.href='./borrow-money03.html' } // loginCodeEvent(); } //短信验证码登录 function loginCodeEvent () { $.ajax({ type:"post", url:"/user/user/loginCode", dataType:'json', data:{ phone:$("#phone").val(), code:$("#phoneYzm").val(), source:source }, success:function(res) { console.log(res) if(res && res.errno == 0){ showMsg('注册成功') window.location.href='./loan.html' }else{ showMsg(res.err) } } }); } //提示信息 function showMsg(msg) { var msg = msg; var msgBox = $('.alert-info'); msgBox.children('p').text(msg); msgBox.show(); setTimeout(function() { msgBox.hide(); }, 2000); } //获取地址栏参数 function parseQueryString(url) { var urlObj = {}; var reg = /([^?=&]+)=([^?=&]+)/g; url.replace(reg, function($0, $1, $2) { urlObj[$1] = decodeURIComponent($2); }) return urlObj; }