美化tp5.1跳转提示

<html>
<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>
</head>
<body>
    <script src="/boot_jq/lib/jquery-3.3.1.min.js"></script>
    <script src="/boot_jq/lib/layer/layer.js"></script>
    <!--
    * $msg 待提示的消息
    * $url 待跳转的链接
    * $time 弹出维持时间(单位秒)
    * icon 这里主要有两个layer的表情,5和6,代表(哭和笑)
    -->
    <script type="text/javascript">
        (function(){
            var msg = '<?php echo(strip_tags($msg));?>';
            var url = '<?php echo($url);?>';
            // 去除.html
            url = url.replace(/.html/, "");
            var wait = '<?php echo($wait);?>';
        <?php
            switch ($code) {
                case 1:
                        ?>
                    layer.msg(msg,{icon:"6",time:wait*1000});
                <?php
                    break;
                case 0:
                        ?>
                    layer.msg(msg,{icon:"5",time:wait*1000});
                <?php
                    break;
            }
                ?>
            setTimeout(function(){
                location.href=url;
            },1000)
        })();
    </script>
</body>
</html>

最好配置跳转地址为自己设定的

// 默认跳转页面对应的模板文件
'dispatch_success_tmpl'  => Env::get('root_path') . 'tpl/dispatch_jump.tpl',
'dispatch_error_tmpl'    => Env::get('root_path') . 'tpl/dispatch_jump.tpl',

// 异常页面的模板文件
'exception_tmpl'         => Env::get('root_path') . 'tpl/think_exception.tpl',

在根目录下创建一个tpl文件夹。
避免每次升级thinkphp都会把跳转给覆盖了。

原文地址:https://www.cnblogs.com/jiqing9006/p/9541119.html