| 
					
				 | 
			
			
				@@ -16,28 +16,37 @@ $("#btn_login").click(function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         type: 'POST', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         url: 'https://api.ptt.cx:8750/api/v1/login/access-token', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         data: param_string, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        success: function(data, textStatus, jqXHR) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            console.log(data); // test 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        success: function(res, textStatus, jqXHR) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            console.log(res); // test 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 將access_token寫入localStorage 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // {access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2N…kyIn0.wwRK7OKPICdbcOhLfgqA5u5uxkhRVP2gQeqEF8tCY4g', token_type: 'bearer'} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var access_token = res.access_token; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 導頁進Dashboard介面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Swal.fire({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                title: '登入成功', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                icon: 'success', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                confirmButtonColor: '#3085d6', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            window.setTimeout(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                window.location.href = 'index.html'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }, 1500); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }, error: function(jqXHR, textStatus, errorThrown) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Swal.fire({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                title: '注意', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                icon: 'error', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                text: '系統問題', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                confirmButtonColor: '#3085d6', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (access_token != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 導頁進Dashboard介面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Swal.fire({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    title: '登入成功', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    icon: 'success', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    confirmButtonColor: '#3085d6' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                window.setTimeout(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    window.location.href = 'index.html'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }, 1500); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, error: function(xhr, status, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            console.log(xhr.responseText); // test 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var res = JSON.parse(xhr.responseText); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (res.detail == 'Incorrect email or password') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Swal.fire({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    title: '注意', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    icon: 'error', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    text: '帳號/密碼錯誤,請重新輸入', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    confirmButtonColor: '#3085d6', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |