66 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!DOCTYPE html>
 | |
| <html lang="en">
 | |
| 
 | |
| <head>
 | |
|   <meta charset="utf-8">
 | |
|   <meta http-equiv="X-UA-Compatible" content="IE=edge">
 | |
|   <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1, user-scalable=no">
 | |
|   <title>登录</title>
 | |
|   <style>
 | |
|     * {
 | |
|       box-sizing: border-box;
 | |
|     }
 | |
|   </style>
 | |
|   <style>
 | |
|     .loading {
 | |
|       position: fixed;
 | |
|       top: 0;
 | |
|       left: 0;
 | |
|       width: 100%;
 | |
|       height: 100%;
 | |
|       background: rgba(255, 255, 255, 0.8);
 | |
|       z-index: 9999;
 | |
|       display: flex;
 | |
|       justify-content: center;
 | |
|       align-items: center;
 | |
|       font-size: 1.5em;
 | |
|       /* Adjust font size for mobile */
 | |
|     }
 | |
| 
 | |
|     @media (max-width: 600px) {
 | |
|       .loading {
 | |
|         font-size: 1em;
 | |
|         /* Smaller font size for smaller screens */
 | |
|       }
 | |
|     }
 | |
|   </style>
 | |
| </head>
 | |
| 
 | |
| <body>
 | |
|   <div class="loading">Loading Code...</div>
 | |
|   <script type="module">
 | |
|     import { loginSuccessUrl } from './config.js';
 | |
|     import { closePage } from './is-wechat.js';
 | |
|     const url = new URL(window.location.href);
 | |
|     const state = url.searchParams.get('state');
 | |
|     const code = url.searchParams.get('code');
 | |
|     // document.body.append(state + '-----------');
 | |
|     // document.body.append(code);
 | |
|     const orgin = url.origin;
 | |
|     const res = await fetch(`${orgin}/api/router?path=wx&key=mplogin&state=${state}&code=${code}`)
 | |
|       .then(res => res.json()).catch(err => {
 | |
|         console.error(err);
 | |
|         alert('登录失败,请稍后再试');
 | |
|         document.body.append('登录失败,请稍后再试');
 | |
|         closePage();
 | |
|       });
 | |
|     // document.body.append(JSON.stringify(res, null, 2));
 | |
|     if (res.code === 200) {
 | |
|       localStorage.setItem('token', res.data.token);
 | |
|     }
 | |
|     closePage();
 | |
| 
 | |
|   </script>
 | |
| </body>
 | |
| 
 | |
| </html> |