- /**
- * 跳转提示函数
- */
- function showMessage(Array $array){
- //验证参数
- if(!emptyempty($array['message']) && !emptyempty($array['url'])){
- $data = [
- 'message' => $array['message'],
- 'url' => $array['url'],
- 'jumpTime' => !emptyempty($array['time']) ? $array['time'] : 2000,
- 'ok'=>!emptyempty($array['ok']) ? $array['ok'] : true
- ];
- } else {
- $data = [
- 'message' => '非法访问!',
- 'url' => 'javascript:history.back();',
- 'jumpTime' => 2000,
- 'ok'=>!emptyempty($array['ok']) ? $array['ok'] : true
- ];
- }
- return view('admin.message',['data' => $data]);
- // return redirect('/message')->with($array);
- }
2.模板页面代码如下:
- @extends('layouts.admin')
- @section('styles')
- <style type="text/css">
- .body-bgcolor{ background-color: #fff}
- .showMsg{border: 1px solid #1e64c8; zoom:1; width:450px; height:172px;position:absolute;top:44%;left:50%;margin:-87px 0 0 -225px}
- .showMsg h5{margin:0px;background-image: url({{asset('images/message/msg.png')}});background-repeat: no-repeat; color:#fff; padding-left:35px; height:25px; line-height:26px;*line-height:28px; overflow:hidden; font-size:14px; text-align:left}
- .showMsg .content{ padding:46px 12px 73px 45px; font-size:14px; height:64px;display: inline-block;}
- .showMsg .bottom{ background:#e4ecf7; margin: 0 1px 1px 1px;line-height:26px; *line-height:30px; height:26px; text-align:center}
- .showMsg .ok,.showMsg .guery{background: url({{asset('images/message/msg_bg.png')}}) no-repeat 0px -560px;}
- .showMsg .guery{background-position: left -460px;}
- </style>
- @endsection
- @section('content')
- <div class="panel-body">
- <div class="showMsg" style="text-align:center">
- <h5>提示信息</h5>
- <div class="content guery">{{ $data['message'] }}</div>
- <div class="bottom">
- @if($data['url'] == 'goback')
- @else
- <a href="{{ $data['url']}}">如果您的浏览器没有自动跳转,请点击这里</a>
- @endif
- @if($data['ok'])
- <script language="javascript">setTimeout("goUrl('{{ $data['url']}}')",{{ $data['jumpTime'] }});</script>
- @endif
- </div>
- </div>
- </div>
- @endsection
3.控制器里使用代码如下:
- return showMessage(['message'=>'修改失败!','url' =>url('subject/index')]);