| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>教育平台登录</title>
- <script src="./axios.min.js"></script>
- <style>
- body {
- font-family: Arial, sans-serif;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100vh;
- margin: 0;
- background-color: #f0f2f5;
- }
- .login-container {
- text-align: center;
- background: white;
- padding: 2rem;
- border-radius: 8px;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
- }
- .login-btn {
- display: block;
- width: 200px;
- padding: 12px;
- margin: 20px auto;
- border: none;
- border-radius: 4px;
- color: white;
- font-size: 16px;
- cursor: pointer;
- transition: background-color 0.3s;
- }
- .student-btn {
- background-color: #1890ff;
- }
- .teacher-btn {
- background-color: #52c41a;
- }
- .login-btn:hover {
- opacity: 0.9;
- }
- </style>
- </head>
- <body>
- <!--<div class="login-container">-->
- <!-- <h1>在线教育平台</h1>-->
- <!-- <button class="login-btn student-btn" onclick="login()">登录</button>-->
- <!--</div>-->
- <!--http://localhost:63342/onlineEducation-front/public/html/loginJump.html?_ijt=eqdbr9d1k5uh8if53et5u8j8su&_ij_reload=RELOAD_ON_SAVE&code=126345&type=1&id=1958766027408039938-->
- <script>
- let baseUrl = 'http://192.168.1.213:9003'
- let baseUrlt = 'http://192.168.1.202:9000'
- let baseUrls = 'http://192.168.1.202:9000'
- // 创建axios实例,参考request.js中的配置
- const service = axios.create({
- baseURL: '/api',
- timeout: 5000
- });
- // 登录函数
- const login = async () => {
- const urlParams = new URLSearchParams(window.location.search);
- let code = urlParams.get('code');
- let type = urlParams.get('type');
- let id = urlParams.get('id');
- if (code == undefined || type == undefined) {
- alert('数据参数不对');
- return
- }
- if (type != 1 && id == undefined) {
- alert('数据参数不对 没有id');
- return
- }
- console.log('什么数值呢', code)
- // 这里需要替换为实际的登录接口URL
- const loginUrl = baseUrl+'/api/webapp/disk/CollegeUser/getUser';
- let res = await service.get(loginUrl, {
- params: {
- code
- },
- headers: {
- 'account': 'admin',
- }
- })
- console.log('登录状况:', res.data);
- if (res.data.code === 200) {
- let url = baseUrl+'/api/webapp/auth/b/getLoginUser'
- let ress = await service.get(url, {
- headers: {
- 'token': res.data.msg,
- }
- })
- console.log('获取人员信息:', ress);
- if(ress.data.code == 200 && ress.data.data.eduIdentity == 1){
- //去教师段
- // 构建带参数的URL
- const params = new URLSearchParams({
- token: res.data.msg,
- type,
- id
- });
- const redirectUrl = `${baseUrlt}/jump?${params.toString()}`;
- window.location.href = redirectUrl;
- }
- }
- // .then(response => {
- //
- // // alert('登录成功');
- // // // 保存token等操作
- // // console.log('登录成功:', response.data);
- // // } else {
- // // alert(`登录失败: ${response.data.msg}`);
- // // }
- // })
- // .catch(error => {
- // console.error('登录请求失败:', error);
- // alert('登录请求失败,请检查网络连接');
- // });
- // // 发送登录请求
- // service.post(loginUrl, loginData)
- // .then(response => {
- // if (response.data.code === 200) {
- // alert(`${userType === 'student' ? '学生' : '教师'}端登录成功`);
- // // 保存token等操作
- // console.log('登录成功:', response.data);
- // } else {
- // alert(`登录失败: ${response.data.msg}`);
- // }
- // })
- // .catch(error => {
- // console.error('登录请求失败:', error);
- // alert('登录请求失败,请检查网络连接');
- // });
- }
- // 在<script>标签内添加
- window.onload = function() {
- console.log('页面加载完成');
- login()
- // 在这里可以执行初始化操作
- // 比如自动登录等
- // login(); // 如果需要自动执行登录
- };
- </script>
- </body>
- </html>
|