ark.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // 帳號登入
  2. $("#btn_login").click(function() {
  3. var username = $('#username').val();
  4. var password = $('#password').val();
  5. var param_string = {
  6. username: username,
  7. password: password
  8. };
  9. if (username == '' || password == '') {
  10. return;
  11. }
  12. $.ajax({
  13. type: 'POST',
  14. url: 'http://api.ptt.cx:8750/api/v1/login/access-token',
  15. data: param_string,
  16. success: function(data, textStatus, jqXHR) {
  17. console.log(data); // test
  18. // 將access_token寫入localStorage
  19. // 導頁進Dashboard介面
  20. Swal.fire({
  21. title: '登入成功',
  22. icon: 'success',
  23. confirmButtonColor: '#3085d6',
  24. });
  25. window.setTimeout(() => {
  26. window.location.href = 'index.html';
  27. }, 1500);
  28. }, error: function(jqXHR, textStatus, errorThrown) {
  29. Swal.fire({
  30. title: '注意',
  31. icon: 'error',
  32. text: '系統問題',
  33. confirmButtonColor: '#3085d6',
  34. });
  35. return false;
  36. }
  37. });
  38. return false;
  39. });