tp5 修改自带success或error跳转模板页面

我们在使用tp5或者tp3.2的时候,用的成功或者失败跳转提示页面一般是用框架的。在后续开发过程中,根据实际项目需要,也是可以更改的,在此分享一个自用的模板。

首先是看一下tp框架自带的跳转模板页面,以tp5为例

在config.php中,我们可以看到,success或error都是用的同一个页面,

在默认的情况下,生成的效果图就是大家经常看到的那个"笑脸"或"哭脸"

失败:,成功:

修改之后的效果图,是这样的

失败:,成功:

下面的是修改之后的dispatch_jump.tpl的源代码:

 {__NOLAYOUT__}<!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 name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>跳转提示</title>
<?php if(isMobile()==true){?>
<style type="text/css">
body, h1, h2, p,dl,dd,dt{margin: 0;padding: 0;font: 15px/1.5 微软雅黑,tahoma,arial;}
body{background:#efefef;}
h1, h2, h3, h4, h5, h6 {font-size: 100%;cursor:default;}
ul, ol {list-style: none outside none;}
a {text-decoration: none;color:#447BC4}
a:hover {text-decoration: underline;}
.ip-attack{width:100%; margin:200px auto 0;}
.ip-attack dl{ background:#fff; padding:30px; border-radius:10px;border: 1px solid #CDCDCD;-webkit-box-shadow: 0 0 8px #CDCDCD;-moz-box-shadow: 0 0 8px #cdcdcd;box-shadow: 0 0 8px #CDCDCD;}
.ip-attack dt{text-align:center;}
.ip-attack dd{font-size:16px; color:#333; text-align:center;}
.tips{text-align:center; font-size:14px; line-height:50px; color:#999;}
</style>
<?php }else{ ?>
<style type="text/css">
body, h1, h2, p,dl,dd,dt{margin: 0;padding: 0;font: 15px/1.5 微软雅黑,tahoma,arial;}
body{background:#efefef;}
h1, h2, h3, h4, h5, h6 {font-size: 100%;cursor:default;}
ul, ol {list-style: none outside none;}
a {text-decoration: none;color:#447BC4}
a:hover {text-decoration: underline;}
.ip-attack{width:600px; margin:200px auto 0;}
.ip-attack dl{ background:#fff; padding:30px; border-radius:10px;border: 1px solid #CDCDCD;-webkit-box-shadow: 0 0 8px #CDCDCD;-moz-box-shadow: 0 0 8px #cdcdcd;box-shadow: 0 0 8px #CDCDCD;}
.ip-attack dt{text-align:center;}
.ip-attack dd{font-size:16px; color:#333; text-align:center;}
.tips{text-align:center; font-size:14px; line-height:50px; color:#999;}
</style>
<?php }?> </head>
<body>
<div class="ip-attack"><dl>
<if condition="$code eq 1" >
<dt style="color: green"><?php echo(strip_tags($msg));?></dt>
<else/>
<dt style="color: red"><?php echo(strip_tags($msg));?></dt>
</if> <br>
<dt>
页面自动 <a id="href" href="<?php echo($url);?>">跳转</a> 等待时间: <b id="wait"><?php echo($wait);?></b>
</dt></dl>
</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>

而且,对于移动端,也做了适配,下面是判断是否是移动端的js方法

 /**
* 功能:是否是移动端
*
* User: cyf
* Time: 2018/7/3 0003 11:01
* @return bool
*/
function isMobile()
{
if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
{
return true;
}
if (isset ($_SERVER['HTTP_VIA']))
{
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}
if (isset ($_SERVER['HTTP_USER_AGENT']))
{
$clientkeywords = array ('nokia',
'sony',
'ericsson',
'mot',
'samsung',
'htc',
'sgh',
'lg',
'sharp',
'sie-',
'philips',
'panasonic',
'alcatel',
'lenovo',
'iphone',
'ipod',
'blackberry',
'meizu',
'android',
'netfront',
'symbian',
'ucweb',
'windowsce',
'palm',
'operamini',
'operamobi',
'openwave',
'nexusone',
'cldc',
'midp',
'wap',
'mobile'
);
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
{
return true;
}
}
if (isset ($_SERVER['HTTP_ACCEPT']))
{
if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))))
{
return true;
}
}
return false;
}

tp5 修改自带success或error跳转模板页面的更多相关文章

  1. thinkphp3.2自定义success及error跳转页面

    首先我们需要配置目录 在conf下新建一个config文件 <?php return array( 'TMPL_ACTION_SUCCESS'=>'Public:dispatch_jump ...

  2. thinkphp方法success和error跳转时间以及返回ajax

    Action类的success和error方法第三个参数为数字时候,表示指定页面跳转时间,例如: $,); $,); 如果是ajax跳转 必须用true: $this->success('操作成 ...

  3. thinkphp succes error跳转模板 设置

    执行成功 换成自己想要的模块 下面的路径是默认的模板\ThinkPHP\Tpl\dispatch_jump.tpl D:\wamp\www\ThinkPHP\Tpl\dispatch_jump.tpl ...

  4. yii2自定义json格式success,error跳转

    /** * ---------------------------------------------- * 操作成功跳转的快捷方法 * @access protected * @param stri ...

  5. Thinkphp框架中自定义修改success和error页面

    Thinkphp框架中自定义修改success和error页面 Thinkphp框架的默认success和error太难看,可以自定义设置,步骤如下: (注意:TP原框架中的success跳转有问题, ...

  6. ThinkPHP页面跳转success与error方法

    首先是控制器中,可以使用下代码: config配置如下: 'TMPL_ACTION_ERROR' => 'Public:error', // 默认错误跳转对应的模板文件 'TMPL_ACTION ...

  7. nginx配置url中带问号的rewrite跳转

    今天收到一个需求,要将一个带查询参数的url跳转到另外一个静态url,安装常规的rewrite规则,如: rewrite ^/a.html?id=67$ http://zt.epython.cn/20 ...

  8. ajax中什么时候进success和error

    先简单介绍下ajax: 简单的说Ajax请求通过XMLHttpRequest对象发送请求,该对象有四个状态(readyState): -未初始化.-正在初始化.-发送数据.-正在发送数据.-完成. 当 ...

  9. 关于ajaxFileUpload图片上传,success和error都触发的情况

    最近做到项目使用JQuery的插件ajaxFileUpload~~~ 遇到了非常领人匪夷所思的事情,当图片上传成功之后呢(success),它的error事件也被触发了,情况就是: 后端数据正确返回 ...

随机推荐

  1. Washing Plates 贪心

    https://www.hackerrank.com/contests/101hack41/challenges/washing-plates 给定n个物品,选这个物品,贡献 + p, 不选的话,贡献 ...

  2. sqoop导出hive数据到mysql错误: Caused by: java.lang.RuntimeException: Can't parse input data

    Sqoop Export数据到本地数据库时出现错误,命令如下: sqoop export \ --connect 'jdbc:mysql://202.193.60.117/dataweb?useUni ...

  3. MapReduce的输入格式

    1. InputFormat接口 InputFormat接口包含了两个抽象方法:getSplits()和creatRecordReader().InputFormat决定了Hadoop如何对文件进行分 ...

  4. less css用法思维导图

    Less 是一个Css 预编译器,可以扩展Css语言,添加功能如允许变量(variables),混合(mixins),函数(functions) 和许多其他的技术,让你的Css更具维护性,主题性,扩展 ...

  5. 一个简单的CI分页类

    [php] view plaincopy <span style="font-size:16px;">/** * * 关于 页码有效性的判断需要加在 控制器中判断,即当 ...

  6. ElasticsearchIllegalArgumentException[failed to find analyzer [ik]]问题解决

    ElasticsearchIllegalArgumentException[failed to find analyzer [ik]] 没有找到分词器 请查看本博客经得住实践的文章:http://bl ...

  7. AnyCAD在医疗中的应用

    void addPoint(List<float> buffer, Vector3 pt) { buffer.Add((float)pt.X); buffer.Add((float)pt. ...

  8. 第6章 传输层(详解TCP的三次握手与四次挥手)

    第6章 传输层 传输层简介 传输层为网络应用程序提供了一个接口,并且能够对网络传输提供了可选的错误检测.流量控制和验证功能.TCP/IP传输层包含很多有用的协议,能够提供数据在网络传输所需的必要寻址信 ...

  9. androidStudio修改包名 Android 如何修改包名(同一个手机可以跑2个eros 项目)。

    修改applicationId(gradle.properties). 2.即时同步更新过去,否则不报错

  10. Remote System Explorer Operation在eclipse后台一直跑 解决办法

    在用eclipse开发时,经常遇到卡死的情况,其中一种就是右下角出现:“Remote System Explorer Operation”,解决方案如下: 第一步:Eclipse -> Pref ...