tp5跳转页面的优化

tp5跳转页面不太适合正式项目,所以感觉还是有必要进行一下美化的,这里提供两种优化方案供大家选择。一种是不需要点击确定,等待时间到了的话,自己跳转,另外一种则需要点击确定才会进行跳转。

注意:必须要引入layui,代码中的layui地址请自己更换。

  1. 自动跳转

效果图:

(035%41I(T{4WPAP0MVF}32.png

打开tp5根目录下thinkphp/tpl/dispatch_jump.tpl

修改该文件为

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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>
    <!-- 这里需要引入你自己jquery地址,layui 的css和js -->
    <script src="__ADMIN__/style/jquery_002.js"></script>
    <link rel="stylesheet" href="__ADMIN__/plus/layui/css/layui.css" media="all">
    <script src="__ADMIN__/plus/layui/layui.js"></script>
</head>
<body>
    <input type="hidden" id="msg" value="<?php echo(strip_tags($msg));?>" />
    <input type="hidden" id="url" value="<?php echo($url);?>" />
    <input type="hidden" id="wait" value="<?php echo($wait);?>" />
    
    <script type="text/javascript">
     layui.use('layer', function(){
        var layer = layui.layer;
        var msg=$('#msg').val();
        var url=$('#url').val();
        var wait=$('#wait').val();
        layer.msg(msg,{icon: <?php if($code == 1){echo 1;}else{echo 2;};?>,offset: '200px',time:1000} ,function(){
            location.href = url;
        });
    });
</script>
</body>
</html>

2.点击确定才跳转,还是修改该文件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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>
    <script src="__ADMIN__/style/jquery_002.js"></script>
    <link rel="stylesheet" href="__ADMIN__/plus/layui/css/layui.css" media="all">
    <script src="__ADMIN__/plus/layui/layui.js"></script>
</head>
<body>
    <input type="hidden" id="msg" value="<?php echo(strip_tags($msg));?>" />
    <input type="hidden" id="url" value="<?php echo($url);?>" />
    <input type="hidden" id="wait" value="<?php echo($wait);?>" />
    
    <script type="text/javascript">
     layui.use('layer', function(){
        var layer = layui.layer;
        var msg=$('#msg').val();
        var url=$('#url').val();
        var wait=$('#wait').val();
        layer.open({
            icon: <?php if($code == 1){echo 1;}else{echo 2;};?>,
            content: msg,
            offset: '200px',
            yes: function(index, layero,){
                //do something
                location.href = url;
                layer.close(index); //如果设定了yes回调,需进行手工关闭
            }
        });
    });
</script>
</body>
</html>




小安

(๑>ڡ<)☆谢谢老板~

使用微信扫描二维码完成支付

评论
已有 0条评论