浏览代码

登录逻辑处理

liting2017 6 年之前
父节点
当前提交
a4bfac4bb4
共有 4 个文件被更改,包括 180 次插入37 次删除
  1. 1 1
      src/css/inded.css
  2. 78 4
      src/css/newMenu/public.css
  3. 87 30
      src/js/public.js
  4. 14 2
      template/index.html

+ 1 - 1
src/css/inded.css

@@ -43,7 +43,7 @@ width:120px;overflow: hidden;
 .wield_cont{width:1200px;height:400px;margin: 20px auto;text-align: center;}
 
 .brands{width:100%;margin-top:-4px;position: relative;}
-.brands a>img{width:100%;}
+.brands img{width:100%;}
 
 
 #hotProject{width:100%;padding-top: 30px;background:url("../../img/indedImg/inded40.png")no-repeat;}

+ 78 - 4
src/css/newMenu/public.css

@@ -585,14 +585,15 @@ a:active{text-decoration:none;}/* 指正在点的链接*/
 .smg{height: 0px;text-align: center;transform: scale(0) ;padding: 0 10px;
     line-height:0px;background:#17a2b8;border-radius: 10px;
     position: fixed;top: 100px; left: 50%;color:#ffffff;
-	transition: all .3s ease-in-out;z-index: 9999999;
+	transition: all .3s ease-in-out;z-index: 9999999;margin-left: -130px;
 	overflow: hidden;
 }
 
-.smg input{transition: all .3s ease-in-out;width: 0px;height: 40px;border: none;background: none;text-align: center;font-size: 14px;}
+.smg input{width:260px;transition: all .3s ease-in-out;height: 0px;border: none;background: none;text-align: center;font-size: 14px;}
 .smg.active input{
 	width: 260px;
 	transition: all .3s ease-in;
+	height: 40px;
 }
 
 .smg.active{
@@ -600,9 +601,7 @@ a:active{text-decoration:none;}/* 指正在点的链接*/
 	line-height: 40px;
     transform: scale(1) ;
 	top: 200px;
-	margin-left: -130px;
     z-index: 9999999999;
-    
 }
 
 
@@ -952,3 +951,78 @@ input:-webkit-autofill {
 	margin-left: 10px;
 }
 
+
+/* 个人企业登陆判断弹出框 */
+.modeLogin.active{
+	width: 300px;
+	height: 220px;
+	transition: all .1s ease-in;
+}
+.modeBj{
+	display: none;
+	position: fixed;
+	width: 100%;
+	height: 100%;
+	top: 0;
+	left: 0;
+	background: transparent;
+	z-index:1999998;
+}
+.modeLogin{
+	width: 0px;
+	height:0px;
+	overflow: hidden;
+	background: #fff;
+	box-shadow: 0 0 40px rgb(44, 44, 44);
+	border-radius: 5px;
+	position: fixed;
+	top: 50%;
+	left: 50%;
+	z-index: 1999999;
+	transform: translate(-50% ,-50%);
+	-webkit-transform: translate(-50% ,-50%);
+	-ms-transform: translate(-50% ,-50%);
+	-moz-transform: translate(-50% ,-50%);
+	-o-transform: translate(-50% ,-50%);
+	transition: all .1s ease-in-out;
+}
+.modeLogin div{
+	clear: both;
+	width: 100%;
+	padding: 0px 60px 0
+}
+.modeLogin span{
+	display: inline-block;
+	margin-bottom: 10px;
+}
+.modeLogin i{
+	display: inline-block;
+	float: right;
+	margin: 10px;
+	font-size: 16px;	
+}
+.modeLogin i:hover{
+	cursor: pointer;
+	color: #f00;
+}
+.modeLogin div button{
+	width: 80px;
+}
+.modeLogin div button.btn-default{
+	margin-left: 15px;
+}
+.modeLogin p.active{
+	background: #17a2b8;
+	color: #fff;
+	border-color: transparent;
+}
+.modeLogin p{
+	cursor: pointer;
+	width: 180px;
+	height: 40px;
+	margin-bottom: 10px;
+	line-height: 38px;
+	font-size: 14px;
+	border: 1px solid #999;
+	text-align: center;
+}

+ 87 - 30
src/js/public.js

@@ -76,24 +76,16 @@ window.onload=function(){
 			$('#form_register').fadeIn(800)
 		}
 	})
-	$('#form_login').submit(function(e){
-		let hrefs=window.location.href,jump=window.location.hash,jumpState=false,
-			urls = hrefs.split('/').pop();
-		if(urls=='evaluate'||urls=='shopList'||jump=='#jump'){
-			jumpState=true;
-		}
-		e.preventDefault();
-		var Suser=$('#Lo_user').val();
-		var Spass=$('#Lo_pass').val();	
-		var type=$(".login_pass>#customerType").val();
-		var check_experts=$('#checks').prop('checked');		
-		if(Suser==''||Spass==''){	
-			msg('请填写用户名/密码.');
-			return false;
-		}else{	
+	//登录调用;
+	function loginBegin(type){
+			let hrefs=window.location.href,jump=window.location.hash,jumpState=false,
+				urls = hrefs.split('/').pop();
+			if(urls=='evaluate'||urls=='shopList'||jump=='#jump'){
+				jumpState=true;
+			}
 			$('.loading').show();		
-			let txt = "登录中,请稍后...",htmls=[],i=0,
-			txtArr = txt.split('');
+			let txt = "登录中,请稍后...",htmls=[],
+				txtArr = txt.split('');
 			txtArr.map(item=>{
 				htmls.push(`
 					<span>${item}</span>
@@ -105,9 +97,9 @@ window.onload=function(){
               dataType: "json",
               url: globalConfig.context + "/signin",
               data: {
-                      "mobile": Suser,
-					  "password": Spass,
-					  'type':type
+				"mobile": $('#Lo_user').val(),
+				"password": $('#Lo_pass').val(),
+				'type':type
               },
               success: function (rest) {
 				    $('.loading').hide();				
@@ -127,22 +119,87 @@ window.onload=function(){
                         } else {
 							if(!jumpState){
 								msg('登录成功,2秒后跳转个人中心');
-									setTimeout(()=>{
-										window.location.href = globalConfig.context + "/user/account/index.html";
-									},2000)
-								}else{
-									msg('登录成功');
-									setTimeout(()=>{
-										window.location.reload();
-									},1000)
-								}
+								setTimeout(()=>{
+									window.location.href = globalConfig.context + "/user/account/index.html";
+								},2000)
+							}else{
+								msg('登录成功');
+								setTimeout(()=>{
+									window.location.reload();
+								},1000)
+							}
                         }                       
 					}
 			   }
           })
-                
+	}
+	$('#form_login').submit(function(e){
+		e.preventDefault();
+		var Suser=$('#Lo_user').val();
+		var Spass=$('#Lo_pass').val();	
+		if(Suser==''||Spass==''){	
+			msg('请填写用户名/密码.');
+			return false;
+		}else{	
+			ininUserType(Suser,Spass)
 		}			
 	})
+	function ininUserType(user,pass){
+		$.ajax({
+			method:'get',
+			dataType:'json',
+			url:globalConfig.context+'/open/loginCheck',
+			data:{
+				"mobile":user,
+				"password":pass,
+			},
+			success:function(data){
+				if (data.error && data.error.length) {					
+					msg(data.error[0].message);	
+					return;
+				}
+				if(data.data.type!=null){
+					loginBegin(data.data.type);
+				}else{
+					$('.modeBj').show(200);
+					$('.modeLogin').addClass('active');
+					modelLogin(data.data.id);
+				}
+			}
+		})
+	}
+	
+	function modelLogin(ids){
+		$('.modeLogin div p').click(function(){
+			$(this).addClass('active').siblings('p').removeClass('active');
+		});
+		$('.modeLogin .btn-default,.modeLogin .delLogin').click(function(){
+			$('.modeLogin').removeClass('active');
+			$('.modeBj').hide(100);
+		});
+		$('.modeLogin .btn-success').click(function(){
+			let typeMode = $('.modeLogin div .active')[1].getAttribute('data-val');
+			if(typeMode==null){
+				return;
+			}
+			$.ajax({
+				method:'post',
+				dataType:'json',
+				url: globalConfig.context+'/open/updateUser',
+				data:{
+					type:typeMode,
+					id:ids
+				},
+				success:function(data){
+					if(data.error&&data.error.length){
+						msg(data.error[0].message);
+						return;	
+					}
+					loginBegin(typeMode);
+				}
+			})
+		})
+	}
 	//提示框渐隐函数
 	function msg(mess) {
 		if($('.smg').hasClass('active')){

+ 14 - 2
template/index.html

@@ -7,11 +7,11 @@
 	<meta name="viewport" content="width=device-width, initial-scale=1.0">
 	<meta http-equiv="X-UA-Compatible" content="ie=edge">
 	<title>首页</title>
-	<!--<link rel="stylesheet" href="../src/css/bootstrap.css">
+	<link rel="stylesheet" href="../src/css/bootstrap.css">
     <link rel="stylesheet" href="../src/css/newMenu/public.css">
     <link rel="stylesheet" href="../src/css/newMenu/header.css">
     <link rel="stylesheet" href="../src/css/newMenu/index.css">
-    <link rel="stylesheet" href="../src/css/inded.css">-->
+    <link rel="stylesheet" href="../src/css/inded.css">
 </head>
 <body>
 	<div class="header">
@@ -780,6 +780,18 @@
 		<div class="smg">
 			<input type="text" name="msg" value="111" id="msg" />
 		</div>
+		<div class="modeBj">
+			<div class="modeLogin">
+				<i class="glyphicon glyphicon-remove delLogin"></i>
+				<div>
+					<span>请选择您的用户类型</span>
+					<p data-val='0' class="active">个人用户</p>
+					<p data-val='1'>企业用户</p>
+					<button class="btn btn-success">确认</button>
+					<button class="btn btn-default">返回</button>
+				</div>
+			</div>
+		</div>
 	</footer>
 </body>