imgTab.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
  12. <link href="css/bootstrap.min.css" rel="stylesheet">
  13. <link href="css/toastr.min.css" rel="stylesheet">
  14. <link href="css/browser-fixes.css" rel="stylesheet">
  15. <script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
  16. <script src="js/jquery.min.js"></script>
  17. <script src="js/toastr.min.js"></script>
  18. <script src="js/bootstrap.min.js"></script>
  19. <script src="js/jquery_cookie_min.js"></script>
  20. <script src="js/scripts.js"></script>
  21. <script src="js/jqhttpsdk.js"></script>
  22. <script src="js/jkcor.js"></script>
  23. <script src="js/pages.js"></script>
  24. <script src="js/datachange.js"></script>
  25. </head>
  26. <body>
  27. <div class="clear-backend">
  28. <div class="avatar">
  29. <div>
  30. <a href="javascript:void(0);" target="_blank">
  31. <img src="img/admin.png" alt="">
  32. </a>
  33. </div>
  34. </div>
  35. <div id="zosi" class="menu">
  36. <input type="radio" class="tab-1" name="tab" onclick="location.href='index.html'">
  37. <span>APP</span><i class="fa fa-home"></i>
  38. </div>
  39. <div id="avss" class="menu">
  40. <input type="radio" class="tab-5" name="tab" onclick="location.href='avss_index.html'">
  41. <span>AVSS</span><i class="fa fa-language"></i>
  42. </div>
  43. <div id="zosi_link" class="menu">
  44. <input type="radio" class="tab-6" name="tab" onclick="location.href='zosi_link_index.html'">
  45. <span>Zosi Link</span><i class="fa fa-language"></i>
  46. </div>
  47. <div class="menu">
  48. <input type="radio" class="tab-7" name="tab" onclick="location.href='new_searchTool.html'">
  49. <span> New Search Tool</span><i class="fa fa-language"></i>
  50. </div>
  51. <div class="menu">
  52. <input type="radio" class="tab-8" name="tab" onclick="location.href='old_searchTool.html'">
  53. <span>Old Search Tool</span><i class="fa fa-language"></i>
  54. </div>
  55. <div class="menu">
  56. <input type="radio" class="tab-2" name="tab" onclick="location.href='langTab.html'">
  57. <span>Lang</span><i class="fa fa-medium"></i>
  58. </div>
  59. <div class="menu">
  60. <input type="radio" class="tab-3" name="tab" onclick="location.href='userTab.html'">
  61. <span>Users</span><i class="fa fa-user"></i>
  62. </div>
  63. <div class="menu">
  64. <input type="radio" class="tab-4" name="tab" checked="checked">
  65. <span>Azimg</span><i class="fa fa-image"></i>
  66. </div>
  67. <!-- tab-top-bar -->
  68. <div class="top-bar">
  69. <ul>
  70. <li>
  71. <a href="login.html" title="Log Out">
  72. <i class="fa fa-sign-out"></i>
  73. </a>
  74. </li>
  75. <!--
  76. <li>
  77. <a href="javascript:void(0);" title="Messages">
  78. <i class="fa fa-envelope"></i>
  79. </a>
  80. </li>
  81. -->
  82. <li>
  83. <a href="javascript:void(0);" title="Edit" onclick="editSysFunc()">
  84. <i class="fa fa-edit"></i>
  85. </a>
  86. </li>
  87. </ul>
  88. </div>
  89. <!-- tab-content -->
  90. <div class="tab-content" style="overflow: auto">
  91. <section class="tab-item-4" style="height: 100%;width: 100%;display: block">
  92. <div class="container-fluid">
  93. <div class="row">
  94. <div class="col-md-12">
  95. <form class="form-inline" role="form">
  96. <div class="form-group">
  97. <label class="sr-only" for="asin_add_input">ASIN</label>
  98. <input type="text" class="form-control" id="asin_add_input"
  99. placeholder="请输入ASIN">
  100. </div>
  101. <div class="form-group">
  102. <label class="sr-only" for="url_add_input">链接</label>
  103. <input type="text" class="form-control" id="url_add_input"
  104. placeholder="请输入图片url">
  105. </div>
  106. <button type="submit" class="btn btn-primary" onclick="subAddImgAction();return false;">
  107. 保存
  108. </button>
  109. </form>
  110. </div>
  111. <div class="col-md-12">
  112. <form class="form-inline float-right" role="form">
  113. <div class="form-group">
  114. <input type="text" class="form-control" id="searchInput" placeholder="请输入搜索的ASIN">
  115. </div>
  116. <button type="submit" class="btn btn-primary" onclick="subSearchAsinAction();return false;">
  117. 搜索
  118. </button>
  119. </form>
  120. </div>
  121. </div>
  122. </div>
  123. <hr>
  124. <div class="container-fluid">
  125. <div class="row">
  126. <div class="col-md-12">
  127. <table class="table table-bordered table-hover">
  128. <thead id="tabHead">
  129. <tr>
  130. <th>编号</th>
  131. <th>ASIN</th>
  132. <th>图片URL</th>
  133. <th>MD5</th>
  134. <th>添加时间</th>
  135. <th>更新时间</th>
  136. <th>操作</th>
  137. </tr>
  138. </thead>
  139. <tbody id="tabBody"></tbody>
  140. </table>
  141. </div>
  142. </div>
  143. <div id="pagination"></div>
  144. </div>
  145. <!--模态框start-->
  146. <div class="container-fluid">
  147. <div class="row">
  148. <div class="col-md-12">
  149. <div class="modal fade" id="modal-container-edit" role="dialog"
  150. aria-labelledby="myModalLabel"
  151. aria-hidden="true">
  152. <div class="modal-dialog" role="document">
  153. <div class="modal-content">
  154. <div class="modal-header">
  155. <h5 class="modal-title" id="myModalLabel">
  156. 编辑
  157. </h5>
  158. <button type="button" class="close" data-dismiss="modal">
  159. <span aria-hidden="true">×</span>
  160. </button>
  161. </div>
  162. <div class="modal-body">
  163. <div class="form-group" id="edit_model_form">
  164. </div>
  165. </div>
  166. <div class="modal-footer">
  167. <button type="button" class="btn btn-primary editRowSaveBtn"
  168. onclick="editRow(this);return false;">
  169. 保存
  170. </button>
  171. <button type="button" class="btn btn-secondary" data-dismiss="modal">
  172. 关闭
  173. </button>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. </div>
  179. </div>
  180. </div>
  181. <!--模态框end-->
  182. <!--修改推送邮箱 模态框start -->
  183. <div class="container-fluid">
  184. <div class="row">
  185. <div class="col-md-12">
  186. <div class="modal fade" id="modal-sys-edit" role="dialog"
  187. aria-labelledby="myModalLabel"
  188. aria-hidden="true">
  189. <div class="modal-dialog" role="document">
  190. <div class="modal-content">
  191. <div class="modal-header">
  192. <h5 class="modal-title" id="myModalLabel">
  193. 编辑
  194. </h5>
  195. <button type="button" class="close" data-dismiss="modal">
  196. <span aria-hidden="true">×</span>
  197. </button>
  198. </div>
  199. <div class="modal-body">
  200. <div class="form-group" id="edit_model_form">
  201. <label for="asimgMsgEmailInput">通知邮箱:</label>
  202. <input type="text" class="form-control" id="asimgMsgEmailInput">
  203. <label for="asIntervalINput">时间间隔(小时):</label>
  204. <input type="text" class="form-control" id="asIntervalINput">
  205. </div>
  206. </div>
  207. <div class="modal-footer">
  208. <button type="button" class="btn btn-primary editRowSaveBtn"
  209. onclick="SaveSysFunc(this);return false;">
  210. 保存
  211. </button>
  212. <button type="button" class="btn btn-secondary" data-dismiss="modal">
  213. 关闭
  214. </button>
  215. </div>
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. </div>
  221. </div>
  222. <!--模态框end-->
  223. </section>
  224. </div>
  225. </div>
  226. <script type="text/javascript">
  227. let index_data;
  228. var line = 10;
  229. $(function () {
  230. toastr.options = {
  231. "closeButton": true,
  232. "debug": false,
  233. "newestOnTop": false,
  234. "progressBar": true,
  235. "positionClass": "toast-top-right",
  236. "preventDuplicates": false,
  237. "onclick": null,
  238. "showDuration": "300",
  239. "hideDuration": "500",
  240. "timeOut": "5000",
  241. "extendedTimeOut": "1000",
  242. "showEasing": "swing",
  243. "hideEasing": "linear",
  244. "showMethod": "fadeIn",
  245. "hideMethod": "fadeOut"
  246. };
  247. InitIndex()
  248. });
  249. function InitIndex() {
  250. var page = GetUrlParam('page');
  251. page = page.replace('#', '');
  252. if (!page) {
  253. page = 1
  254. }
  255. let post_data = {
  256. 'token': $.cookie('access_token'),
  257. 'page': page,
  258. 'line': line
  259. }
  260. console.log(isNaN(page))
  261. let searchAsin = $('#searchInput').val()
  262. if (searchAsin) {
  263. post_data['searchAsin'] = searchAsin
  264. }
  265. $('#pagination').empty()
  266. $.postJSON(
  267. http_ip_prot + 'asimg/query', JSON.stringify(post_data),
  268. function (data) {
  269. if (data['code'] == 0) {
  270. console.log(data)
  271. addTable(data['res']);
  272. let count_page = Math.ceil(data['count'] / line);
  273. $('#pagination').pagination({
  274. pages: count_page, //总页数
  275. // pages: 10000, //总页数
  276. edges: 2,
  277. cssStyle: 'pagination', //按纽大小pagination-lg或写入自定义css
  278. displayedPages: 5, //显示几个
  279. onPageClick: function (pageNumber, event) {
  280. //点击时调用
  281. // alert(pageNumber);
  282. queryData(pageNumber)
  283. },
  284. onInit: function (getid) {
  285. //刷新时或初始化调用
  286. // alert(getid);
  287. }
  288. });
  289. } else {
  290. alert(data['msg'])
  291. window.location.href = "http://" + domain + ":7724/web/login.html";
  292. }
  293. }
  294. );
  295. }
  296. function queryData(page) {
  297. let post_data = {
  298. 'token': $.cookie('access_token'),
  299. 'page': page,
  300. 'line': line
  301. };
  302. let searchAsin = $('#searchInput').val()
  303. if (searchAsin) {
  304. post_data['searchAsin'] = searchAsin
  305. }
  306. $.postJSON(
  307. http_ip_prot + 'asimg/query', JSON.stringify(post_data),
  308. function (data) {
  309. if (data['code'] == 0) {
  310. // console.log(data['res'])
  311. console.log(data)
  312. addTable(data['res'])
  313. } else {
  314. alert(data['msg'])
  315. }
  316. }
  317. );
  318. }
  319. function addTable(data) {
  320. index_data = data
  321. let body_html = ''
  322. $.each(data, function (idx, obj) {
  323. let edit_btn = '<a href="javascript:void(0);" title="Edit" onclick="editFunc(\'' + obj['id'] + '\')"><i class="fa fa-edit"></i></a>';
  324. let del_btn = '<a href="javascript:void(0);" title="Delete" onclick="delAsImg(\'' + obj['id'] + '\')"><i class="fa fa-ban"></i></a>';
  325. body_html += '<tr>' +
  326. '<td>' + obj['id'] + '</td>' +
  327. '<td>' + obj['asin'] + '</td>' +
  328. //'<td>' + obj['url'] + '</td>' +
  329. '<td><img width="50px" src="' + obj['url'] + '"/></td>' +
  330. '<td>' + obj['md5'] + '</td>' +
  331. '<td>' + $.DateChange.UnixToDate(obj['addTime'], true, 8) + '</td>' +
  332. '<td>' + $.DateChange.UnixToDate(obj['updTime'], true, 8) + '</td>' +
  333. '<td>' + edit_btn + '&nbsp;&nbsp;&nbsp;' + del_btn + '</td></tr>'
  334. })
  335. $('#tabBody').html(body_html)
  336. }
  337. function delAsImg(id) {
  338. let post_data = {
  339. 'token': $.cookie('access_token'),
  340. 'id': id
  341. }
  342. let cr = confirm('delete it ?')
  343. if (cr) {
  344. $.postJSON(
  345. http_ip_prot + 'asimg/delete', JSON.stringify(post_data),
  346. function (data) {
  347. if (data['code'] == 0) {
  348. console.log(data)
  349. // alert(data['msg'])
  350. window.location.reload()
  351. } else {
  352. alert(data['msg'])
  353. }
  354. }
  355. );
  356. }
  357. }
  358. function editFunc(id) {
  359. // alert(langKey)
  360. $('#modal-container-edit').modal('show')
  361. let html_edit = ''
  362. $.each(index_data, function (idx, obj) {
  363. if (id == obj['id']) {
  364. html_edit = '<input id="editIDInput" type="hidden" value="' + id + '"/>'
  365. html_edit += '<label for="editAsinInput">ASIN</label><input type="text" class="form-control" id="editAsinInput" value="' + obj['asin'] + '">'
  366. html_edit += '<label for="editUrlInput">图片URL</label><input type="text" class="form-control" id="editUrlInput" value="' + obj['url'] + '">'
  367. }
  368. });
  369. $('#edit_model_form').html(html_edit)
  370. }
  371. function editRow() {
  372. let asin = $('#editAsinInput').val()
  373. let url = $('#editUrlInput').val()
  374. let id = $('#editIDInput').val()
  375. let post_data = {
  376. 'token': $.cookie('access_token'),
  377. 'asin': asin,
  378. 'url': url,
  379. 'id': id
  380. }
  381. console.log(post_data)
  382. $.postJSON(
  383. http_ip_prot + 'asimg/update', JSON.stringify(post_data),
  384. function (data) {
  385. if (data['code'] == 0) {
  386. console.log(data)
  387. // alert(data['msg'])
  388. window.location.reload()
  389. } else {
  390. alert(data['msg'])
  391. }
  392. }
  393. );
  394. }
  395. function subAddImgAction() {
  396. let url = $("#url_add_input").val();
  397. let asin = $("#asin_add_input").val();
  398. let post_data = {
  399. 'url': url,
  400. 'asin': asin,
  401. 'token': $.cookie('access_token'),
  402. };
  403. $.postJSON(
  404. http_ip_prot + 'asimg/add',
  405. JSON.stringify(post_data),
  406. function (data) {
  407. if (data['code'] == 0) {
  408. // alert(data['msg'])
  409. toastr["success"]('保存成功')
  410. InitIndex()
  411. // window.location.reload()
  412. } else {
  413. toastr["success"]('保存失败')
  414. console.log(data['msg'])
  415. }
  416. }
  417. );
  418. }
  419. function subSearchAsinAction() {
  420. InitIndex()
  421. }
  422. function editSysFunc() {
  423. $('#modal-sys-edit').modal('show')
  424. let post_data = {
  425. 'token': $.cookie('access_token'),
  426. 'key_list': ['asimgEmail', 'asinterval']
  427. }
  428. $.postJSON(
  429. http_ip_prot + 'sysSet/query', JSON.stringify(post_data),
  430. function (data) {
  431. if (data['code'] == 0) {
  432. console.log('-------------------------------')
  433. console.log(data)
  434. console.log('===============================')
  435. $('#asIntervalINput').val(data['res']['asinterval']/3600)
  436. $('#asimgMsgEmailInput').val(data['res']['asimgEmail'])
  437. } else {
  438. alert(data['msg'])
  439. }
  440. }
  441. );
  442. }
  443. function SaveSysFunc() {
  444. let asinterval = parseInt($('#asIntervalINput').val())
  445. let asimgEmail = $('#asimgMsgEmailInput').val()
  446. let post_data = {
  447. 'update_data': [
  448. {'key': 'asimgEmail', 'val': asimgEmail},
  449. {'key': 'asinterval', 'val': asinterval*3600}
  450. ],
  451. 'token': $.cookie('access_token'),
  452. }
  453. $.postJSON(
  454. http_ip_prot + 'sysSet/update', JSON.stringify(post_data),
  455. function (data) {
  456. if (data['code'] == 0) {
  457. console.log(data);
  458. $('#modal-sys-edit').modal('hide')
  459. } else {
  460. console.log(data)
  461. }
  462. }
  463. )
  464. }
  465. </script>
  466. </body>
  467. </html>