import '../css/bootstrap.less'; import 'bootstrap/dist/js/bootstrap.js'; import '../css/public.css'; import '../css/register.css'; import './public.js'; $(function(){ //查看技淘网协议 var hht=$(window).height(); $('.login_').height(hht); $('.login_').hide() $('.head_login_').click(function(e){ e.preventDefault(); $('.login_').fadeIn(800) }) $('.login_close_').click(function(){ $('.login_').fadeOut(800) }) //登陆 var hht=$(window).height(); $('.login').height(hht); $('.login').hide() $('.head_login').click(function(e){ e.preventDefault(); $('.login').fadeIn(800) }) $('.login_close').click(function(){ $('.login').fadeOut(800) }) //选择专家和企业时要切换 var panduan; $("#qiye").click(function(){ panduan=$('#zhuangjia').prop("checked") ? '0' : '1'; if(panduan==1){ $(".businessName").css("display","block"); $(".linkmanName").css("display","block"); $(".zhuangjiaName").css("display","none"); } }); $("#zhuangjia").click(function(){ panduan=$('#zhuangjia').prop("checked") ? '0' : '1'; if(panduan==0){ $(".businessName").css("display","none"); $(".linkmanName").css("display","none"); $(".zhuangjiaName").css("display","block"); } }); //点击账号后面那个×,清空账号 $(".log_del").click(function(){ $("#username").val(""); $("#photo").css("color","#ccc"); }); //修改单选框的样式 $("#qiye").prop('checked',true); $('#qiye').click(function(){ var Cheack=$(this).prop('checked') if(Cheack){ $(this).parent().addClass('cheackeds').removeClass('cheackeds_no'); $('#zhuangjia').prop('checked',false) $('#zhuangjia').parent().addClass('cheackeds_no').removeClass('cheackeds'); }else{ $('#zhuangjia').prop('checked',true) $('#zhuangjia').parent().addClass('cheackeds').removeClass('cheackeds_no'); $(this).parent().addClass('cheackeds_no').removeClass('cheackeds'); } }) $('#zhuangjia').click(function(){ var Cheack_no=$(this).prop('checked') if(Cheack_no){ $(this).parent().addClass('cheackeds').removeClass('cheackeds_no'); $('#qiye').prop('checked',false) $('#qiye').parent().addClass('cheackeds_no').removeClass('cheackeds'); }else{ $('#qiye').prop('checked',true) $('#qiye').parent().addClass('cheackeds').removeClass('cheackeds_no'); $(this).parent().removeClass('cheackeds').addClass('cheackeds_no'); } }) var xieyi=$('#protocol').prop("checked",false); $('.sub').attr('disabled', true) $('.sub').css({background: '#CCCCCC',border: 'none'}) $('#protocol').click(function(){ var Cheack_no=$(this).prop('checked') if(Cheack_no){ $(this).parent().removeClass('cheackeds_no').addClass('cheackeds'); $('.sub').attr('disabled', false); $('.sub').css({background: '#F18101',border: 'none'}) }else{ $(this).prop('checked',false) $(this).parent().addClass('cheackeds_no').removeClass('cheackeds'); $('.sub').attr('disabled', true) $('.sub').css({background: '#CCCCCC',border: 'none'}) } }) //密码 function pass1(){ $('#userpassword').blur(function () { var pass_pattern=/^\w{6,12}$/; var pass1 = $(this).val(); var tt=$('#userpassword2').val(); if (pass1==''||!pass_pattern.test(pass1)) { $(this).val(''); $(this).attr('placeholder', '请输入6-12位数密码'); } ; if ($(this).val() == ''||tt!==pass1) { $('#userpassword2').val('') $('#userpassword2').attr('placeholder', '确认密码') } ; }); } pass1(); //密码相同 pass2(); function pass2(){ //密码相同验证 $('#userpassword2').blur(function () { var orepeat = $(this).val(); var passw = $('#userpassword').val(); if (passw !== orepeat||passw == '') { $(this).val(''); $(this).attr('placeholder', '确认密码') } }); } //手机号码 function photo1(){ var pho_pattern=/^1[3|4|5|7|8][0-9]{9}$/; $("#username").keyup(function(){ var phol= $(this).val(); if(pho_pattern.test(phol)){ $('#photo').attr('disabled', false); $("#photo").css("color","#F18101"); }else if(!pho_pattern.test(phol)){ $('#photo').attr('disabled', true); $("#photo").css("color","#ccc"); } }); $('#username').blur(function () { var pho= $(this).val(); if (pho==''||!pho_pattern.test(pho)) { $(this).val(''); $(this).attr('placeholder', '请输入正确的号码') } else{ $('#photo').attr('disabled', false); $("#photo").css("color","#F18101"); } }) } photo1(); //手机验证码 function photo_num(){ $('#photo_num').blur(function () { var phoa = $(this).val(); if (phoa=='') { $(this).val(''); $(this).attr('placeholder', '请输入手机上的验证码'); } }) } photo_num(); //单位名称 function photo_name(){ $('#business').blur(function () { var name = $(this).val(); if (name=='') { $(this).val(''); $(this).attr('placeholder', '单位名称'); } }) } photo_name(); //联系人名称 function lxr_name(){ $('#linkman').blur(function () { var name = $(this).val(); if (name=='') { $(this).val(''); $(this).attr('placeholder', '单位联系人姓名'); } }) } lxr_name(); //专家名称 function zj_name(){ $('#man').blur(function () { var name = $(this).val(); if (name=='') { $(this).val(''); $(this).attr('placeholder', '请填写您的姓名'); } }) } zj_name(); //表单提交 $("#form_register").submit(function(e) { var user = $("#username").val(); var password1 = $("#userpassword").val(); var password2 = $("#userpassword2").val(); var types = $('#zhuangjia').prop("checked") ? '0' : '1';//团体/个人 var oname = $('#business').val();//企业名称 var opeople = $('#linkman').val();//企业联系人 var people=$('#man').val();//企业联系人 var Code = $("#piccode").val(); var mobileCode = $('#photo_num').val();//手机验证码 e.preventDefault(); if(user==''||password1==''||password2==''||Code==''||mobileCode==''){ return false; }else if(types==0){ if(people==''){ return false; }else{ $.ajax({ type: "POST", dataType: "json", url: globalConfig.context + "/register", data: { "mobile": user, "password": password1, "type": types, "contacts": people, "verficationCode":Code, "mobileCode": mobileCode }, success: function (rest) { if (rest.error && rest.error.length) { $('#msg').val(rest.error[0].message); msg(); } else { var data = rest.data; if (data && data.requestURI) { var path = globalConfig.context + data.requestURI if (data.queryString) { path += '?' + data.queryString; } if (window.location.hash) { path += window.location.hash; } window.location.href = path; } else { window.location.href = globalConfig.context + "/user/account/index.html"; } return true; } } }) } } else if(types==1){ if(opeople==''||oname==''){ return false; }else{ $.ajax({ type: "POST", dataType: "json", url: globalConfig.context + "/register", data: { "mobile": user, "password": password1, "type": types, "companyName": oname, "contacts": opeople, "verficationCode":Code, "mobileCode": mobileCode }, success: function (rest) { if (rest.error && rest.error.length) { $('#msg').val(rest.error[0].message); msg(); } else { var data = rest.data; if (data && data.requestURI) { var path = globalConfig.context + data.requestURI if (data.queryString) { path += '?' + data.queryString; } if (window.location.hash) { path += window.location.hash; } window.location.href = path; } else { window.location.href = globalConfig.context + "/user/account/index.html"; } return true; } } }) } } }) //点击刷新图片验证码 $('.yanzhengma_cont').click(function () { $('.yanzhengma_cont img').attr('src', (globalConfig.context + "/open/getVCode?t=" + Math.random())) }) var tt = 30; $('#photo').click(function () { //手机验证功能 var ophoto = $('#username').val(); var types = $('#zhuangjia').prop("checked") ? '0' : '1'; var phott = $('#piccode').val(); //验证码倒计时 $('#photo').attr('disabled', true); $(this).attr('disabled', true); var timer = setInterval(function () { tt -= 1; $('#photo').attr('disabled', true); $(this).val("发送"+'('+tt+'s'+')'); $(this).css({color:'#cccccc'}) if (tt == 0) { clearInterval(timer); $('#photo').attr('disabled', false); $(this).attr('disabled', false); tt=30; $(this).css({color:'rgb(241, 129, 1)'}) $(this).val('重新发送'); } }.bind(this), 1000); $.ajax({ type: "GET", url: globalConfig.context + "/open/getMCode", data: { "mobile": ophoto, "sign": false, "type": types, "verificationCode": phott }, success: function (data) { if (data.error && data.error.length) { $('#msg').val(data.error[0].message); msg(); } else { $('#msg').val('发送成功'); msg(); } return true; } }); }); //提示框渐隐函数 $('.smg').hide(); function msg(){ var lit=$('#msg').val(); if(lit!==''){ $('.smg').fadeIn(500); } setTimeout(function(){ $('.smg').fadeOut(500); $('#msg').val(''); },2000) } });