IndexController.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\user\controller;
use app\user\model\UserModel;
use cmf\controller\HomeBaseController;
class IndexController extends HomeBaseController
{
/**
* 前台用户首页(公开)
*/
public function index()
{
$id = $this->request->param("id", 0, "intval");
$userModel = new UserModel();
$user = $userModel->where('id', $id)->find();
if (empty($user)) {
$this->error("查无此人!");
}
$this->assign($user->toArray());
$this->assign('user',$user);
return $this->fetch(":index");
}
/**
* 前台ajax 判断用户登录状态接口
*/
function isLogin()
{
if (cmf_is_user_login()) {
$this->success("用户已登录",null,['user'=>cmf_get_current_user()]);
} else {
$this->error("此用户未登录!");
}
}
/**
* 退出登录
*/
public function logout()
{
session("user", null);//只有前台用户退出
return redirect($this->request->root() . "/");
}
}