第10讲_layer插件美化success等提示框
知识点:
1、config.php页面
// 默认跳转页面对应的模板文件 //'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', //'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', 'dispatch_success_tmpl' => APP_PATH . '/admin/view/public/dispatch.html',
2、在视图层新建public文件夹,新建在public文件夹中新建dispatch.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>跳转提示</title> <link rel="stylesheet" href="__ADMIN__/layui/css/layui.css" /> <script src="__ADMIN__/layui/layui.js"></script> <script src="__ADMIN__/js/jquery.js"></script> </head> <body> <input type="hidden" id="msg" name="msg" value="<?php echo(strip_tags($msg));?>" /> <input type="hidden" id="url" name="url" value="<?php echo(strip_tags($url));?>" /> <input type="hidden" id="wait" name="wait" value="<?php echo(strip_tags($wait));?>" /> <script> (function () { var msg = $("#msg").val(); var url = $("#url").val(); var wait = $("#wait").val(); layer.open({ type: 0, //可传入的值有:0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层) title: ["温馨提示", "font-size:18px; color:orange;"], //数组第二项可以写任意css样式;如果你不想显示标题栏,你可以title: false content: msg, btn: ["确定"], yes: function (index, layero) { console.log("点了确定"); console.log(url); layer.close(index); //如果设定了yes回调,需进行手工关闭 location.href = url; //跳转到指定地址 }, btn2: function (index, layero) { console.log("点了取消"); console.log(url); layer.close(index); location.href = url; //跳转到指定地址 }, }); var interval = setInterval(function () { var time = --wait.innerHTML; if (time <= 0) { location.href = href; clearInterval(interval); } }, 1000); })(); </script> </body> </html>
3、编辑页面的form表单的主要代码:
<form action="?" method="POST">
4、控制器主要代码:
$this->success('配置更新成功!', url('index', ['tab' => $data['tab']]));