function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } function check_phone(obj){ var model = /^1[1,3,5,7,8][0-9]{9}$/; if(!model.test(obj.value)){ $("#phoneNumber").addClass("error"); $("#phoneNumber").next().text("手机号码不通过"); //alert("手机号码不通过"); }else{ $("#phoneNumber").removeClass("error"); $.ajax({ type: "get", url: "http://api.edu24ol.com/phpapi/isMobileEngaged?phone="+obj.value+"&_="+timestamp, dataType: "jsonp", jsonp: "callback", success: function(json){ if(json.status==1){ $("#phoneNumber").addClass("error"); $("#phoneNumber").next().text("该手机号码已经被注册"); } if(json.status==0){ $("#phoneNumber").removeClass("error"); // $("#phoneNumber").next().text("号码可用"); } }, error: function(){ alert('fail'); } }); $("#phoneNumber").next().text(""); //alert("手机号码验证通过"); } } function yuyue_time(time_str,time_str1){ var zhibo_start_date = new Date((time_str)); var zhibo_end_date = new Date((time_str1)); var M = (zhibo_start_date.getMonth()+1 < 10 ? '0'+(zhibo_start_date.getMonth()+1) : zhibo_start_date.getMonth()+1) + '月'; var D = (zhibo_start_date.getDate() < 10 ? '0' + (zhibo_start_date.getDate()) : zhibo_start_date.getDate()) + '日'; var h = (zhibo_start_date.getHours() < 10 ? '0' + zhibo_start_date.getHours() : zhibo_start_date.getHours()) + ':'; var m = (zhibo_start_date.getMinutes() <10 ? '0' + zhibo_start_date.getMinutes() : zhibo_start_date.getMinutes()); var end_h = (zhibo_end_date.getHours() < 10 ? '0' + zhibo_end_date.getHours() : zhibo_end_date.getHours()) + ':'; var end_m = (zhibo_end_date.getMinutes() <10 ? '0' + zhibo_end_date.getMinutes() : zhibo_end_date.getMinutes()); $(".yvyue .p2").html(M+D+" "+h+m+" -- "+end_h+end_m); } function imagecode(){ $.ajax({ type: "get", async: false, url: "http://api.hqwx.com/phpapi/user/genImageCodeStr?orgId=2&platform=web&appId=wwwedu24ol", dataType: "jsonp", jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback) success: function(json){ $(".codeImg").attr('src',json.verifyCodeStr); $("#codeString").attr("value", json.codeString); }, error: function(){ alert('fail'); } }); } function resetCode(){ $('.btn-send').addClass('disabled'); $('.btn-send').html('120秒后重新发送'); var second = 120; var timer = null; timer = setInterval(function(){ second -= 1; if(second >0 ){ $('.btn-send').html(second+'秒后重新发送'); $('.btn-send').attr("href","javascript:;"); }else{ clearInterval(timer); $('.btn-send').removeClass('disabled'); $('.btn-send').html('获取短信验证码'); $('.btn-send').attr("href","javascript:getValidationCode();"); } },1000); } function getValidationCode(){ $.ajax({ type: "get", url: "http://api.hqwx.com/phpapi/user/sendSmsCode?phone="+$("#phoneNumber").val()+"&codeString="+$("#codeString").val()+"&verifyCode="+$(".imgCode").val()+"&orgId=2&platform=web&appId=wwwedu24ol&_="+new Date().getTime(), dataType: "jsonp", jsonp: "callback", success: function(json){ if(json.status==230){ $(".imgCode").next().next().text("验证码输入错误!"); $(".imgCode").addClass("error"); imagecode(); } if(json.status==1){ resetCode(); $(".verifyCode").next().next().next().text(""); $(".verifyCode").removeClass("error"); } }, error: function(){ alert('fail'); } }); } function allright(){ var model = /^1[1,3,5,7,8][0-9]{9}$/; if(model.test($("#phoneNumber").val())){ $("#phoneNumber").removeClass("error"); $("#phoneNumber").next().text(""); if($(".imgCode").val().length >0){ $(".imgCode").next().next().text(""); $(".imgCode").removeClass("error"); if($(".verifyCode").val().length >0){ $(".verifyCode").next().next().next().text(""); $(".verifyCode").removeClass("error"); $.ajax({ type: "get", url: "http://api.hqwx.com/phpapi/phoneBind?phone="+$("#phoneNumber").val()+"&verifyCode="+$(".verifyCode").val()+"&passport="+$.cookie("passport")+"&_="+new Date().getTime(), dataType: "jsonp", jsonp: "callback", success: function(json){ if(json.status==1){ $(".dialog-bind-phone").css("display","none"); } if(json.status==230){ $(".verifyCode").next().next().next().text("短信验证码输入错误!"); $(".verifyCode").addClass("error"); } }, error: function(){ alert('fail'); } }); }else{ $(".verifyCode").next().next().next().text("短信验证码没有输入!"); $(".verifyCode").addClass("error"); } }else{ $(".imgCode").next().next().text("验证码没有输入!"); $(".imgCode").addClass("error"); } }else{ $("#phoneNumber").addClass("error"); $("#phoneNumber").next().text("手机号码错误!"); } } $(document).ready(function(){ $(document).on("click",".codeImg", function () { imagecode(); }); $(document).on("click",".btn-commit", function () { if($('.btn-commit').is('.disabled')){ }else{ allright(); } }); $(document).on("click",".verifyCode", function () { $(".btn-commit").removeClass("disabled"); }); $(document).on("click",".icon-close", function () { $(".dialog").removeAttr("style"); }); $(document).on("click",".button-group .button-primary", function () { var zhibo_id=$(this); if($.cookie("passport") == null){ window.location.href="/login/?url="+window.location.href+"?zhibo_id="+zhibo_id.data("id"); }else{ var timestamp=new Date().getTime(); if(zhibo_id.data("url")==undefined){ $.ajax({ type: "get", async:false, url: "http://api.hqwx.com/phpapi/userInfo?passport="+$.cookie("passport")+"&orgId=2&appId=wwwedu24ol&platform=web&_="+timestamp, dataType: "jsonp", jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback) success: function(json){ if(json.status==1){ if(json.data[0].isMobileVerified==false){ $(".dialog-bind-phone").css("display","block"); imagecode(); }else{ $.ajax({ type: "get", async:false, url: "http://www.hqwx.com/zhibo/kcsubscribe?keid="+zhibo_id.data("id")+"&source=5&terminaltype=3&_="+timestamp, dataType: "jsonp", jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback) success: function(json1){ if(json1.status.code==0){ yuyue_time(json1.data.startTime,json1.data.endTime); $(".yvyue .p3").html(json1.data.liveTheme); $(".yvyue").css("display","block"); zhibo_id.removeClass("button-primary"); zhibo_id.addClass("button-disabled"); } if(json1.status.code==-1){ window.location.href="/login/?url="+window.location.href+"?zhibo_id="+zhibo_id.data("id"); } }, error: function(){ alert('fail'); } }); } }else{ window.location.href="/login/?url="+window.location.href+"?zhibo_id="+zhibo_id.data("id"); } }, error: function(){ alert('fail'); } }); }else{ window.location.href="http://www2.hqwx.com/peixun/jzs.html?"+zhibo_id.data("url"); } } }); });