您现在的位置是:首页>文章详情

laravel 自定义success方法

admin2020-10-05编程经验

简介laravel 自定义success方法

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;

class CommonController extends Controller
{
    /**
     * success 成功后跳转
     * @param $msg
     * @param int $wait
     * @param string $url
     */
    public function success($msg,$wait=1,$url='')
    {

        echo <<<HTML
<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>
    <body>
    <div class="ip-attack">
    <dl>
    <dt style="color: green">{$msg}</dt>
     <br>
        <dt>
            页面自动 <a id="href" href="{$url}">跳转</a> 等待时间: <b id="wait">{$wait}</b>
        </dt></dl>
        </div>
</body>
<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>
HTML;
    }

    /**
     * 失败后跳转
     * @param $msg
     * @param int $wait
     * @param string $url
     */
    public function error($msg,$wait=1,$url='')
    {
        echo <<<HTML
<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>
    <body>
    <div class="ip-attack">
    <dl>
    <dt style="color: red">{$msg}</dt>
     <br>
        <dt>
            页面自动 <a id="href" href="{$url}">跳转</a> 等待时间: <b id="wait">{$wait}</b>
        </dt></dl>
        </div>
</body>
<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>
HTML;
    }
}

编程经验

后端技术

旅行相册

常用工具

影视推荐

前端技术

网站源码

QQ技术教程

破解软件

人生杂记

服务器技术

编程笔记