Commit 37d6de1baebe59c6142fb37dd1dd3b26a1db3667

Authored by luoyanshou
1 parent 7b0367f5

【留言板】登录逻辑实现

trunk/Message/Api/Controller/Message/MessListController.class.php
@@ -11,7 +11,7 @@ namespace Api\Controller\Message; @@ -11,7 +11,7 @@ namespace Api\Controller\Message;
11 11
12 class MessListController extends \Api\Controller\AbstractController 12 class MessListController extends \Api\Controller\AbstractController
13 { 13 {
14 - 14 + // 禁止系统登录验证
15 protected $_require_login = false; 15 protected $_require_login = false;
16 16
17 /** 17 /**
@@ -21,4 +21,5 @@ class MessListController extends \Api\Controller\AbstractController @@ -21,4 +21,5 @@ class MessListController extends \Api\Controller\AbstractController
21 { 21 {
22 $this->_result = '留言列表'; 22 $this->_result = '留言列表';
23 } 23 }
  24 +
24 } 25 }
trunk/Message/Api/Controller/User/UserLoginController.class.php
@@ -14,8 +14,12 @@ use Common\Model\LuoyanshouModel as UserModel; @@ -14,8 +14,12 @@ use Common\Model\LuoyanshouModel as UserModel;
14 14
15 class UserLoginController extends \Api\Controller\AbstractController 15 class UserLoginController extends \Api\Controller\AbstractController
16 { 16 {
  17 + // 禁止系统登录验证
17 protected $_require_login = false; 18 protected $_require_login = false;
18 19
  20 + /**
  21 + * 用户登录
  22 + */
19 public function Login_post() 23 public function Login_post()
20 { 24 {
21 $postData = I('post.'); 25 $postData = I('post.');
@@ -25,9 +29,14 @@ class UserLoginController extends \Api\Controller\AbstractController @@ -25,9 +29,14 @@ class UserLoginController extends \Api\Controller\AbstractController
25 ]; 29 ];
26 $userModel = new UserModel(); 30 $userModel = new UserModel();
27 31
28 - $total = $userModel->count_by_conds( $conds );  
29 - $login_flg = ( $total == 1) ? true : false; 32 + $userInfo = $userModel->get_by_conds( $conds );
30 33
  34 + $login_flg = ( $userInfo != null) ? true : false;
  35 + if( $login_flg ){
  36 + session_start();
  37 + $_SESSION['userid'] = $userInfo['u_id'];
  38 + }
  39 +
31 $this->_result = [ 40 $this->_result = [
32 'login_flg' => $login_flg 41 'login_flg' => $login_flg
33 ]; 42 ];
trunk/www/apidocassets/css/mess_front.css
@@ -17,7 +17,7 @@ body{ @@ -17,7 +17,7 @@ body{
17 margin: 0 auto; 17 margin: 0 auto;
18 } 18 }
19 .con table tr{ 19 .con table tr{
20 - height: 40px; 20 + height: 25px;
21 } 21 }
22 .con table tr td{ 22 .con table tr td{
23 text-align: left; 23 text-align: left;
trunk/www/apidocassets/javascript/mess_front.js
@@ -48,7 +48,27 @@ function jumpLogin() @@ -48,7 +48,27 @@ function jumpLogin()
48 return false; 48 return false;
49 } 49 }
50 50
51 - $('#frm_login').submit(); 51 + $.ajax({
  52 + url:'http://lys.com/wx5019b9c455ea9c81/Message/Api/User/UserLogin/Login',
  53 + type:'POST',
  54 + data:{
  55 + name:$('#txtName').val(),
  56 + pwd:$('#txtPwd').val()
  57 + },
  58 + dataType:'json',
  59 + success:function( data ){
  60 + if( data['result']['login_flg'] === true){
  61 + window.location = 'list.php';
  62 + }else{
  63 + return false;
  64 + }
52 65
  66 + },
  67 + error:function(e){
  68 + console.log('error: '+e);
  69 + }
  70 + });
  71 +
  72 + //$('#frm_login').submit();
53 } 73 }
54 74
trunk/www/mess_front/input.PHP
1 <?php 1 <?php
2 2
  3 + session_start();
3 4
  5 + if( !isset($_SESSION['userid']) || empty($_SESSION['userid']) )
  6 + header("Location: login.php");
4 ?> 7 ?>
5 8
  9 +
6 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 10 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
7 "http://www.w3.org/TR/html4/loose.dtd"> 11 "http://www.w3.org/TR/html4/loose.dtd">
8 <html> 12 <html>
@@ -19,12 +23,12 @@ @@ -19,12 +23,12 @@
19 <form action="http://lys.com/wx5019b9c455ea9c81/Message/Api/Message/MessInput" method="post" id="frm_input"> 23 <form action="http://lys.com/wx5019b9c455ea9c81/Message/Api/Message/MessInput" method="post" id="frm_input">
20 <table> 24 <table>
21 <caption><h2>发表留言</h2></caption> 25 <caption><h2>发表留言</h2></caption>
22 - <tr> 26 + <!--<tr>
23 <td>姓名:</td> 27 <td>姓名:</td>
24 <td> 28 <td>
25 <input type="text" name="txtName" > 29 <input type="text" name="txtName" >
26 </td> 30 </td>
27 - </tr> 31 + </tr>-->
28 <tr> 32 <tr>
29 <td>标题:</td> 33 <td>标题:</td>
30 <td> 34 <td>
trunk/www/mess_front/list.php
@@ -8,5 +8,12 @@ @@ -8,5 +8,12 @@
8 </head> 8 </head>
9 <body> 9 <body>
10 10
  11 + <div class="con">
  12 + <table>
  13 +
  14 + </table>
  15 +
  16 + <h6><a href="input.php" target="_blank">在线留言</a></h6>
  17 + </div>
11 </body> 18 </body>
12 </html> 19 </html>
13 \ No newline at end of file 20 \ No newline at end of file