123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- import '../css/bootstrap.less';
- // import 'bootstrap/dist/js/bootstrap.js';
- import 'css/newMenu/public.css';
- import 'css/newMenu/header.css'
- import '../css/register.css';
- import './public.js';
- $(function () {
- //查看技淘网协议
- var hht = $(window).height();
- $('.login_').height(hht);
- //登陆
- var hht = $(window).height();
- $('.login').hide();
- //点击账号后面那个×,清空账号
- $(".log_del").click(function () {
- $("#username").focus().val("").css('color','#666');
- });
- 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: '#fe6e42',
- border: 'none'
- })
- } else {
- $(this).prop('checked', false)
- $(this).parent().addClass('cheackeds_no').removeClass('cheackeds');
- $('.sub').attr('disabled', true)
- $('.sub').css({
- background: '#CCCCCC',
- border: 'none'
- })
- }
- })
- //手机号码
- let oldPhoto='';
- $('#photo').attr('disabled', true);
- function photo1() {
- var pho_pattern = /^1[2|3|4|5|6|7|8|9][0-9]{9}$/;
- $("#usePhoto").keyup(function () {
- oldPhoto = $(this).val();
- if (pho_pattern.test(oldPhoto)) {
- tipFun.call(this,false,'')
- $('#photo').attr('disabled', false);
- $("#photo").css("color", "#F18101");
- } else {
- tipFun.call(this,true,'请填写正确的手机号码')
- $('#photo').attr('disabled', true);
- $("#photo").css("color", "#ccc");
- }
- });
- $("#usePhoto").blur(function(){
- if (pho_pattern.test(oldPhoto)) {
- tipFun.call(this,false,'')
- } else {
- tipFun.call(this,true,'请填写正确的手机号码')
- }
- })
- }
- photo1();
- //手机验证码
- function photo_num() {
- $('#photo_num').blur(function () {
- var phoa = $(this).val().trim();
- if (phoa == '') {
- tipFun.call(this,true,'验证码不能为空')
- }else{
- tipFun.call(this,false,'')
- }
- })
- }
- photo_num();
- /*失去焦点处理 */
- blurFun();
- /* 提示框函数处理 */
- function tipFun(state,txt){
- let _this=this;
- if(state){
- $(_this).siblings('.Tips').text(txt);
- $(_this).siblings('.Tips').addClass('active')
- }else{
- $(_this).siblings('.Tips').text('');
- $(_this).siblings('.Tips').removeClass('active')
- }
- }
- function blurFun(){
- $('#username').blur(function(){
- if(!$(this).val().trim()){
- tipFun.call(this,true,'请填写用户名')
- }else {
- tipFun.call(this,false,'')
- }
- })
- $('#userpassword').blur(function () {
- var pass_pattern = /^[a-zA-Z\d_]{6,12}$/;
- var pass1 = $(this).val().trim();
- var tt = $('#userpassword2').val().trim();
- if (!pass1|| !(pass_pattern.test(pass1))) {
- tipFun.call(this,true,'请输入6-12位数的密码')
- }else if(pass1===tt){
- tipFun.call($('#userpassword2'),false,'');
- }else{
- tipFun.call(this,false,'')
- tipFun.call($('#userpassword2'),true,'两次密码不一致');
- }
- });
- $('#customerName').blur(function(){
- if(!$(this).val().trim()){
- tipFun.call(this,true,'请填写客户名称')
- }else{
- tipFun.call(this,false,'')
- }
- });
-
- $('#userpassword2').blur(function () {
- var orepeat = $(this).val();
- var passw = $('#userpassword').val();
- if (passw !== orepeat || passw == '') {
- tipFun.call(this,true,'两次密码不一致')
- }else{
- tipFun.call(this,false,'')
- }
- });
- }
- function initVal(){
- $('#protocol').prop("checked", false)
- $(this).prop('checked', false)
- $(this).parent().addClass('cheackeds_no').removeClass('cheackeds');
- $('.sub').attr('disabled', true)
- $('.sub').css({
- background: '#CCCCCC',
- border: 'none'
- })
- }
- //表单提交
- if(window.location.search.indexOf('code')>-1){
- let code = (window.location.search).split('=');
- $('#beInviteCode').val(code[1]);
- }
- $("#form_register").submit(function (e) {
- e.preventDefault();
- var user = $("#username").val(),
- usePhoto = $('#usePhoto').val(),
- password1 = $("#userpassword").val(),
- password2 = $("#userpassword2").val(),
- customerType = $('#customerTypes').val(),
- mobileCode = $('#photo_num').val(),//手机验证码
- codeV = $('#beInviteCode').val();
- if(password1!==password2){
- tipFun.call($('#userpassword2'),true,'两次密码不一致');
- return;
- };
- if(!usePhoto&&!password1&&!mobileCode){
- $('.Tips').text('请输入内容.');
- $('.Tips').addClass('active');
- return ;
- }
- if($('.Tips.active').length){
- return;
- } else {
- $('.loading').show();
- $.ajax({
- type: "POST",
- dataType: "json",
- url: globalConfig.context + "/register",
- data: {
- "unitName": user,
- "password": password1,
- "mobile": usePhoto,
- "mobileCode": mobileCode,
- "type":customerType,
- "beInviteCode":codeV
- },
- success: function (rest) {
- $('.loading').hide()
- if (rest.error && rest.error.length) {
- msg(rest.error[0].message);
- } else {
- setTimeout(()=>{
- msg("注册成功,请登录个人中心操作");
- initVal();
- if($('.header ul li a').hasClass('head_login')){
- $('.login').fadeIn(800);
- $('#form_register').fadeOut(800)
- }
- },2000)
- }
- }
- })
- }
- })
- agreement();
- function agreement(){
- $('.head_login_').click(function(){
- $('.login_').show();
- })
- $('.login_close_').click(function(){
- $('.login_').hide();
- })
- }
- var tt = 30;
- $('#photo').click(function () {
- var ophoto = $('#usePhoto').val().trim();
- if (ophoto) {
- $.ajax({
- type: "GET",
- url: globalConfig.context + "/open/getMCode",
- data: {
- "mobile": ophoto,
- "sign": false,
- },
- success: function (data) {
- if (data.error && data.error.length) {
- msg(data.error[0].message);
- } else {
- //验证码倒计时
- $('#photo').attr('disabled', true);
- var timer = setInterval(function () {
- tt -= 1;
- $('#photo').val("发送" + '(' + tt + 's' + ')');
- $('#photo').css({
- color: '#cccccc'
- })
- if (tt == 0) {
- clearInterval(timer);
- $('#photo').attr('disabled', false);
- tt = 30;
- $('#photo').css({
- color: '#f18101'
- })
- $('#photo').val('重新发送');
- }
- }.bind(this), 1000);
- msg('发送成功');
- }
- return true;
- }
- });
- } else {
- msg('请填写手机号码!');
- }
- });
- //提示框渐隐函数
- function msg(mess) {
- if($('.smg').hasClass('active')){
- return ;
- }
- $('.smg').addClass('active')
- $('#msg').val(mess);
- setTimeout(function () {
- $('.smg').removeClass('active')
- $('#msg').val('');
- }, 2000)
- }
- //底部图片处理
- footerImg()
- function footerImg(){
- $('.cont_left img').attr('src','');
- $('.cont_center img').attr('src','');
- }
- });
|