login.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel=icon type=image/png href="data:image/png;base64,iVBORw0KGgo=">
  8. <meta name="description" content="">
  9. <meta name="author" content="">
  10. <title>管理后台</title>
  11. <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  12. <style>
  13. body {
  14. padding-top: 50px;
  15. }
  16. .sub-header {
  17. padding-bottom: 10px;
  18. border-bottom: 1px solid #eee;
  19. }
  20. .navbar-fixed-top {
  21. border: 0;
  22. }
  23. .sidebar {
  24. display: none;
  25. }
  26. @media (min-width: 768px) {
  27. .sidebar {
  28. position: fixed;
  29. top: 51px;
  30. bottom: 0;
  31. left: 0;
  32. z-index: 1000;
  33. display: block;
  34. padding: 20px;
  35. overflow-x: hidden;
  36. overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
  37. background-color: #f5f5f5;
  38. border-right: 1px solid #eee;
  39. }
  40. }
  41. .nav-sidebar {
  42. margin-right: -21px; /* 20px padding + 1px border */
  43. margin-bottom: 20px;
  44. margin-left: -20px;
  45. }
  46. .nav-sidebar > li > a {
  47. padding-right: 20px;
  48. padding-left: 20px;
  49. }
  50. .nav-sidebar > .active > a,
  51. .nav-sidebar > .active > a:hover,
  52. .nav-sidebar > .active > a:focus {
  53. color: #fff;
  54. background-color: #428bca;
  55. }
  56. .main {
  57. padding: 20px;
  58. }
  59. @media (min-width: 768px) {
  60. .main {
  61. padding-right: 40px;
  62. padding-left: 40px;
  63. }
  64. }
  65. .main .page-header {
  66. margin-top: 0;
  67. }
  68. .placeholders {
  69. margin-bottom: 30px;
  70. text-align: center;
  71. }
  72. .placeholders h4 {
  73. margin-bottom: 0;
  74. }
  75. .placeholder {
  76. margin-bottom: 20px;
  77. }
  78. .placeholder img {
  79. display: inline-block;
  80. border-radius: 50%;
  81. }
  82. </style>
  83. </head>
  84. <body>
  85. <nav class="navbar navbar-inverse navbar-fixed-top">
  86. <div class="container-fluid">
  87. <div class="navbar-header">
  88. <a class="navbar-brand" href="/">管理后台</a>
  89. </div>
  90. <ul class="nav navbar-nav navbar-right">
  91. <li class="dropdown">
  92. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{session('username')}} <span class="caret"></span></a>
  93. <ul class="dropdown-menu">
  94. <li><a href="/logout">退出</a></li>
  95. </ul>
  96. </li>
  97. </ul>
  98. </div>
  99. </nav>
  100. <div class="container-fluid">
  101. <div class="row">
  102. <div class="container">
  103. <div class="row">
  104. <div class="col-md-8 col-md-offset-2">
  105. <div style="margin-top: 40px;" class="panel panel-default">
  106. <div class="panel-heading">登录</div>
  107. <div class="panel-body">
  108. <form class="form-horizontal" role="form" method="POST" action="{{ url('/dologin') }}">
  109. {!! csrf_field() !!}
  110. <div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
  111. <label class="col-md-4 control-label">账号</label>
  112. <div class="col-md-6">
  113. <input type="username" class="form-control" name="username" value="">
  114. </div>
  115. </div>
  116. <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
  117. <label class="col-md-4 control-label">密码</label>
  118. <div class="col-md-6">
  119. <input type="password" class="form-control" name="password">
  120. </div>
  121. </div>
  122. <div class="form-group">
  123. <div class="col-md-6 col-md-offset-4">
  124. <div class="checkbox">
  125. <label>
  126. <input type="checkbox" name="remember"> 记住登陆状态
  127. </label>
  128. </div>
  129. </div>
  130. </div>
  131. <div class="form-group">
  132. <div class="col-md-6 col-md-offset-4">
  133. <button type="submit" class="btn btn-primary">
  134. <i class="fa fa-btn fa-sign-in"></i>登录
  135. </button>
  136. </div>
  137. </div>
  138. </form>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </body>
  147. <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
  148. <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  149. <script>
  150. function AlertWindow(obj) {
  151. $.ajaxSetup({
  152. headers: {
  153. 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
  154. }
  155. });
  156. this.startEle = obj.startEle || '.js-alert-start';
  157. this.startAjax = obj.startAjax || false;
  158. this.endAjax = obj.endAjax || false;
  159. this.closeEle = obj.closeEle || ".js-modal-close";
  160. this.saveEle = obj.saveEle || ".js-modal-save";
  161. this.errorEle = obj.errorEle || ".js-error-msg";
  162. this.oStartEle = $(this.startEle);
  163. this.formHtml = obj.formHtml;
  164. this.saveHtml =obj.saveHtml;
  165. this.__init__();
  166. }
  167. AlertWindow.prototype.__init__ = function () {
  168. fromOldHtml = '';
  169. //打开
  170. var that = this;
  171. var editid = '';
  172. if(that.startAjax){
  173. that.oStartEle.on('click',function (e) {
  174. e.preventDefault();
  175. var data = {};
  176. if(that.startAjax.data){
  177. data[that.startAjax.data.key] = $(this).data(that.startAjax.data.key);
  178. }
  179. $.ajax({
  180. url:that.startAjax.url,
  181. type:that.startAjax.type || 'get',
  182. data:data,
  183. dataType:'json',
  184. success:function (res) {
  185. if(res.code == 1){
  186. //$(that.startAjax.target).html(res.data)
  187. that.formHtml = res.data;
  188. var title = $(this).data('title') || '编辑';
  189. editid = $(this).data('id');
  190. that.show(title);
  191. }
  192. },
  193. });
  194. })
  195. }else{
  196. that.oStartEle.on('click',function (e) {
  197. e.preventDefault();
  198. var title = $(this).data('title') || '编辑';
  199. editid = $(this).data('id');
  200. that.show(title);
  201. })
  202. }
  203. //提交
  204. console.log(that.saveEle);
  205. $("#myModal .modal-footer").on('click',that.saveEle,function () {
  206. var data = $('.js-ajax-from').serializeArray();
  207. var res = that.formcheck(data,that.endAjax.requiredata) ;
  208. if(!( res === true )){
  209. $('.'+res).addClass('has-error');
  210. $(that.errorEle).html("不能为空").css({"display":"inline"});
  211. return false;
  212. }
  213. //console.log(that.endAjax);
  214. //console.log(data);
  215. var newdata = {};
  216. for(var k in data){
  217. newdata[data[k]['name']] = data[k]['value'];
  218. }
  219. console.log(editid);
  220. if(editid){
  221. newdata['id'] = editid;
  222. }
  223. console.log(newdata);
  224. //return ;
  225. $.ajax({
  226. url:that.endAjax.url,
  227. type:"post",
  228. data:newdata,
  229. dataType:'json',
  230. success:function (response) {
  231. //console.log(response)
  232. if(response.code){
  233. that.hide();
  234. setTimeout(function () {
  235. var html = '<div class="alert alert-success" role="alert">'+response.msg+'</div>';
  236. $('.js-prepend').prepend(html);
  237. setTimeout(function () {
  238. //window.location.reload();
  239. },300)
  240. },10)
  241. }else {
  242. $('.'+res).addClass('has-error');
  243. $(that.errorEle).html(response.msg).css({"display":"inline"});
  244. return false;
  245. }
  246. },
  247. fail:function () {
  248. $(that.errorEle).html("error").css({"display":"inline"});
  249. return false;
  250. }
  251. })
  252. });
  253. //关闭
  254. $(that.closeEle).on('click',function () {
  255. that.hide(that.saveClass);
  256. /*setTimeout(function () {
  257. window.location.reload();
  258. },100)*/
  259. })
  260. };
  261. AlertWindow.prototype.show = function (title) {
  262. $("#myModal .modal-footer").html(this.saveHtml);
  263. $('#myModal .js-ajax-from').html(this.formHtml);
  264. $('body').addClass('modal-open');
  265. $('#myModal').addClass('in').css({"display":"block"});
  266. if(title){
  267. $('#myModalLabel').html(title);
  268. }
  269. $(".form_datetime").datetimepicker({format: 'yyyy-mm-dd hh:ii'});
  270. };
  271. AlertWindow.prototype.hide = function () {
  272. $("#myModal .modal-footer").html("");
  273. $('body').removeClass('modal-open');
  274. $('#myModal').removeClass('in').css({"display":"none"});
  275. };
  276. AlertWindow.prototype.ajax = function (obj) {
  277. //console.log(obj)
  278. $.ajax({
  279. obj
  280. });
  281. };
  282. AlertWindow.prototype.formcheck = function (form,require) {
  283. //console.log(require);
  284. if(!require.length)
  285. return true;
  286. for(var i = 0;i<require.length;i++){
  287. if( form[i].name == require[i] && form[i].value == '')
  288. return require[i];
  289. }
  290. return true;
  291. }
  292. $(function () {
  293. /*var total = $("#hidden-total").val();
  294. $("#js-order-page ul").append("<li><a href='javascript:;'>总计"+total+"</a></li>")
  295. $(".form_datetime").datetimepicker({format: 'yyyy-mm-dd hh:ii'});*/
  296. })
  297. </script>
  298. </html>