tp5 修改自帶success或error跳轉模板頁面

tp5 修改自帶success或error跳轉模板頁面

咱們在使用tp5或者tp3.2的時候,用的成功或者失敗跳轉提示頁面通常是用框架的。在後續開發過程當中,根據實際項目須要,也是能夠更改的,在此分享一個自用的模板。javascript

首先是看一下tp框架自帶的跳轉模板頁面,以tp5爲例php

在config.php中,咱們能夠看到,success或error都是用的同一個頁面,css

 在默認的狀況下,生成的效果圖就是你們常常看到的那個"笑臉"或"哭臉"html

失敗:,成功:java

修改以後的效果圖,是這樣的android

失敗:,成功:web

下面的是修改以後的dispatch_jump.tpl的源代碼:windows

 1 {__NOLAYOUT__}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  2 <html xmlns="http://www.w3.org/1999/xhtml">  3 <head>  4 <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />  5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  6 <title>跳轉提示</title>  7 <?php if(isMobile()==true){?>  8 <style type="text/css">  9  body, h1, h2, p,dl,dd,dt{margin: 0;padding: 0;font: 15px/1.5 微軟雅黑,tahoma,arial;} 10  body{background:#efefef;} 11  h1, h2, h3, h4, h5, h6 {font-size: 100%;cursor:default;} 12  ul, ol {list-style: none outside none;} 13  a {text-decoration: none;color:#447BC4} 14  a:hover {text-decoration: underline;} 15  .ip-attack{width:100%; margin:200px auto 0;} 16  .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;} 17  .ip-attack dt{text-align:center;} 18  .ip-attack dd{font-size:16px; color:#333; text-align:center;} 19  .tips{text-align:center; font-size:14px; line-height:50px; color:#999;} 20 </style> 21 <?php }else{ ?> 22 <style type="text/css"> 23  body, h1, h2, p,dl,dd,dt{margin: 0;padding: 0;font: 15px/1.5 微軟雅黑,tahoma,arial;} 24  body{background:#efefef;} 25  h1, h2, h3, h4, h5, h6 {font-size: 100%;cursor:default;} 26  ul, ol {list-style: none outside none;} 27  a {text-decoration: none;color:#447BC4} 28  a:hover {text-decoration: underline;} 29  .ip-attack{width:600px; margin:200px auto 0;} 30  .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;} 31  .ip-attack dt{text-align:center;} 32  .ip-attack dd{font-size:16px; color:#333; text-align:center;} 33  .tips{text-align:center; font-size:14px; line-height:50px; color:#999;} 34 </style> 35 <?php }?> 36 37 </head> 38 <body> 39 <div class="ip-attack"><dl> 40 <if condition="$code eq 1" > 41 <dt style="color: green"><?php echo(strip_tags($msg));?></dt> 42 <else/> 43 <dt style="color: red"><?php echo(strip_tags($msg));?></dt> 44 </if> 45 46 <br> 47 <dt> 48 頁面自動 <a id="href" href="<?php echo($url);?>">跳轉</a> 等待時間: <b id="wait"><?php echo($wait);?></b> 49 </dt></dl> 50 </div> 51 <script type="text/javascript"> 52  (function(){ 53 var wait = document.getElementById('wait'), 54  href = document.getElementById('href').href; 55 var interval = setInterval(function(){ 56 var time = --wait.innerHTML; 57 if(time <= 0) { 58  location.href = href; 59  clearInterval(interval); 60  }; 61  }, 1000); 62  })(); 63 </script> 64 </body> 65 </html>

並且,對於移動端,也作了適配,下面是判斷是不是移動端的js方法框架

 1 /**  2  * 功能:是不是移動端  3  *  4  * User: cyf  5  * Time: 2018/7/3 0003 11:01  6  * @return bool  7 */  8 function isMobile()  9 { 10 if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) 11  { 12 return true; 13  } 14 if (isset ($_SERVER['HTTP_VIA'])) 15  { 16 return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false; 17  } 18 if (isset ($_SERVER['HTTP_USER_AGENT'])) 19  { 20 $clientkeywords = array ('nokia', 21 'sony', 22 'ericsson', 23 'mot', 24 'samsung', 25 'htc', 26 'sgh', 27 'lg', 28 'sharp', 29 'sie-', 30 'philips', 31 'panasonic', 32 'alcatel', 33 'lenovo', 34 'iphone', 35 'ipod', 36 'blackberry', 37 'meizu', 38 'android', 39 'netfront', 40 'symbian', 41 'ucweb', 42 'windowsce', 43 'palm', 44 'operamini', 45 'operamobi', 46 'openwave', 47 'nexusone', 48 'cldc', 49 'midp', 50 'wap', 51 'mobile' 52  ); 53 if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) 54  { 55 return true; 56  } 57  } 58 if (isset ($_SERVER['HTTP_ACCEPT'])) 59  { 60 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')))) 61  { 62 return true; 63  } 64  } 65 return false; 66 }
相關文章
相關標籤/搜索