修改访问时间判断和对于异常的部分提示
This commit is contained in:
parent
9ed1e5e554
commit
2701925e99
|
@ -85,11 +85,18 @@ export async function getMajor(code) {
|
|||
return response;
|
||||
}
|
||||
//检查用户身份
|
||||
export async function checkUser(code) {
|
||||
export async function checkUser(code, openid, unionid) {
|
||||
try {
|
||||
const response = await http.post('/h5/cees/ceesUser/checkUser', {
|
||||
userId: code,
|
||||
openId: openid,
|
||||
unionId: unionid,
|
||||
});
|
||||
return response;
|
||||
} catch (err) {
|
||||
// 抛出错误,让外层 catch 拿到详细信息
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
//检查用户身份
|
||||
export async function checkUserByEmployeeCode(employeeCode,code) {
|
||||
|
|
|
@ -2,7 +2,12 @@ export const routes = [
|
|||
{
|
||||
path: '/',
|
||||
redirect: '/home',
|
||||
component: () => import('@/layout/basic/index.vue'),
|
||||
//component: () => import('@/layout/basic/index.vue'),
|
||||
meta: {
|
||||
title: '哈尔滨师范大学评卷报名系统',
|
||||
keepAlive: true,
|
||||
showHeader: false,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'home',
|
||||
|
@ -95,6 +100,11 @@ export const routes = [
|
|||
// 找不到路由重定向到404页面
|
||||
path: '/:pathMatch(.*)',
|
||||
redirect: '/home',
|
||||
meta: {
|
||||
title: '哈尔滨师范大学评卷报名系统',
|
||||
keepAlive: true,
|
||||
showHeader: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -30,10 +30,11 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, ref, } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { showDialog,showNotify, showConfirmDialog,showFailToast } from 'vant';
|
||||
import { showDialog,showNotify, showConfirmDialog,showFailToast,showToast } from 'vant';
|
||||
import { getAccessTime,getMajor, checkUser,getCode, getUserInfo,AutocheckUser,checkUserByEmployeeCode } from '@/api';
|
||||
import { useUserStore } from '@/store';
|
||||
import { showInputDialog } from '@/utils/request/showInputDialog';
|
||||
import { opendir } from 'fs';
|
||||
|
||||
|
||||
|
||||
|
@ -82,93 +83,71 @@
|
|||
*/
|
||||
let accessChecked = false;
|
||||
|
||||
async function login() {
|
||||
async function login() {
|
||||
loading.value = true;
|
||||
show.value = true;
|
||||
const code = inputCode.value.toString();
|
||||
// 验证顺序:先检查空值,再检查长度
|
||||
|
||||
if (!code) {
|
||||
showConfirmDialog({
|
||||
await showConfirmDialog({
|
||||
allowHtml: true,
|
||||
confirmButtonColor: '#8D2328',
|
||||
message: '身份码不能为空',
|
||||
});
|
||||
//showNotify({ type: 'danger', message: '身份码不能为空' });
|
||||
//showFailToast('身份码不能为空');
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (code.length !== 8) {
|
||||
showConfirmDialog({
|
||||
await showConfirmDialog({
|
||||
title: '请输入8位身份码',
|
||||
allowHtml: true,
|
||||
confirmButtonColor: '#8D2328',
|
||||
});
|
||||
//showNotify({ type: 'danger', message: '请输入8位身份码' });
|
||||
//showToast({ type: 'fail', message: '身份码不能为空' });
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
if (!accessChecked) {
|
||||
await performLogin();
|
||||
}
|
||||
|
||||
async function checkAccessTime() {
|
||||
try {
|
||||
const res = await getAccessTime();
|
||||
const currentTime = new Date();
|
||||
const startTime = new Date(res.result.startTime);
|
||||
const endTime = new Date(res.result.endTime);
|
||||
|
||||
console.log("startTime", startTime);
|
||||
console.log("endTime", endTime);
|
||||
|
||||
const formatToChineseTime = (date) => {
|
||||
const month = date.getMonth() + 1;
|
||||
const day = date.getDate();
|
||||
const hour = date.getHours();
|
||||
return `${month}月${day}号${hour}时`;
|
||||
};
|
||||
|
||||
const startTimeString = formatToChineseTime(startTime);
|
||||
const endTimeString = formatToChineseTime(endTime);
|
||||
const formattedTime = `${startTimeString}-${endTimeString}`;
|
||||
|
||||
console.log(formattedTime);
|
||||
|
||||
if (currentTime >= startTime && currentTime <= endTime) {
|
||||
accessChecked = true;
|
||||
// Continue with login process
|
||||
await performLogin();
|
||||
return {
|
||||
allowed: true
|
||||
};
|
||||
} else {
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
await showDialog({
|
||||
title: '访问提示',
|
||||
message: `请在规定的时间内进行报名。\n报名时间:\n${startTimeString} —— ${endTimeString}`,
|
||||
});
|
||||
return false;
|
||||
return {
|
||||
allowed: false,
|
||||
message: `请在规定的时间内进行报名。\n报名时间:\n${startTimeString} —— ${endTimeString}`
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error getting access time:', err);
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
await showDialog({
|
||||
title: '访问错误',
|
||||
message: '获取访问时间失败,请稍后再试。',
|
||||
});
|
||||
return false;
|
||||
return {
|
||||
allowed: false,
|
||||
error: true,
|
||||
message: '获取访问时间失败,请稍后再试。'
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// Already checked, continue with login
|
||||
await performLogin();
|
||||
}
|
||||
}
|
||||
function performLogin() {
|
||||
function performLogin() {
|
||||
loading.value = true;
|
||||
show.value = true;
|
||||
|
||||
// 验证身份码长度
|
||||
const code = inputCode.value.toString();
|
||||
|
||||
|
||||
// 模拟获取学科信息
|
||||
const majors = [
|
||||
{ id: 1, name: '语文', value: 1 },
|
||||
|
@ -183,7 +162,7 @@ async function login() {
|
|||
if (res.code === 500) {
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
alert(res.message);
|
||||
showDialog(res.message);
|
||||
return;
|
||||
}
|
||||
if (res.code === 200) {
|
||||
|
@ -204,21 +183,43 @@ async function login() {
|
|||
message: `该识别码对应<span style="color: #8D2328;font-weight: 700">${major.value}</span>学科评卷人员如与您的评卷学科不符请退出并联系学院负责人`,
|
||||
})
|
||||
.then(() => {
|
||||
checkUser(code).then((res) => {
|
||||
if (res.result.code == 500) {
|
||||
checkUser(code,userInfo.openid,userInfo.unionid).then((res) => {
|
||||
console.log(res)
|
||||
if (res.code == 500) {
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
store.logout();
|
||||
alert(res.result.message);
|
||||
showDialog(res.message);
|
||||
return;
|
||||
}
|
||||
// 未填写信息
|
||||
if (res.result.status == '1') {
|
||||
//showNotify({ type: 'success', message: '登录成功' });
|
||||
checkAccessTime().then(accessResult => {
|
||||
console.log(accessResult.allowed, "accessResult");
|
||||
if (accessResult.allowed) {
|
||||
// 在访问时间内 - 允许跳转
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
store.login(res.result);
|
||||
router.push(res.result.router);
|
||||
} else {
|
||||
// 不在访问时间内 - 显示提示
|
||||
showDialog({
|
||||
title: '访问提示',
|
||||
message: accessResult.message || '当前不在允许操作的时间段'
|
||||
});
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('检查访问时间失败:', error);
|
||||
showDialog({
|
||||
title: '访问提示',
|
||||
message: '无法验证访问时间,请稍后再试'
|
||||
});
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
});
|
||||
}
|
||||
// 填写过信息
|
||||
if (res.result.status == '2') {
|
||||
|
@ -231,10 +232,18 @@ async function login() {
|
|||
store.setGroupId(res.result.groupId);
|
||||
router.push(res.result.router);
|
||||
}
|
||||
}).catch((err)=>{
|
||||
showDialog({
|
||||
title: '错误',
|
||||
message: err.message
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消操作
|
||||
.catch((err) => {
|
||||
showDialog({
|
||||
title: '错误',
|
||||
message: err.message
|
||||
});
|
||||
});
|
||||
} else if (res.result.identity === 4) {
|
||||
// 外校老师
|
||||
|
@ -249,26 +258,47 @@ async function login() {
|
|||
title: '身份识别码确认',
|
||||
allowHtml: true,
|
||||
confirmButtonColor: '#8D2328',
|
||||
// message:`专业是:${major.value}`
|
||||
// message:`尊敬的老师您好,该识别码对应《${major.value}》学科阅卷人员,如与邀请函发送给您的评卷学科学科不符,请退出并联系刁衣非老师,联系电话……`
|
||||
message: `尊敬的老师您好,该识别码对应<span style="color: #8D2328;font-weight: 700">${major.value}</span>学科评卷人员,如与邀请函发送给您的评卷学科不符,请退出并联系您所在学校负责人`,
|
||||
})
|
||||
.then(() => {
|
||||
checkUser(code).then((res) => {
|
||||
if (res.result.code == 500) {
|
||||
checkUser(code,userInfo.openid,userInfo.unionid)
|
||||
.then((res) => {
|
||||
console.log('then:', res);
|
||||
if (res.code == 500) {
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
store.logout();
|
||||
alert(res.result.message);
|
||||
showDialog(res.message);
|
||||
return;
|
||||
}
|
||||
// 未填写信息
|
||||
if (res.result.status == '1') {
|
||||
showNotify({ type: 'success', message: '登录成功' });
|
||||
checkAccessTime().then(accessResult => {
|
||||
console.log(accessResult.allowed, "accessResult");
|
||||
if (accessResult.allowed) {
|
||||
// 在访问时间内 - 允许跳转
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
store.login(res.result);
|
||||
router.push(res.result.router);
|
||||
} else {
|
||||
// 不在访问时间内 - 显示提示
|
||||
showDialog({
|
||||
title: '访问提示',
|
||||
message: accessResult.message || '当前不在允许操作的时间段'
|
||||
});
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('检查访问时间失败:', error);
|
||||
showDialog({
|
||||
title: '访问提示',
|
||||
message: '无法验证访问时间,请稍后再试'
|
||||
});
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
});
|
||||
}
|
||||
// 填写过信息
|
||||
if (res.result.status == '2') {
|
||||
|
@ -281,51 +311,35 @@ async function login() {
|
|||
store.setGroupId(res.result.groupId);
|
||||
router.push(res.result.router);
|
||||
}
|
||||
}).catch((err)=>{
|
||||
if (err && typeof err === 'object' && 'code' in err && 'message' in err) {
|
||||
showDialog({
|
||||
title: '错误',
|
||||
message: err.message
|
||||
});
|
||||
} else if (err instanceof Error) {
|
||||
showDialog({
|
||||
title: '错误',
|
||||
message: err.message
|
||||
});
|
||||
} else {
|
||||
showDialog({
|
||||
title: '错误',
|
||||
message: '未知错误'
|
||||
});
|
||||
}
|
||||
loading.value = false;
|
||||
show.value = false;
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消操作
|
||||
.catch((err) => {
|
||||
showDialog({
|
||||
title: '错误',
|
||||
message: err.message
|
||||
});
|
||||
});
|
||||
} else if (res.result.identity === 1) {
|
||||
// 行政人员
|
||||
//showConfirmDialog({
|
||||
// title: '工号确认',
|
||||
// allowHtml: true,
|
||||
// confirmButtonColor: '#8D2328',
|
||||
// message: `<p style="text-align: left;text-indent:24px"><span style="font-weight: 700">${res.result.userName}</span>同志,已在2024年哈尔滨师范大学评卷数据库中检索到您的信息,请点击确认查看您的分工。</p>`,
|
||||
//})
|
||||
// .then(() => {
|
||||
// checkUser(code).then((res) => {
|
||||
//if (res.result.code == 500) {
|
||||
// loading.value = false;
|
||||
// show.value = false;
|
||||
// store.logout();
|
||||
// alert(res.result.message);
|
||||
// return;
|
||||
//}
|
||||
//// 未填写信息
|
||||
//if (res.result.status == '1') {
|
||||
// showNotify({ type: 'success', message: '登录成功' });
|
||||
// loading.value = false;
|
||||
// show.value = false;
|
||||
// store.login(res.result);
|
||||
// router.push(res.result.router);
|
||||
//}
|
||||
//// 填写过信息
|
||||
//if (res.result.status == '2') {
|
||||
// showNotify({ type: 'success', message: '登录成功' });
|
||||
// loading.value = false;
|
||||
// show.value = false;
|
||||
// localStorage.clear();
|
||||
|
||||
// store.login(res.result);
|
||||
// store.setUserId(res.result.userId);
|
||||
// store.setGroupId(res.result.groupId);
|
||||
// router.push(res.result.router);
|
||||
//}
|
||||
// });
|
||||
// })
|
||||
// .catch(() => {});
|
||||
showInputDialog({
|
||||
title: '工号确认',
|
||||
message: '请输入您的工号以继续操作',
|
||||
|
@ -355,20 +369,31 @@ async function login() {
|
|||
loading.value = false;
|
||||
show.value = false;
|
||||
localStorage.clear();
|
||||
|
||||
store.login(res.result);
|
||||
store.setUserId(res.result.userId);
|
||||
store.setGroupId(res.result.groupId);
|
||||
router.push(res.result.router);
|
||||
}
|
||||
}).catch((err)=>{
|
||||
showDialog({
|
||||
title: '错误',
|
||||
message: err.message
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('用户取消输入');
|
||||
.catch((err) => {
|
||||
showDialog({
|
||||
title: '错误',
|
||||
message: err.message
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}).catch((err)=>{
|
||||
showDialog({
|
||||
title: '错误',
|
||||
message: err.message
|
||||
});
|
||||
});
|
||||
}
|
||||
//微信网页授权
|
||||
|
@ -403,7 +428,7 @@ async function login() {
|
|||
} catch (error) {
|
||||
console.error('授权流程错误:', error);
|
||||
// 5. 用户友好的错误提示
|
||||
showFailToast(error.message || '微信授权失败');
|
||||
//showFailToast(error.message || '微信授权失败');
|
||||
} finally {
|
||||
|
||||
}
|
||||
|
@ -461,7 +486,7 @@ async function login() {
|
|||
});
|
||||
|
||||
} catch (error) {
|
||||
showFailToast('获取用户信息失败');
|
||||
//showFailToast('获取用户信息失败');
|
||||
console.error(error);
|
||||
} finally {
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<div class="ditu-img" v-if="show1">
|
||||
<span @click="show1 = false"> 关闭 ✕ </span>
|
||||
<div class="card-img">
|
||||
<img src="@/assets/orangeUi/ditu.jpg" style="width: 100%; height: 100%" />
|
||||
<img src="@/assets/Ui/地图.png" style="width: 100%; height: 100%" />
|
||||
</div>
|
||||
</div>
|
||||
<p>师大地图</p>
|
||||
|
|
|
@ -391,9 +391,8 @@
|
|||
>
|
||||
<div class="grop-by">
|
||||
评卷地点信息
|
||||
<p>暂时未发布</p>
|
||||
<p v-if="!group">暂时未发布</p>
|
||||
<p v-else>{{ group }}</p>
|
||||
<p v-if="!location">暂时未发布</p>
|
||||
<p v-else>{{ location }}</p>
|
||||
</div>
|
||||
<!-- <img src="@/assets/img/dt.jpg"/>-->
|
||||
<span class="dialog-close-content" @click="show5 = false">×</span>
|
||||
|
@ -496,6 +495,7 @@
|
|||
* 7. 获取用户证书信息
|
||||
* */
|
||||
const group = ref('');
|
||||
const location = ref('');
|
||||
const dormitory = ref('');
|
||||
const showIcon = reactive({
|
||||
show0: false,
|
||||
|
@ -540,7 +540,8 @@
|
|||
show3.value = true;
|
||||
getGroupName(userInfo.groupId).then(
|
||||
(res) => {
|
||||
group.value = res.result;
|
||||
group.value = res.result.name;
|
||||
location.value = res.result.markingLocation
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
|
@ -592,7 +593,8 @@
|
|||
userInfo.pyCard = userInfo.pyCardMasked;
|
||||
}
|
||||
console.log("userInfo.phone",userInfo.phone);
|
||||
store.setMajorId(store.LoginUser.majorId);
|
||||
console.log(res.result.user.majorId)
|
||||
store.setMajorId(res.result.user.majorId);
|
||||
Object.assign(showIcon, res.result);
|
||||
},
|
||||
(err) => {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<!--<van-cell-group inset class="mar-auto15">
|
||||
<van-field class="van-field__label_rectangle" label-width="400px" label="哈尔滨师范大学评卷信息填报" type="hidden" />
|
||||
</van-cell-group>-->
|
||||
<van-form @submit="onSubmit">
|
||||
<van-form ref="formRef" @submit="onSubmit">
|
||||
<div class="head-cg">
|
||||
<img src="@/assets/Ui/信息/个人信息/个人信息.svg" />
|
||||
</div>
|
||||
|
@ -180,7 +180,8 @@
|
|||
openId: store.getOpenId,
|
||||
userId: store.getUserId,
|
||||
});
|
||||
|
||||
// 表单引用
|
||||
const formRef = ref();
|
||||
const showPicker = ref(false);
|
||||
const showSex = ref(false);
|
||||
const columns = [
|
||||
|
@ -416,7 +417,7 @@
|
|||
handleSubmit();
|
||||
} else {
|
||||
// 正常验证流程
|
||||
notLocalTeacher.value?.validate().then(() => {
|
||||
formRef.value?.validate().then(() => {
|
||||
handleSubmit();
|
||||
}).catch((error) => {
|
||||
console.log('表单验证失败', error);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<!-- <div class="wxts"> 建议使用中国银行或中国建设银行借记卡(储蓄卡)账户信息填报除 <em>借记卡</em> 以外其他类型账户(如:信用卡)会造成您的劳务费用无法成功发放。</div>-->
|
||||
<!-- <p class="xxxxx"></p>-->
|
||||
<!-- </div>-->
|
||||
<van-form @submit="onSubmit">
|
||||
<van-form ref="formRef" @submit="onSubmit">
|
||||
<div class="head-cg">
|
||||
<img src="@/assets/Ui/信息/劳务信息/劳务信息.svg" />
|
||||
</div>
|
||||
|
@ -486,7 +486,8 @@
|
|||
openId: '',
|
||||
unionId: ''
|
||||
});
|
||||
|
||||
// 表单引用
|
||||
const formRef = ref();
|
||||
const tname = ref('');
|
||||
const tid = ref('');
|
||||
const tphone = ref('');
|
||||
|
@ -671,7 +672,7 @@
|
|||
return;
|
||||
} else {
|
||||
// 正常验证流程
|
||||
notLocalTeacherTwo.value?.validate().then(() => {
|
||||
formRef.value?.validate().then(() => {
|
||||
myShowDialog.value = true;
|
||||
console.log("storedData", storedData);
|
||||
myObj = { ...values, ...storedData };
|
||||
|
|
Loading…
Reference in New Issue