|
|
@@ -52,11 +52,22 @@
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
-<input type="hidden" th:value="${teacherUrl}" name="id" id="teacherUrl" >
|
|
|
-<input type="hidden" th:value="${studentUrl}" name="id" id="studentUrl" >
|
|
|
+<div class="container">
|
|
|
+ <div class="loading-container" id="loadingContainer">
|
|
|
+ <div class="spinner"></div>
|
|
|
+ <div class="loading-text" id="loadingText">加载中...</div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+<input type="hidden" th:value="${teacherUrl}" id="teacherUrl" >
|
|
|
+<input type="hidden" th:value="${studentUrl}" id="studentUrl" >
|
|
|
+<input type="hidden" th:value="${code}" id="code" >
|
|
|
+<input type="hidden" th:value="${type}" id="type" >
|
|
|
+<input type="hidden" th:value="${id}" id="id" >
|
|
|
<script src="/api/webapp/js/axios.min.js" type="text/javascript" th:src="@{/api/webapp/js/axios.min.js}"></script>
|
|
|
<script>
|
|
|
-
|
|
|
+ let loadingContainer
|
|
|
+ let loadingText
|
|
|
+ let triggerBtn
|
|
|
let baseUrl ="http://"+window.location.host;
|
|
|
let teacherUrl = document.getElementById('teacherUrl').value;
|
|
|
let studentUrl = document.getElementById('studentUrl').value;
|
|
|
@@ -65,15 +76,13 @@
|
|
|
// 创建axios实例,参考request.js中的配置
|
|
|
const service = axios.create({
|
|
|
baseURL: '/api',
|
|
|
- timeout: 5000
|
|
|
+ timeout: 10000
|
|
|
});
|
|
|
|
|
|
- // 登录函数
|
|
|
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');
|
|
|
+ let code = document.getElementById('code').value;
|
|
|
+ let type = document.getElementById('type').value;
|
|
|
+ let id = document.getElementById('id').value;
|
|
|
if (code == undefined || type == undefined) {
|
|
|
alert('数据参数不对');
|
|
|
return
|
|
|
@@ -83,6 +92,9 @@
|
|
|
return
|
|
|
}
|
|
|
console.log('什么数值呢', code)
|
|
|
+ console.log('type数值', type)
|
|
|
+ loadingContainer.classList.remove('ready-enter');
|
|
|
+ loadingText.textContent = '加载中...';
|
|
|
// 这里需要替换为实际的登录接口URL
|
|
|
const loginUrl = baseUrl+'/api/webapp/disk/CollegeUser/getUser';
|
|
|
|
|
|
@@ -106,7 +118,16 @@
|
|
|
})
|
|
|
console.log('获取人员信息:', ress);
|
|
|
if(ress.data.code == 200 && ress.data.data.eduIdentity == 1){
|
|
|
- //去教师端
|
|
|
+ // 请求完成后切换到准备进入状态
|
|
|
+ loadingText.textContent = '准备进入';
|
|
|
+ loadingContainer.classList.add('ready-enter');
|
|
|
+
|
|
|
+ // 可选:移除spinner,只显示文字
|
|
|
+ const spinner = document.querySelector('.spinner');
|
|
|
+ if (spinner) {
|
|
|
+ spinner.style.display = 'none';
|
|
|
+ }
|
|
|
+ //去教师段
|
|
|
// 构建带参数的URL
|
|
|
const params = new URLSearchParams({
|
|
|
userId: ress.data.data.id,
|
|
|
@@ -126,6 +147,7 @@
|
|
|
});
|
|
|
const redirectUrl = `${studentUrl}${type==1?'/student/resourceDetails':'/student/resourceCenter'}?${params.toString()}`;
|
|
|
window.location.href = redirectUrl;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -134,12 +156,11 @@
|
|
|
// 在<script>标签内添加
|
|
|
window.onload = function() {
|
|
|
console.log('页面加载完成');
|
|
|
+ loadingContainer = document.getElementById('loadingContainer');
|
|
|
+ loadingText = document.getElementById('loadingText');
|
|
|
+ triggerBtn = document.getElementById('triggerBtn');
|
|
|
login()
|
|
|
- // 在这里可以执行初始化操作
|
|
|
- // 比如自动登录等
|
|
|
- // login(); // 如果需要自动执行登录
|
|
|
};
|
|
|
-
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|