tp5之如何修改默认success与error界面

1.首先找到tp5目录下thinkphp/tpl/dispatch_jump.tpl文件
{__NOLAYOUT__}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,
    maximum-scale=1.0,user-scalable=no"/>
    <title>跳转提示</title>
    <style type="text/css">
        *{ padding: 0; margin: 0; }
        body{ background: #fff; font-family: "Microsoft Yahei","Helvetica Neue",
        Helvetica,Arial,sans-serif; color: #333; font-size: 16px; }
        .system-message{ padding: 24px 48px; }
        .system-message h1{ font-size: 100px; font-weight: normal; line-height: 120px; 
        margin-bottom: 12px; }
        .system-message .jump{ padding-top: 10px; }
        .system-message .jump a{ color: #333; }
        .system-message .success,.system-message .error{ line-height: 1.8em; font-size: 36px; 
        }
        .system-message .detail{ font-size: 12px; line-height: 20px; margin-top: 12px;
         display: none; }
    </style>
</head>
<body>
    <div class="system-message">
        <?php switch ($code) {?>
            <?php case 1:?>
            <h1>:)</h1>
            <p class="success"><?php echo(strip_tags($msg));?></p>
            <?php break;?>
            <?php case 0:?>
            <h1>:(</h1>
            <p class="error"><?php echo(strip_tags($msg));?></p>
            <?php break;?>
        <?php } ?>
        <p class="detail"></p>
        <p class="jump">
            页面自动 <a id="href" href="<?php echo($url);?>">跳转</a>
             等待时间: <b id="wait"><?php echo($wait);?></b>
        </p>
    </div>
    <script type="text/javascript">
        (function(){
            var wait = document.getElementById('wait'),
                href = document.getElementById('href').href;
            var interval = setInterval(function(){
                var time = --wait.innerHTML;
                if(time <= 0) {
                    location.href = href;
                    clearInterval(interval);
                };
            }, 1000);
        })();
    </script>
</body>
</html>
2.在view目录下新建一个dispatch_jump.html文件,引入html页面后页面的内容自己修改喜欢的样式内容,
以下是楼主自己引入的样式,注意查看这里的变量是否与tp5默认的dispatch_jump.tpl里的变量名称是否一致,
不一致会报错。
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>运超超 | 后台登录</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, 
    user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.4 -->
    <link href="__ADMIN__/style/bootstrap/css/bootstrap.min.css" rel="stylesheet" 
    type="text/css" />
    <!-- Theme style -->
    <link href="__ADMIN__/style/dist/css/AdminLTE.min.css" rel="stylesheet" 
    type="text/css" />
    <!-- iCheck -->
    <link href="__ADMIN__/style/plugins/iCheck/square/blue.css" rel="stylesheet" 
    type="text/css" />
    <style>#imgVerify{width: 120px;margin: 0 auto; text-align: center;display: block;}	
    </style>
    </head>
    <body class="login-page">
    <div class="login-box ma_t_cm">
    
<?php if($code) {?>    
      <!--处理成功-->
      <div class="login-box-body">
      <h4 class="login-box-msg ver_cm"><span class="glyphicon glyphicon-ok 
      ver_cm"></span> <?php echo($msg); ?></h4>
          <a href="javascript:void(0);">页面自动 <a id="href"
           href="<?php echo($url); ?>">跳转</a> 等待时间: <b id="wait">
           <?php echo($wait); 
           ?></b></a><br /><br />  
          <a href="#" target="_parent">网站前台</a>
          <a href="#" target="_parent">管理员后台</a>

      </div>      
<?php }else{?>     
      <!--处理失败-->
       <div class="login-box-body">
      <h4 class="login-box-msg ver_cm"><span class="glyphicon glyphicon-remove
       ver_cm"></span><?php echo($msg); ?></h4>
          <a href="javascript:void(0);">页面自动 <a id="href" 
          href="<?php echo($url); ?>">跳转</a> 等待时间: <b id="wait">
          <?php echo($wait); 
          ?></b></a><br /><br />
          <a href="#" target="_parent">网站前台</a>
          <a href="#" target="_parent">管理员后台</a>
      </div>
<?php }?>      
	    <div class="margin text-center">
	        <div class="copyright">
	            2018-{:date('Y')} &copy; <a href="http://www.yunchaochao.com">
	            运超超</a> <br/>
	            <a href="http://www.yunchaochao.com">临沂超运网络科技有限公司</a>
	        </div>
	    </div>
    </div><!-- /.login-box -->

<script type="text/javascript">

(function(){
var wait = document.getElementById('wait'),href = document.getElementById('href').href;
var interval = setInterval(function(){
	var time = --wait.innerHTML;
	if(time <= 0) {
		location.href = href;
		clearInterval(interval);
	};
}, 1000);
})();

</script>    
  </body>
</html>
3.接下来是最重要的一步,找到你们config.php文件下的默认跳转页面对应的模板文件代码
  // 默认跳转页面对应的模板文件
    'dispatch_success_tmpl'  => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
    'dispatch_error_tmpl'    => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
4.将以上默认的模板文件代码修改为自己引入的dispatch_jump.html文件,
我这里目录为app\admin\view\public\dispatch_jump.html,所以我这将默认的文件路径修改为以下路径。
  // 默认跳转页面对应的模板文件
    'dispatch_success_tmpl'  => APP_PATH . 'admin' . DS . 'view' . DS . 'public' . DS . 'dispatch_jump.html',
    'dispatch_error_tmpl'    => APP_PATH . 'admin' . DS . 'view' . DS . 'public' . DS . 'dispatch_jump.html',
5.来看一下我的跳转界面吧
![这是我的跳转界面,已经替换默认的模板文件了]
(https://img-blog.csdnimg.cn/2020011000051981.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzgzMDkyNA==,size_16,color_FFFFFF,t_70)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值