userlist.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <title></title>
  7. <meta name="description" content="">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  9. <meta name="robots" content="all,follow">
  10. <!-- Bootstrap CSS-->
  11. <link rel="stylesheet" href="__VENDOR__/bootstrap/css/bootstrap.min.css">
  12. <!-- Font Awesome CSS-->
  13. <link rel="stylesheet" href="__VENDOR__/font-awesome/css/font-awesome.min.css">
  14. <!-- Fontastic Custom icon font-->
  15. <!--<link rel="stylesheet" href="__CSS__/fontastic.css">-->
  16. <link rel="stylesheet" href="__CSS__/iconfont.css">
  17. <!-- Google fonts - Poppins -->
  18. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,700">
  19. <!-- theme stylesheet-->
  20. <link rel="stylesheet" href="__CSS__/style.default.css" id="theme-stylesheet">
  21. <!-- Custom stylesheet - for your changes-->
  22. <link rel="stylesheet" href="__CSS__/custom.css">
  23. <!-- Favicon-->
  24. <link rel="shortcut icon" href="__IMG__/favicon.ico">
  25. <!-- Tweaks for older IEs--><!--[if lt IE 9]>
  26. <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  27. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
  28. </head>
  29. <body>
  30. <div class="page">
  31. <!-- Main Navbar-->
  32. {include file="layout/header" /}
  33. <div class="page-content d-flex align-items-stretch">
  34. <!-- Side Navbar -->
  35. {include file="layout/navigation" /}
  36. <div class="content-inner">
  37. <!-- Page Header-->
  38. <header class="page-header">
  39. <div class="container-fluid">
  40. <h2 class="no-margin-bottom">用户列表</h2>
  41. </div>
  42. </header>
  43. <!-- Breadcrumb-->
  44. <div class="breadcrumb-holder container-fluid">
  45. <ul class="breadcrumb">
  46. <li class="breadcrumb-item">用户管理</li>
  47. <li class="breadcrumb-item active">用户列表</li>
  48. </ul>
  49. </div>
  50. <section class="tables">
  51. <div class="container-fluid">
  52. <div class="row">
  53. <div class="col-lg-12">
  54. <div class="card">
  55. <!--<div class="card-close">
  56. <div class="dropdown">
  57. <button type="button" id="closeCard1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle"><i class="fa fa-ellipsis-v"></i></button>
  58. <div aria-labelledby="closeCard1" class="dropdown-menu dropdown-menu-right has-shadow"><a href="#" class="dropdown-item remove"> <i class="fa fa-times"></i>Close</a><a href="#" class="dropdown-item edit"> <i class="fa fa-gear"></i>Edit</a></div>
  59. </div>
  60. </div>-->
  61. <div class="card-header d-flex align-items-center">
  62. <h3 class="h4">用户列表</h3>
  63. </div>
  64. <div class="card-body">
  65. <div class="form-group col-lg-6" style="float: right;">
  66. <div class="input-group">
  67. <span style="line-height: 2; font-size: 18px; margin-right: 5px;">用户名</span>
  68. <input type="text" id="userName" class="form-control">
  69. <div class="input-group-append">
  70. <button type="button" onclick="onSearch()" class="btn btn-primary">查询</button>
  71. </div>
  72. <div class="input-group-append" style="margin-left: 20px;">
  73. <button type="button" onclick="ondelete()" class="btn btn-primary">删除</button>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="table-responsive">
  78. <table class="table table-striped">
  79. <thead>
  80. <tr>
  81. <th><input type="checkbox" lay-filter="checkeds" lay-skin="primary" class="checkall" onclick="oncheck()"></th>
  82. <th>序号</th>
  83. <th>用户名</th>
  84. <th>注册IP</th>
  85. <th>注册时间</th>
  86. <th>最后登录时间</th>
  87. <th>最后登录IP</th>
  88. <th>手机号</th>
  89. <th>备注</th>
  90. <th>状态</th>
  91. <th>操作</th>
  92. </tr>
  93. </thead>
  94. <tbody>
  95. <?php foreach ($userList as $k => $v): ?>
  96. <tr>
  97. <td class="check-mail">
  98. <input type="checkbox" class="checkone" value="{$k+1}" name="ids" lay-skin="primary">
  99. </td>
  100. <th scope="row">{$k+1}</th>
  101. <td>{$v['user_name']}</td>
  102. <td>{$v['user_register_ip']}</td>
  103. <td><?php echo date('Y-m-d H:i',$v['user_register_time']); ?></td>
  104. <td><?php echo date('Y-m-d H:i',$v['user_last_time']); ?></td>
  105. <td>{$v['user_last_ip']}</td>
  106. <td>{$v['user_phone']}</td>
  107. <td>
  108. <?php
  109. if (strlen($v['user_remark']) <= 40) {echo $v['user_remark'];}
  110. else {echo mb_strcut($v['user_remark'], 0, 60, 'utf-8').'...';}
  111. ?>
  112. </td>
  113. <td>
  114. <?php if ($v['user_status'] == 1): ?>
  115. <span style="color: #26ce16;">启用</span>
  116. <?php else: ?>
  117. <span style="color: red;">禁用</span>
  118. <?php endif; ?>
  119. </td>
  120. <td>
  121. <?php if ($v['user_status'] == 1): ?>
  122. <span onclick="checkStatus({$v['user_id']}, {$v['user_status']})" style="color: #ce2714; cursor:pointer" class="icon iconfont icon-lock-fill" title="禁用"></span>
  123. <?php else: ?>
  124. <span onclick="checkStatus({$v['user_id']}, {$v['user_status']})" style="color: #12a604; cursor:pointer" class="icon iconfont icon-unlock-fill" title="启用"></span>
  125. <?php endif; ?>
  126. </td>
  127. </tr>
  128. <?php endforeach; ?>
  129. </tbody>
  130. </table>
  131. <ul class="list-unstyled" style="display: flex; justify-content: end;">
  132. <?php if (count($page) > 1): ?>
  133. <?php foreach ($page as $k => $v): ?>
  134. <li>
  135. <a onclick="changePage({$v})" style="{$currentPage == $v ? 'pointer-events:none;' : ''}" class="btn btn-xs {$currentPage == $v ? 'btn-secondary' : ''}">{$v}</a>
  136. </li>
  137. <?php endforeach; ?>
  138. <?php endif; ?>
  139. </ul>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </section>
  147. <!-- Page Footer-->
  148. {include file="layout/footer" /}
  149. </div>
  150. </div>
  151. </div>
  152. <!-- JavaScript files-->
  153. <script src="__VENDOR__/jquery/jquery.min.js"></script>
  154. <script src="__VENDOR__/popper.js/umd/popper.min.js"> </script>
  155. <script src="__VENDOR__/bootstrap/js/bootstrap.min.js"></script>
  156. <script src="__VENDOR__/jquery.cookie/jquery.cookie.js"> </script>
  157. <script src="__VENDOR__/chart.js/Chart.min.js"></script>
  158. <script src="__VENDOR__/jquery-validation/jquery.validate.min.js"></script>
  159. <script src="__JS__/jquery.form.js"></script>
  160. <script src="__JS__/plugins/layer/layer.min.js"></script>
  161. <!-- Main File-->
  162. <script src="__JS__/front.js"></script>
  163. <script>
  164. function onSearch() {
  165. let userName = $("#userName").val();
  166. let urlParam = '';
  167. if (userName) {
  168. urlParam = "{:url('admin/index/userlist')}"+"?userName="+userName;
  169. } else {
  170. urlParam = "{:url('admin/index/userlist')}";
  171. }
  172. window.location.href = urlParam;
  173. }
  174. function oncheck() {
  175. if($('.checkall').is(':checked')==true){
  176. $('.checkone').prop('checked',true);
  177. }else{
  178. $('.checkone').prop('checked',false);
  179. }
  180. }
  181. function ondelete() {
  182. let msg = '确认删除所选用户';
  183. layer.confirm(msg, {icon: 3, title:'提示'}, function(index){
  184. var ids = [];
  185. $("input[name='ids']:checked").each(function(i){
  186. ids.push($(this).val())
  187. })
  188. if(ids==''){
  189. layer.msg('未选中任何用户'); return false;
  190. }
  191. //console.log(ids);
  192. $.getJSON("{:url('admin/index/delUser')}", {'ids' : ids}, function(res){
  193. //console.log(res);
  194. if(1 == res.code){
  195. layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
  196. location.reload();
  197. });
  198. }else if(111 == res.code){
  199. window.location.reload();
  200. }else{
  201. layer.alert(res.msg, {title: '友情提示', icon: 2});
  202. }
  203. });
  204. layer.close(index);
  205. })
  206. }
  207. function checkStatus(id, getStatus) {
  208. let msg = '确认禁用此用户';
  209. if (getStatus != 1) {
  210. msg = '确认启用此用户';
  211. }
  212. let status = getStatus == 1 ? 2 : 1;
  213. layer.confirm(msg, {icon: 3, title:'提示'}, function(index){
  214. $.getJSON("{:url('admin/index/updateUser')}", {'id' : id, status: status}, function(res){
  215. if(1 == res.code){
  216. layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
  217. location.reload();
  218. });
  219. }else if(111 == res.code){
  220. window.location.reload();
  221. }else{
  222. layer.alert(res.msg, {title: '友情提示', icon: 2});
  223. }
  224. });
  225. layer.close(index);
  226. })
  227. }
  228. function changePage(page) {
  229. let param = getQueryString();
  230. param.currentPage = page;
  231. let urlParam = "{:url('admin/index/userList')}"+"?"+putUrlParam(param);
  232. window.location.href = urlParam;
  233. }
  234. // 获取URL参数.
  235. function getQueryString() {
  236. var qs = location.search.substr(1), // 获取url中"?"符后的字串
  237. args = {}, // 保存参数数据的对象
  238. items = qs.length ? qs.split("&") : [], // 取得每一个参数项
  239. item = null,
  240. len = items.length;
  241. for(var i = 0; i < len; i++) {
  242. item = items[i].split("=");
  243. var name = decodeURIComponent(item[0]),
  244. value = decodeURIComponent(item[1]);
  245. if(name) {
  246. args[name] = value;
  247. }
  248. }
  249. return args;
  250. }
  251. // 对象转URL参数
  252. function putUrlParam(param) {
  253. let urlParam = '';
  254. let n = 1;
  255. for(let key in param){
  256. if (n === 1) {
  257. urlParam = key+'='+param[key];
  258. } else {
  259. urlParam += '&'+key+'='+param[key];
  260. }
  261. n++;
  262. }
  263. return urlParam;
  264. }
  265. </script>
  266. </body>
  267. </html>