markdown格式wiki文档

userlist.php 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4. <meta charset="UTF-8">
  5. <link rel="stylesheet" href="/static/css/bootstrap.min.css">
  6. <script src="/static/js/jquery.min.js"></script>
  7. <script src="/static/js/bootstrap.min.js"></script>
  8. <script src="/static/js/fun.js"></script>
  9. <title>用户列表</title>
  10. <style>
  11. .box {
  12. width: 80%;
  13. margin: auto;
  14. margin-top: 60px;
  15. padding-left: 10px;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <div class="box">
  21. <div class="row col-md-8">
  22. <button type="button" class="btn btn-primary" onclick="add()">新增</button>
  23. <a href="/index" type="button" class="btn btn-default">返回</a>
  24. <table class="table table-bordered">
  25. <thead>
  26. <tr>
  27. <th>
  28. id
  29. </th>
  30. <th>
  31. 用户名
  32. </th>
  33. <th>
  34. 创建时间
  35. </th>
  36. <th>
  37. 删除
  38. </th>
  39. </tr>
  40. </thead>
  41. <tbody>
  42. <?php
  43. foreach ($list as $value) {
  44. ?>
  45. <tr>
  46. <td><?php echo $value['id']; ?></td>
  47. <td><?php echo $value['username']; ?></td>
  48. <td><?php echo date('Y-m-d H:i:s', $value['create_time']); ?></td>
  49. <td>
  50. <a type="button" class="btn btn-primary" href="javascript:add(<?php echo $value['id']; ?>)">
  51. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
  52. <a type="button" class="btn btn-danger" href="javascript:del(<?php echo $value['id']; ?>)">
  53. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
  54. </td>
  55. </tr>
  56. <?php
  57. }
  58. ?>
  59. </tbody>
  60. </table>
  61. </div>
  62. </div>
  63. <!-- 新增 Modal -->
  64. <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel">
  65. <div class="modal-dialog" role="document" style="margin-top: 200px;">
  66. <div class="modal-content modal-add">
  67. <div class="modal-header">
  68. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  69. <h4 class="modal-title" id="addModalLabel">新增</h4>
  70. </div>
  71. <div class="modal-body">
  72. <input type="hidden" name="userid" id="userid" value="0">
  73. <div class="form-group">
  74. <label for="username">用户名</label>
  75. <input type="text" class="form-control" id="username" placeholder="请输入用户名">
  76. </div>
  77. <div class="form-group">
  78. <label for="password">密码</label>
  79. <input type="password" class="form-control" id="password" placeholder="请输入密码">
  80. </div>
  81. <div class="form-group">
  82. <label for="password">确认密码</label>
  83. <input type="password" class="form-control" id="repassword" placeholder="请再次输入密码">
  84. </div>
  85. </div>
  86. <div class="modal-footer">
  87. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  88. <button type="button" class="btn btn-primary" onclick="save()">SAVE</button>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. <!-- model end -->
  94. <script>
  95. function del(id) {
  96. $.post('/userdelete', {
  97. 'userid': id,
  98. }, function(res) {
  99. console.log(res);
  100. if (res.code == 0) {
  101. alert('操作成功');
  102. window.location.reload();
  103. } else {
  104. alert(res.msg);
  105. }
  106. return false;
  107. }, 'json');
  108. }
  109. function add(userid) {
  110. userid = userid || 0;
  111. if (userid != 0) {
  112. $.get('userinfo', {
  113. 'userid': userid,
  114. }, function(res) {
  115. $("#userid").val(res.info.id);
  116. $("#username").val(res.info.username);
  117. $("#username").attr('disabled', true);
  118. }, 'json')
  119. }
  120. $("#addModal").modal('show');
  121. }
  122. function save() {
  123. let userid = document.querySelector('#userid').value;
  124. let username = document.querySelector('#username').value;
  125. let password = document.querySelector('#password').value;
  126. let repassword = document.querySelector('#repassword').value;
  127. if (isNull(password)) {
  128. alert("密码不能为空.");
  129. return false;
  130. }
  131. if (!pwdFormat(password)) {
  132. alert("密码需6位以上.");
  133. return false;
  134. }
  135. if (password != repassword) {
  136. alert("两次密码不一致.");
  137. return false;
  138. }
  139. $.post(
  140. '/usersave', {
  141. "userid": userid,
  142. "username": username,
  143. "password": password,
  144. "repassword": repassword
  145. },
  146. function(res) {
  147. // console.log(res);
  148. if (res.code == 0) {
  149. alert(res.msg);
  150. window.location.reload();
  151. } else {
  152. alert(res.msg);
  153. return false;
  154. }
  155. }, 'json');
  156. }
  157. </script>
  158. </body>
  159. </html>