$(document).ready(function () { try { validatecodechange() } catch (e) { } }); /*更换图片验证码*/ function validatecodechange() { var imgobj = $("img[data-name='validatecode']"); imgobj.attr("src", "/validatecode?_=" + math.random()); } //发送短信验证码 function sendphoneclick(smstemplate) { var isvalid = ajaxpagemethod.validator("mobilecontainer"); if (isvalid == false) { return false; } settimeout(function () { setremaintime(); }, 100); var mobilephone = $("#mobile").val(); var postdata = {}; postdata["mobile"] = '' + mobilephone + ''; postdata["validatecode"] = '' + $("input[data-name='validatecode']").val() + ''; postdata["smstemplate"] = '' + smstemplate + '' var ajaxurl = '/sms-sendphonecode-' + mobilephone + ''; //发送短信验证码 $.ajax({ type: 'post', cache: false, url: ajaxurl, data: postdata, datatype: 'json', beforesend: function (xmlhttprequest) { //console.log("开始执行发送短信验证码"); }, success: function (data) { if (data.status == "error") { if (data.text.indexof("[errcode]") != -1) { layer.msg(data.text.replace('[errcode]', '')); curcount = 0; } } try { validatecodechange(); } catch (e) { } try { console.log(data); } catch (e) { } }, complete: function (xmlhttprequest, textstatus) { //console.log("短信验证码发送结束"); } }); } var curcount = 60; //timer处理函数 function setremaintime() { if (curcount == 0) { $("#btnsendphone").removeattr("disabled");//启用按钮 $("#btnsendphone").removeclass("send"); $("#btnsendphone").val("获取短信验证码"); curcount = 60; } else { curcount = curcount - 1; $("#btnsendphone").attr("disabled", true);//启用按钮 $("#btnsendphone").addclass("send"); $("#btnsendphone").val("重新发送(" + curcount + ")"); settimeout(function () { setremaintime() }, 1000); } }