From 59b7e4ef1f8ceecbd9a223b9451efb0add2e6c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Mon, 15 Oct 2018 16:39:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=BA=E7=AB=8B=E7=A9=BA=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E7=B1=BB=E3=80=81=E7=A9=BA=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8=E3=80=81=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/Base.php | 10 ++- application/common/controller/BaseError.php | 26 +++++++ application/error/controller/Index.php | 22 ------ application/home/controller/Error.php | 11 +-- application/home/controller/Index.php | 43 +++++++++- .../view/index/mysuccess.html} | 14 ++-- application/home/view/index/notfound.html | 78 +++++++++++++++++++ application/index/controller/Error.php | 17 +--- application/login/controller/Error.php | 11 +++ application/login/controller/Index.php | 12 ++- application/login/validate/Yanzheng.php | 17 ++-- application/login/view/index/index.html | 2 +- application/member/controller/Error.php | 11 +++ application/student/controller/Error.php | 5 +- application/system/controller/Error.php | 5 +- route/{error.php => home.php} | 3 +- route/login.php | 4 +- 17 files changed, 216 insertions(+), 75 deletions(-) create mode 100644 application/common/controller/BaseError.php delete mode 100644 application/error/controller/Index.php rename application/{error/view/index/index.html => home/view/index/mysuccess.html} (82%) create mode 100644 application/home/view/index/notfound.html create mode 100644 application/login/controller/Error.php create mode 100644 application/member/controller/Error.php rename route/{error.php => home.php} (87%) diff --git a/application/common/controller/Base.php b/application/common/controller/Base.php index da496bb3..dd4f5fc7 100644 --- a/application/common/controller/Base.php +++ b/application/common/controller/Base.php @@ -12,7 +12,15 @@ class Base extends Controller { // 调用Auth中间件进行用户权限验证 - protected $middleware = ['YanZheng']; + protected $middleware = [ + 'YanZheng'=>[ + 'except'=>[ + 'notfound', + 'mysuccess', + 'ajaxData' + ], + ], + ]; public function _empty() { diff --git a/application/common/controller/BaseError.php b/application/common/controller/BaseError.php new file mode 100644 index 00000000..42ae426b --- /dev/null +++ b/application/common/controller/BaseError.php @@ -0,0 +1,26 @@ +redirect(url('/notfound')); + } + + public function _empty() + { + $this->redirect(url('/notfound')); + } + +} diff --git a/application/error/controller/Index.php b/application/error/controller/Index.php deleted file mode 100644 index e3128a32..00000000 --- a/application/error/controller/Index.php +++ /dev/null @@ -1,22 +0,0 @@ -fetch(); - } - - -} diff --git a/application/home/controller/Error.php b/application/home/controller/Error.php index daf29391..132697e4 100644 --- a/application/home/controller/Error.php +++ b/application/home/controller/Error.php @@ -2,13 +2,10 @@ namespace app\home\controller; -use think\Controller; +// 引用空控制器基类 +use app\common\controller\BaseError; -class Error extends Controller +class Error extends BaseError { - public function index() - { - // 跳转页面 - $this->redirect(url('/notfound')); - } + } diff --git a/application/home/controller/Index.php b/application/home/controller/Index.php index a0674aa9..62a83df0 100644 --- a/application/home/controller/Index.php +++ b/application/home/controller/Index.php @@ -7,6 +7,45 @@ use app\common\controller\Base; class Index extends Base { - // 跳转页面 - $this->redirect(url('/notfound')); + + // /** + // * 操作成功跳转 + // * + // * @return \think\Response + // */ + public function mysuccess($msg = '操作成功~') + { + // 模版赋值 + $this->assign('msg',$msg); + + // 跳转页面 + return $this->fetch(); + } + + + /** + * 操作失败跳转 + * + * @return \think\Response + */ + public function notfound() + { + if (session('?msg')) + { + $msg = session('msg'); + session('msg', null); + }else{ + $msg = '不好意思,您访问的页面不存在~'; + } + + + // 模版赋值 + $this->assign('msg',$msg); + + // 跳转页面 + return $this->fetch(); + } + + + } diff --git a/application/error/view/index/index.html b/application/home/view/index/mysuccess.html similarity index 82% rename from application/error/view/index/index.html rename to application/home/view/index/mysuccess.html index f5b504a8..64a26d3a 100644 --- a/application/error/view/index/index.html +++ b/application/home/view/index/mysuccess.html @@ -17,19 +17,19 @@ -404页面 +系统提示
-

- 404 +

+ 系统提示

-

不好意思,您访问的页面不存在~

-

您可以: +

{$msg}

+
\ No newline at end of file diff --git a/application/home/view/index/notfound.html b/application/home/view/index/notfound.html new file mode 100644 index 00000000..cbe141b1 --- /dev/null +++ b/application/home/view/index/notfound.html @@ -0,0 +1,78 @@ + + + + + + + + + +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui/css/H-ui.min.css" /} +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui.admin/css/H-ui.admin.css" /} +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/Hui-iconfont/1.0.8/iconfont.css" /} + +系统提示 + + +
+

+ 系统提示 +

+

{$msg}

+ + +
+
+

+
+{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/jquery/1.9.1/jquery.min.js"} +{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui/js/H-ui.min.js"} +{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui.admin/js/H-ui.admin.js"} + + + + + + \ No newline at end of file diff --git a/application/index/controller/Error.php b/application/index/controller/Error.php index 857c48f5..47118e29 100644 --- a/application/index/controller/Error.php +++ b/application/index/controller/Error.php @@ -2,20 +2,11 @@ namespace app\index\controller; -// 引用控制器类 -use think\Controller; +// 引用空控制器基类 +use app\common\controller\BaseError; -class Error extends Controller +class Error extends BaseError { - /** - * 显示资源列表 - * - * @return \think\Response - */ - public function index() - { - // 跳转页面 - $this->redirect(url('/notfound')); - } + } diff --git a/application/login/controller/Error.php b/application/login/controller/Error.php new file mode 100644 index 00000000..0d6938ab --- /dev/null +++ b/application/login/controller/Error.php @@ -0,0 +1,11 @@ +post('username'); + $data = request()->post(); - if (!$validate->check($data)) { - dump($validate->getError()); + $result = $validate->check($data); + $msg = $validate->getError(); + + + + if(!$result){ + $this->redirect('/notfound',[], 302, ['msg' => $msg]); } - // return true; } } diff --git a/application/login/validate/Yanzheng.php b/application/login/validate/Yanzheng.php index 06ea501f..500b6b53 100644 --- a/application/login/validate/Yanzheng.php +++ b/application/login/validate/Yanzheng.php @@ -13,18 +13,13 @@ class Yanzheng extends Validate * @var array */ protected $rule = [ - 'username' => ['require',], - 'password' => 'number' + 'username' => 'require', + 'password' => 'require|number' ]; - - /** - * 定义错误信息 - * 格式:'字段名.规则名' => '错误信息' - * - * @var array - */ + protected $message = [ - 'username.require' => '帐号不能为空', - 'password.number' => '密码必须为纯数字' + 'username.require' => '用户名必须填写', + 'password.require' => '密码必须填写', + 'password.number' => '密码必须是数字', ]; } diff --git a/application/login/view/index/index.html b/application/login/view/index/index.html index bcc850ca..331e50e6 100644 --- a/application/login/view/index/index.html +++ b/application/login/view/index/index.html @@ -38,7 +38,7 @@
- +
diff --git a/application/member/controller/Error.php b/application/member/controller/Error.php new file mode 100644 index 00000000..d94cb44d --- /dev/null +++ b/application/member/controller/Error.php @@ -0,0 +1,11 @@ +