Commit 6f22e973 authored by clone's avatar clone

后台基类,bug修复

parent 35d606af
......@@ -166,6 +166,9 @@ class Shop extends Basic
$result["api_path"] = IMG_PATH;
$param["house_id"] = $params['id'];
$result["images"] = $this->dbImg->getHouseImages($param, 15);
$param["imgtype"] = 4;//图片类型:1效果图,2实景图,3样板图,4户型图,5交通图
$result["plan_images"] = $this->dbImg->getHouseImages($param, 4);
if ($result['room_num_left'] == 0) {
return $this->response("101", '此楼盘已下架');
}
......
......@@ -79,7 +79,7 @@ class Basic extends Controller
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
// $this->tokenVerify();
$this->tokenVerify();
}
}
......
......@@ -17,12 +17,12 @@ class Banner extends Basic
{
protected $bannerModel;
public function __construct()
public function __construct($request = null)
{
parent::__construct($request);
$this->bannerModel = new BannerModel();
}
/**
* 查询banner列表
* @return \think\Response
......
......@@ -27,7 +27,7 @@ class Login extends Basic
public function login()
{
return view("login/login");
return view("/login/login");
}
public function loginVerify()
......@@ -35,7 +35,7 @@ class Login extends Basic
$name = $_POST["username"];
$passwd = $_POST["passwd"];
if (!isset($name) || !isset($passwd)) {
return view("login/login", [ "msg" => "用户名或密码不能为空" ]);
return view("/login/login", [ "msg" => "用户名或密码不能为空" ]);
}
$params["name"] = $name;
$params["pswd"] = md5(md5($passwd));
......@@ -45,11 +45,11 @@ class Login extends Basic
if (count($result) > 0) {
Session::set("userName",$result[0]["name"]);
Session::set("userId",$result[0]["id"]);
Session::set("lastLoginTime",$result[0]["last_login_time"]);
Session::set("lastLoginTime",time());
$this->redirect('banner/banner');
$this->redirect('/index/banner');
} else {
return view("login/login", [ "msg" => "用户名或密码错误" ]);
return view("/login/login", [ "msg" => "用户名或密码错误" ]);
}
}
......
......@@ -12,6 +12,7 @@ namespace app\index\extend;
use think\Controller;
use think\Request;
use think\Response;
use think\Session;
class Basic extends Controller
{
......@@ -23,6 +24,17 @@ class Basic extends Controller
public $params;
public $userName;
public $userId;
public $lastLoginTime;
protected $filterVerify = array(
"index/login",
"index/loginVerify",
);
/**
* 基础接口SDK
* @param Request|null $request
......@@ -39,9 +51,32 @@ class Basic extends Controller
} elseif (strtoupper($this->request->method()) === "POST") {
$this->params = $this->request->param() != null ? $this->request->param() : null;
}
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->userVerify();
}
}
/**
* 验证登录时效
*/
public function userVerify(){
$this->userName = Session::get("userName");
$this->userId = Session::get("userId");
$this->lastLoginTime = Session::get("lastLoginTime");
if(empty($this->userName) || empty($this->userId) || empty($this->lastLoginTime) ){
$this->redirect('/index/login');
}
//登录有效期为1小时
if ((time() - $this->lastLoginTime) > 7200) {
$this->redirect('/index/login');
}
}
/**
* 输出返回数据
* @param string $msg 提示消息内容
......
<script src='/resource/lib/js/require.min.js' data-main='/resource/js/main?version=1111122' charset='utf-8'></script>
\ No newline at end of file
<script src='/resource/lib/js/require.min.js' data-main='/resource/js/main?version=111' charset='utf-8'></script>
\ No newline at end of file
......@@ -17,9 +17,9 @@ require.config ({
'paginationStart': 'lib/js/zw.pagination',
},
'shim': {
/* 'jquery': {
'jquery': {
'exports': 'jquery'
},*/
},
'doT': {
'exports': 'doT'
},
......@@ -30,6 +30,7 @@ require.config ({
'exports': 'ckfinderStart'
},
'bootstrapJs': {
'deps': ['jquery'],
'exports': 'bootstrapJs'
},
'datetimepicker': {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment