userTab.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <!doctype html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>afaa</title>
  8. <link rel="stylesheet" type="text/css" href="css/normalize.css"/>
  9. <link rel="stylesheet" type="text/css" href="css/default.css">
  10. <link rel="stylesheet" href="css/style.css">
  11. <link href="http://cdn.bootcss.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
  12. <link href="css/bootstrap.min.css" rel="stylesheet">
  13. <script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
  14. <script src="js/jquery.min.js"></script>
  15. <script src="js/bootstrap.min.js"></script>
  16. <script src="js/jquery_cookie_min.js"></script>
  17. <script src="js/scripts.js"></script>
  18. <script src="js/jqhttpsdk.js"></script>
  19. <script src="js/jkcor.js"></script>
  20. <script src="js/pages.js"></script>
  21. </head>
  22. <body>
  23. <div class="clear-backend">
  24. <div class="avatar">
  25. <div>
  26. <a href="#" target="_blank">
  27. <img src="img/admin.png" alt="">
  28. </a>
  29. </div>
  30. </div>
  31. <input type="radio" class="tab-1" name="tab" onclick="location.href='index.html'">
  32. <span>Home</span><i class="fa fa-home"></i>
  33. <input type="radio" class="tab-2" name="tab" onclick="location.href='langTab.html'">
  34. <span>Lang</span><i class="fa fa-medium"></i>
  35. <input type="radio" class="tab-3" name="tab" checked="checked">
  36. <span>Users</span><i class="fa fa-user"></i>
  37. <!-- tab-top-bar -->
  38. <div class="top-bar">
  39. <ul>
  40. <li>
  41. <a href="login.html" title="Log Out">
  42. <i class="fa fa-sign-out"></i>
  43. </a>
  44. </li>
  45. <li>
  46. <a href="" title="Messages">
  47. <i class="fa fa-envelope"></i>
  48. </a>
  49. </li>
  50. <li>
  51. <a href="" title="Edit">
  52. <i class="fa fa-edit"></i>
  53. </a>
  54. </li>
  55. </ul>
  56. </div>
  57. <!-- tab-content -->
  58. <div class="tab-content">
  59. <section class="tab-item-3">
  60. <div class="container-fluid">
  61. <div class="row">
  62. <div class="col-md-12">
  63. <form role="form">
  64. <div class="form-group">
  65. <label for="InputUsername">
  66. 用户
  67. </label>
  68. <input type="text" class="form-control" id="InputUsername"/>
  69. <label for="InputPassword">
  70. 密码
  71. </label>
  72. <input type="text" class="form-control" id="InputPassword"/>
  73. </div>
  74. <button type="submit" class="btn btn-primary" onclick="subRegAction();return false;">
  75. 保存
  76. </button>
  77. </form>
  78. </div>
  79. </div>
  80. </div>
  81. <hr>
  82. <div class="container-fluid">
  83. <div class="row">
  84. <div class="col-md-12">
  85. <table class="table table-bordered table-hover">
  86. <thead id="tabHead">
  87. <tr><th>编号</th>
  88. <th>用户</th>
  89. <th>操作</th></tr>
  90. </thead>
  91. <tbody id="tabBody"></tbody>
  92. </table>
  93. </div>
  94. </div>
  95. </div>
  96. <!--模态框start-->
  97. <div class="container-fluid">
  98. <div class="row">
  99. <div class="col-md-12">
  100. <div class="modal fade" id="modal-container-edit" role="dialog"
  101. aria-labelledby="myModalLabel"
  102. aria-hidden="true">
  103. <div class="modal-dialog" role="document">
  104. <div class="modal-content">
  105. <div class="modal-header">
  106. <h5 class="modal-title" id="myModalLabel">
  107. EDIT
  108. </h5>
  109. <button type="button" class="close" data-dismiss="modal">
  110. <span aria-hidden="true">×</span>
  111. </button>
  112. </div>
  113. <div class="modal-body">
  114. <div class="form-group" id="edit_model_form">
  115. </div>
  116. </div>
  117. <div class="modal-footer">
  118. <button type="button" class="btn btn-primary editRowSaveBtn"
  119. onclick="editRow(this);return false;">
  120. Save changes
  121. </button>
  122. <button type="button" class="btn btn-secondary" data-dismiss="modal">
  123. Close
  124. </button>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <!--模态框end-->
  133. </section>
  134. </div>
  135. </div>
  136. <script type="text/javascript">
  137. let index_data
  138. $(function () {
  139. let post_data = {
  140. 'token': $.cookie('access_token'),
  141. };
  142. $.postJSON(
  143. http_ip_prot + 'user/query', JSON.stringify(post_data),
  144. function (data) {
  145. if (data['code'] == 0) {
  146. console.log(data)
  147. index_data = data['res']
  148. addTable(data['res'])
  149. } else {
  150. alert(data['msg'])
  151. }
  152. }
  153. );
  154. });
  155. function addTable(data) {
  156. let body_html = ''
  157. $.each(data, function (idx, obj) {
  158. let edit_btn = '<a href="#" title="Edit" onclick="editFunc(\'' + obj['id'] + '\')"><i class="fa fa-edit"></i></a>';
  159. let del_btn = '<a href="#" title="Delete" onclick="delArea(\'' + obj['id'] + '\')"><i class="fa fa-ban"></i></a>';
  160. body_html += '<tr><td>' + obj['id'] + '</td><td>' + obj['username'] + '</td><td>' + edit_btn + '&nbsp;&nbsp;&nbsp;' + del_btn + '</td></tr>'
  161. })
  162. $('#tabBody').html(body_html)
  163. }
  164. function subLangAre() {
  165. let access_token = $.cookie('access_token')
  166. let langArea = $('#InputLangArea').val()
  167. let post_data = {
  168. 'token': access_token,
  169. 'lang': langArea,
  170. }
  171. console.log(post_data)
  172. $.postJSON(
  173. http_ip_prot + 'langArea/add',
  174. JSON.stringify(post_data),
  175. function (data) {
  176. if (data['code'] == 0) {
  177. alert(data['msg'])
  178. window.location.reload();
  179. } else {
  180. alert(data['msg'])
  181. }
  182. }
  183. );
  184. }
  185. function delArea(id) {
  186. let post_data = {
  187. 'token': $.cookie('access_token'),
  188. 'id': id
  189. }
  190. let cr = confirm('delete it ?')
  191. if (cr) {
  192. $.postJSON(
  193. http_ip_prot + 'user/delete', JSON.stringify(post_data),
  194. function (data) {
  195. if (data['code'] == 0) {
  196. console.log(data)
  197. // alert(data['msg'])
  198. window.location.reload()
  199. } else {
  200. alert(data['msg'])
  201. }
  202. }
  203. );
  204. }
  205. }
  206. function editFunc(lang_id) {
  207. // alert(langKey)
  208. console.log(index_data)
  209. $('#modal-container-edit').modal('show')
  210. let html_edit = ''
  211. $.each(index_data, function (idx, obj) {
  212. if (lang_id == obj['id']) {
  213. html_edit = '<input type="text" class="form-control" id="editDataInput" value="' + obj['username'] + '" lid="' + lang_id + '">'
  214. }
  215. });
  216. $('#edit_model_form').html(html_edit)
  217. return
  218. // let post_data = {'token': $.cookie('access_token')};
  219. // let html_per = '<label for="lang_key_edit">KEY</label><input class="form-control" type="text" id="lang_key_edit" oldkey="' + langKey + '" value="' + langKey + '"> '
  220. // $.each(la_list, function (idx, obj) {
  221. // console.log(obj);
  222. // html_per += ('<label for="InputLangArea">' + obj['lang'] + ':</label>' +
  223. // '<input type="text" class="form-control" lang="' + obj['lang'] + '" value="' + (lw_data[langKey][obj['lang']] ? lw_data[langKey][obj['lang']] : '') + '"/>')
  224. // });
  225. // // console.log(html_per)
  226. // $('#edit_model_form').html(html_per)
  227. }
  228. function editRow() {
  229. let lang_id = $('#editDataInput').attr('lid')
  230. let lang_area = $('#editDataInput').val()
  231. if (lang_id && lang_area) {
  232. let post_data = {
  233. 'token': $.cookie('access_token'),
  234. 'id': lang_id,
  235. 'lang': lang_area
  236. }
  237. $.postJSON(
  238. http_ip_prot + 'langArea/update', JSON.stringify(post_data),
  239. function (data) {
  240. if (data['code'] == 0) {
  241. console.log(data)
  242. // alert(data['msg'])
  243. window.location.reload()
  244. } else {
  245. alert(data['msg'])
  246. }
  247. }
  248. );
  249. } else {
  250. alert('none')
  251. }
  252. }
  253. function subRegAction() {
  254. let username = $("#InputUsername").val();
  255. let password = $("#InputPassword").val();
  256. let post_data = {
  257. 'username': username,
  258. 'password': password
  259. };
  260. $.postJSON(
  261. http_ip_prot + 'user/register',
  262. JSON.stringify(post_data),
  263. function (data) {
  264. if (data['code'] == 0) {
  265. alert(data['msg'])
  266. window.location.reload()
  267. } else {
  268. alert(data['msg'])
  269. }
  270. }
  271. );
  272. }
  273. </script>
  274. </body>
  275. </html>