laravel添加前台跳转成功页面示例

2020-09-03 12:11:07

创建视图

创建视图success.blade.php

<!doctype html><html lang="{{ str_replace('_', '-', app()->getLocale()) }}">  <head>    <meta charset="utf-8">    <meta name="viewport" content="width=device-width, initial-scale=1">    <script src="{{ asset('/citymedia/js/jquery-1.9.1.min.js') }}"></script>  </head>  <body>  <!-- 代码 begin -->  <div id="applyFor" style="text-align: center; width: 500px; margin: 100px auto;">    {{$message}},将在    <span class="loginTime" style="color: red">{{$jumpTime}}</span>    秒后跳转至    <a href="{{$url}}" rel="external nofollow" style="color: red">{{$urlname}}</a>    页面  </div>  </body></html>  <script type="text/javascript">    $(function(){      var url = "{{$url}}"      var loginTime = parseInt($('.loginTime').text());      var time = setInterval(function(){        loginTime = loginTime-1;        $('.loginTime').text(loginTime);        if(loginTime==0){          clearInterval(time);          window.location.href=url;        }      },1000);    })</script>

在controller里面返回视图

  return view('citymedia.success')->with([    //跳转信息        'message'=>'你已经提交信息,请您耐心等待!',        //自己的跳转路径        'url' =>'/citymedia/interact',        //跳转路径名称        'urlname' =>'互动专区',        //跳转等待时间(s)        'jumpTime'=>2,      ]);
相关文章 大家在看