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 11  
12 12 class MessListController extends \Api\Controller\AbstractController
13 13 {
14   -
  14 + // 禁止系统登录验证
15 15 protected $_require_login = false;
16 16  
17 17 /**
... ... @@ -21,4 +21,5 @@ class MessListController extends \Api\Controller\AbstractController
21 21 {
22 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 14  
15 15 class UserLoginController extends \Api\Controller\AbstractController
16 16 {
  17 + // 禁止系统登录验证
17 18 protected $_require_login = false;
18 19  
  20 + /**
  21 + * 用户登录
  22 + */
19 23 public function Login_post()
20 24 {
21 25 $postData = I('post.');
... ... @@ -25,9 +29,14 @@ class UserLoginController extends \Api\Controller\AbstractController
25 29 ];
26 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 40 $this->_result = [
32 41 'login_flg' => $login_flg
33 42 ];
... ...
trunk/www/apidocassets/css/mess_front.css
... ... @@ -17,7 +17,7 @@ body{
17 17 margin: 0 auto;
18 18 }
19 19 .con table tr{
20   - height: 40px;
  20 + height: 25px;
21 21 }
22 22 .con table tr td{
23 23 text-align: left;
... ...
trunk/www/apidocassets/javascript/mess_front.js
... ... @@ -48,7 +48,27 @@ function jumpLogin()
48 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 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 10 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
7 11 "http://www.w3.org/TR/html4/loose.dtd">
8 12 <html>
... ... @@ -19,12 +23,12 @@
19 23 <form action="http://lys.com/wx5019b9c455ea9c81/Message/Api/Message/MessInput" method="post" id="frm_input">
20 24 <table>
21 25 <caption><h2>发表留言</h2></caption>
22   - <tr>
  26 + <!--<tr>
23 27 <td>姓名:</td>
24 28 <td>
25 29 <input type="text" name="txtName" >
26 30 </td>
27   - </tr>
  31 + </tr>-->
28 32 <tr>
29 33 <td>标题:</td>
30 34 <td>
... ...
trunk/www/mess_front/list.php
... ... @@ -8,5 +8,12 @@
8 8 </head>
9 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 18 </body>
12 19 </html>
13 20 \ No newline at end of file
... ...