var qs = parseQueryString(window.location.href),user_id,userInfoData; var request = 'http://182.92.118.1:5090'; var key = '',userInfoKey = '',send_cms_key = '',checkCodeKey = '',tpl_id = ''; $().ready(function(){ if(qs.user_id){ user_id = qs.user_id; } if(qs.tpl_id){ tpl_id = qs.tpl_id; } if(qs.key){ key = qs.key; } userInfo();//获取用户信息 }) function userInfo () { //用户信息 $(".loading").show(); $.ajax({ type: 'get', url: request + '/userInfo', data:{ 'user_id':user_id, 'key':key }, success: function (res) { $(".loading").hide(); console.log(res) if(res.status == 200){ userInfoData = res.data; userInfoKey = res.key; $(".SMS_verification .phone").html(userInfoData.mobile.replace(/^(\d{3})\d{4}(\d+)/,"$1****$2")); $(".SMS_verification .title").html(userInfoData.name + '手机号验证'); }else{ showMsg(res.msg) } }, fail: function () { showMsg('网络错误,请稍后再试~') $(".loading").hide(); } }) } function send_cms () { //发送验证码 $(".loading").show(); $.ajax({ type: 'get', url: request + '/send_cms', data:{ 'user_id':user_id, 'key':userInfoKey }, success: function (res) { $(".loading").hide(); console.log(res) if(res.code == 200){ send_cms_key = res.key; $(".authorization_authentication .yzm_button").addClass('yzm_button_active'); var downCount = 60; var time = setInterval(function () { $(".authorization_authentication .yzm_button").html(downCount + 's'); downCount--; if(downCount < 0){ clearInterval(time); $(".authorization_authentication .yzm_button").removeClass('yzm_button_active'); $(".authorization_authentication .yzm_button").html('获取验证码'); } },1000) }else{ showMsg(res.msg) } }, fail: function () { showMsg('网络错误,请稍后再试~') $(".loading").hide(); } }) } function nextStepEnvet(){ //下一步 $(".SMS_verification").hide(); $(".authorization_authentication").show(); document.title='授权认证' $(".authorization_authentication .title span").html(userInfoData.mobile.substring(7)); send_cms();//发送短信 } function getYzmButton () { //获取验证码按钮 if($(".authorization_authentication .yzm_button").attr('class').indexOf('yzm_button_active') == -1){ send_cms();//发送短信 } } function submissionEventYzm(){ //提交验证码 console.log($(".authorization_authentication .yzm_div input").val()); var userCode = $(".authorization_authentication .yzm_div input").val(); if(userCode.trim() == ''){ showMsg('请输入手机验证码'); return; } $(".loading").show(); $.ajax({ type: 'get', url: request + '/checkCode', data:{ 'code':userCode, // 'mobile':userInfoData.mobile, 'user_id':user_id, 'key':send_cms_key }, success: function (res) { $(".loading").hide(); console.log(res) if(res.code == 200){ checkCodeKey = res.key; window.location.href='mySigning.html?user_id=' + user_id }else{ showMsg(res.msg) } }, fail: function () { showMsg('网络错误,请稍后再试~') $(".loading").hide(); } }) } //获取地址栏参数 function parseQueryString(url) { var urlObj = {}; var reg = /([^?=&]+)=([^?=&]+)/g; url.replace(reg, function($0, $1, $2) { urlObj[$1] = decodeURIComponent($2); }) return urlObj; } // 展示错误提示信息 function showMsg(msg) { var msgBox = document.getElementsByClassName('alert-info')[0]; msgBox.getElementsByTagName("p")[0].innerHTML=msg; msgBox.style.display="block"; setTimeout(function() { msgBox.style.display="none"; }, 2000); }