123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- 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';
- import { DH_NOT_SUITABLE_GENERATOR } from 'constants';
- $(function () {
- //查看技淘网协议
- var hht = $(window).height();
- $('.login_').height(hht);
- $('.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)
- })
- //点击账号后面那个×,清空账号
- $(".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: '#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'
- })
- }
- })
- //手机号码
- let oldPhoto='';
- $('#photo').attr('disabled', true);
- function photo1() {
- var pho_pattern = /^1[3|4|5|7|8][0-9]{9}$/;
- $("#usePhoto").keyup(function () {
- oldPhoto = $(this).val();
- if (pho_pattern.test(oldPhoto)) {
- $('#photo').attr('disabled', false);
- $("#photo").css("color", "#F18101");
- } else if (!pho_pattern.test(oldPhoto)) {
- $('#photo').attr('disabled', true);
- $("#photo").css("color", "#ccc");
- }
- });
- }
- photo1();
- //手机验证码
- function photo_num() {
- $('#photo_num').blur(function () {
- var phoa = $(this).val();
- if (phoa == '') {
- $(this).val('验证码不能为空').css({color:'#f00'});
- }
- })
- }
- photo_num();
- /* 获得焦点处理 */
- $('#username,#customerName,#usePhoto').focus(function(){
- let val = $(this).val();
- if(val.indexOf('用户名')>-1||val.indexOf('下划线')>-1||val.indexOf('客户')>-1||val.indexOf('手机')>-1){
- $(this).val('').css({color:'#333'})
- }
- })
- $('#photo_num').focus(function(){
- if(($(this).val()).indexOf('验证码')>-1){
- $(this).val('')
- }
- $(this).css({color:'#333'})
- })
- $('#userpassword,#userpassword2').focus(function(){
- let passVal =$(this).val();
- console.log(passVal)
- if(passVal.indexOf('密码')>-1){
- $(this).attr('type','password').val('').css({color:'#333'})
- }
- })
- /*失去焦点处理 */
- blurFun();
- function blurFun(){
- $('#username').blur(function(){
- let nameRax = /^[a-zA-Z0-9_-]{6,32}$/;
- if(!$(this).val().trim()){
- $(this).val('请填写用户名').css({color:'#f00'})
- }else if(!nameRax.test($(this).val())){
- $(this).val('6-32位字母/数字/下划线').css({color:'#f00'})
- }
- })
- $('#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)) {
- $(this).attr('type',"text")
- $(this).val('请输入6-12位数字母开头密码').css({color:'#f00'});
- return;
- }else{
- $(this).attr('type','password');
- };
- if (pass1 && tt !== pass1) {
- $('#userpassword2').attr('type',"text")
- $('#userpassword2').val('两次密码不一致').css({color:'#f00'});
- return;
- };
- });
- $('#customerName').blur(function(){
- if(!$(this).val().trim()){
- $(this).val('请填写客户名称').css({color:'#f00'})
- }
- });
- $('#usePhoto').blur(function(){
- if(!$(this).val().trim()){
- $(this).val('请填写手机号码').css({color:'#f00'})
- }
- });
- $('#userpassword2').blur(function () {
- var orepeat = $(this).val();
- var passw = $('#userpassword').val();
- if (passw !== orepeat || passw == '') {
- $(this).attr('type','text')
- $(this).val('两次密码不一致').css({color:'#f00'})
- }
- });
- }
- //表单提交
- $("#form_register").submit(function (e) {
- var user = $("#username").val(),
- usePhoto = $('#usePhoto').val(),
- password1 = $("#userpassword").val(),
- password2 = $("#userpassword2").val(),
- customerName = $('#customerName').val(),
- mobileCode = $('#photo_num').val(); //手机验证码
- e.preventDefault();
- if(user.indexOf('用户名')>-1||customerName.indexOf('客户')>-1||password1.indexOf('密码')>-1||password2.indexOf('密码')>-1||usePhoto.indexOf('手机')>-1||mobileCode.indexOf('验证码')>-1){
- msg('请填写必填项');
- return;
- } else {
- $.ajax({
- type: "POST",
- dataType: "json",
- url: globalConfig.context + "/register",
- data: {
- "username": user,
- "password": password1,
- "unitName": customerName,
- "mobile": usePhoto,
- "mobileCode": mobileCode
- },
- success: function (rest) {
- if (rest.error && rest.error.length) {
- msg(rest.error[0].message);
- } else {
- var data = rest.data;
- console.log(data)
- msg("注册成功!");
- setTimeout(()=>{
- window.location.href = globalConfig.context + "/user/signIn.html";
- },2000)
- }
- }
- })
- }
- })
- 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)
- }
- });
|