fix:修改面授课签到时间范围

This commit is contained in:
lixg
2022-12-18 11:05:31 +08:00
parent fed53be26a
commit 15f3dcccf9
5 changed files with 158 additions and 134 deletions

1
.env
View File

@@ -13,3 +13,4 @@ VITE_BOE_EXAM_DETAIL_URL=https://u-pre.boe.com/pc/exam/test?id=
VITE_BOE_API_URL=https://u-pre.boe.com VITE_BOE_API_URL=https://u-pre.boe.com
VITE_TASK_WHITE_TYPE=-8-,-12-,-13- VITE_TASK_WHITE_TYPE=-8-,-12-,-13-
# VITE_TASK_WHITE_TYPE=-8-,-12-

View File

@@ -2,13 +2,13 @@
* @Author: lixg lixg@dongwu-inc.com * @Author: lixg lixg@dongwu-inc.com
* @Date: 2022-12-11 16:57:58 * @Date: 2022-12-11 16:57:58
* @LastEditors: lixg lixg@dongwu-inc.com * @LastEditors: lixg lixg@dongwu-inc.com
* @LastEditTime: 2022-12-17 14:59:41 * @LastEditTime: 2022-12-17 19:19:17
* @FilePath: /fe-stu/src/api/api.js * @FilePath: /fe-stu/src/api/api.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
export const LOGIN = '/admin/CheckUser/userLogin post' export const LOGIN = '/admin/CheckUser/userLogin post'
// export const FILE_UPLOAD = 'http://111.231.196.214:30001/file/upload' // export const FILE_UPLOAD = 'http://111.231.196.214:30001/file/upload'
export const FILE_UPLOAD = import.meta.env.VITE_BASE_API + '/file/upload' export const FILE_UPLOAD = '/file/upload'
export const COMMON_TOKEN = 'https://upload-z2.qiniup.com' export const COMMON_TOKEN = 'https://upload-z2.qiniup.com'
export const ROUTER_CHAPTER_LIST = '/stu/router/chapterList' export const ROUTER_CHAPTER_LIST = '/stu/router/chapterList'
export const ROUTER_LIST = '/stu/router/list post' export const ROUTER_LIST = '/stu/router/list post'

View File

@@ -42,8 +42,7 @@
class="btn" class="btn"
style="margin-right: 20px" style="margin-right: 20px"
:style="{ :style="{
background: background: data.signFlag ? '#999' : 'rgb(57, 146, 249)',
data.signFlag || !isAllowSign ? '#999' : 'rgb(57, 146, 249)',
}" }"
@click="signClick" @click="signClick"
>{{ data.signFlag ? "已签到" : "签到" }} >{{ data.signFlag ? "已签到" : "签到" }}
@@ -226,10 +225,10 @@
</template> </template>
<script setup> <script setup>
import { computed, reactive, toRefs, watch } from "vue"; import { computed, reactive, toRefs, watch, onUnmounted } from "vue";
import FileTypeImg from "@/components/FileTypeImg.vue"; import FileTypeImg from "@/components/FileTypeImg.vue";
import { request, useRequest } from "@/api/request"; import { request, useRequest } from "@/api/request";
import { STU_OFFCOURSE_DETAIL } from "@/api/api"; import { STU_OFFCOURSE_DETAIL, TASK_BROADCAST_SIGN } from "@/api/api";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { useUserInfo } from "@/api/utils"; import { useUserInfo } from "@/api/utils";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
@@ -263,56 +262,45 @@ let timer = null;
//判断能否签到 //判断能否签到
function isSignClick() { function isSignClick() {
timer = setInterval(() => { timer = setInterval(() => {
let beginTime = new Date(data.value.planDto.beginTime).getTime();
let endTime = !data.value.planDto.afterStart
? new Date(data.value.planDto.endTime).getTime()
: new Date(data.value.planDto.beginTime).getTime();
let nowTime = new Date().getTime();
if (data.value.planDto.beforeStart && data.value.planDto.afterStart) { if (data.value.planDto.beforeStart && data.value.planDto.afterStart) {
//有开始前有开始后 //有开始前有开始后
let beginTime = beginTime = beginTime - data.value.planDto.beforeStart * 60 * 1000;
new Date(data.value.planDto.beginTime).getTime() - endTime = endTime + data.value.planDto.afterStart * 60 * 1000;
data.value.planDto.beforeStart * 60 * 1000; console.log("1111");
let endTime =
new Date(data.value.planDto.beginTime).getTime() +
data.value.planDto.afterStart * 60 * 1000;
let nowTime = new Date().getTime();
if (nowTime < endTime && nowTime > beginTime) {
state.isAllowSign = true;
} else {
state.isAllowSign = false;
}
} else if (
!data.value.planDto.beforeStart &&
!data.value.planDto.afterStart
) {
//开始前开始后都没有
state.isAllowSign = true;
} else if ( } else if (
data.value.planDto.beforeStart && data.value.planDto.beforeStart &&
!data.value.planDto.afterStart !data.value.planDto.afterStart
) { ) {
//只有开始前无开始后 //只有开始前无开始后
let beginTime = beginTime = beginTime - data.value.planDto.beforeStart * 60 * 1000;
new Date(data.value.planDto.beginTime).getTime() - console.log("11112222");
data.value.planDto.beforeStart * 60 * 1000;
let nowTime = new Date().getTime();
if (nowTime > beginTime) {
state.isAllowSign = true;
} else {
state.isAllowSign = false;
}
} else if ( } else if (
!data.value.planDto.beforeStart && !data.value.planDto.beforeStart &&
data.value.planDto.afterStart data.value.planDto.afterStart
) { ) {
//无开始前有开始后 //无开始前有开始后
let endTime = endTime = endTime + data.value.planDto.afterStart * 60 * 1000;
new Date(data.value.planDto.beginTime).getTime() + console.log("1111333");
data.value.planDto.afterStart * 60 * 1000; }
let nowTime = new Date().getTime(); if (nowTime < endTime && nowTime > beginTime) {
if (nowTime < endTime) {
state.isAllowSign = true; state.isAllowSign = true;
} else { } else {
state.isAllowSign = false; state.isAllowSign = false;
} }
} // console.log(
console.log("isAllowSign", state.isAllowSign); // "isAllowSign",
// state.isAllowSign,
// nowTime,
// endTime,
// beginTime,
// nowTime < endTime,
// nowTime > beginTime
// );
}, 1000); }, 1000);
} }
isSignClick(); isSignClick();
@@ -322,13 +310,20 @@ const signClick = () => {
if (data.value.signFlag) { if (data.value.signFlag) {
return; return;
} }
console.log("data.signFlag", data.value.signFlag); // console.log(
if (!isAllowSign) { // "data.signFlag",
// data.value.signFlag,
// state.isAllowSign,
// !state.isAllowSign
// );
if (!state.isAllowSign) {
// console.log("data.signFlag", data.value.signFlag, isAllowSign);
ElMessage.info("未在签到范围内"); ElMessage.info("未在签到范围内");
return; return;
} }
data.value.signFlag = 1; data.value.signFlag = 1;
ElMessage.info("签到成功"); ElMessage.info("签到成功");
console.log("courseId", courseId, taskId, type);
request(TASK_BROADCAST_SIGN, { courseId: courseId, taskId, type }); request(TASK_BROADCAST_SIGN, { courseId: courseId, taskId, type });
}; };
@@ -368,6 +363,12 @@ function toExamItem(obj) {
window.open(import.meta.env.VITE_BOE_EXAM_DETAIL_URL + obj.examinationTestId); //测评 window.open(import.meta.env.VITE_BOE_EXAM_DETAIL_URL + obj.examinationTestId); //测评
// router.push({ path: import.meta.env.VITE_BOE_EXAM_DETAIL_URL+ obj.examinationTestId }); // router.push({ path: import.meta.env.VITE_BOE_EXAM_DETAIL_URL+ obj.examinationTestId });
} }
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
</script> </script>
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->

View File

@@ -30,7 +30,9 @@
</div> </div>
<div <div
class="course" class="course"
v-for="(value, index) in i.taskProcessList.filter(e=>!whiteTypes(e.type))" v-for="(value, index) in i.taskProcessList.filter(
(e) => !whiteTypes(e.type)
)"
:key="index" :key="index"
> >
<div> <div>
@@ -132,7 +134,7 @@
<el-tabs v-model="activeName" @tab-click="handleClick"> <el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="课程公告" name="first"> <el-tab-pane label="课程公告" name="first">
<div class="notice"> <div class="notice">
{{ data.remark || '暂无公告' }} {{ data.remark || "暂无公告" }}
</div> </div>
</el-tab-pane> </el-tab-pane>
<!-- <!--
@@ -207,7 +209,6 @@
<div class="ratebtn">继续学习</div> <div class="ratebtn">继续学习</div>
</div>--> </div>-->
<div style="margin-top: 16px"> <div style="margin-top: 16px">
<div class="progressBox"> <div class="progressBox">
<div>总进度</div> <div>总进度</div>
@@ -324,7 +325,9 @@ const router = useRouter();
const returnclick = () => { const returnclick = () => {
router.back(); router.back();
}; };
const {data} = useRequest(PROJECT_PROCESS, {projectId: projectId || courseId}); const { data } = useRequest(PROJECT_PROCESS, {
projectId: projectId || courseId,
});
const userInfo = computed(() => store.state.userInfo); const userInfo = computed(() => store.state.userInfo);
const activeName = ref("first"); const activeName = ref("first");
@@ -372,10 +375,18 @@ const types = ref({
4: "/homeworkpage", 4: "/homeworkpage",
5: import.meta.env.VITE_BOE_EXAM_DETAIL_URL, //考试 5: import.meta.env.VITE_BOE_EXAM_DETAIL_URL, //考试
6: "/livebroadcast", 6: "/livebroadcast",
7: ({courseId}) => request(LINK_DETAILS(courseId), {}).then(({data: {linkAddress}}) => window.open(linkAddress)),//外联 7: ({ courseId }) =>
request(LINK_DETAILS(courseId), {}).then(({ data: { linkAddress } }) =>
window.open(linkAddress)
), //外联
8: "/discusspage", 8: "/discusspage",
9: "/moreactive", 9: "/moreactive",
10: ({evaTyp, targetId}) => window.open((evaTyp === 1 ? import.meta.env.VITE_BOE_TEST_DETAIL_URL : import.meta.env.VITE_BOE_TEST_OUT_DETAIL_URL) + targetId), //测评 10: ({ evaType, targetId }) =>
window.open(
(evaType == 0
? import.meta.env.VITE_BOE_TEST_DETAIL_URL
: import.meta.env.VITE_BOE_TEST_OUT_DETAIL_URL) + targetId
), //测评
11: "/surveydetail", 11: "/surveydetail",
12: "/ballotpage", 12: "/ballotpage",
13: "/projectdetails", 13: "/projectdetails",
@@ -388,18 +399,28 @@ function toFinish(d,sName) {
return; return;
} }
if (typeof types.value.path[d.type] === 'string') { if (typeof types.value.path[d.type] === "string") {
types.value.path[d.type] && types.value.path[d.type].startsWith("http") && window.open(types.value.path[d.type] + d.targetId) types.value.path[d.type] &&
types.value.path[d.type] && types.value.path[d.type].startsWith("/") && router.push({ types.value.path[d.type].startsWith("http") &&
window.open(types.value.path[d.type] + d.targetId);
types.value.path[d.type] &&
types.value.path[d.type].startsWith("/") &&
router.push({
path: types.value.path[d.type], path: types.value.path[d.type],
query: {id: d.routerTaskId, type: 2, courseId: d.courseId, pName: data.value.name, sName}, query: {
}) id: d.routerTaskId,
} else if (typeof types.value.path[d.type] === 'function') { type: 2,
types.value.path[d.type](d) courseId: d.courseId,
pName: data.value.name,
sName,
},
});
} else if (typeof types.value.path[d.type] === "function") {
types.value.path[d.type](d);
} }
} }
function whiteTypes(type) { function whiteTypes(type) {
return import.meta.env.VITE_TASK_WHITE_TYPE.includes('-' + type +'-') return import.meta.env.VITE_TASK_WHITE_TYPE.includes("-" + type + "-");
} }
</script> </script>

View File

@@ -343,9 +343,9 @@ const returnclick = () => {
router.back(); router.back();
}; };
const { data } = useRequest(ROUTER_PROCESS, { routerId }); const { data } = useRequest(ROUTER_PROCESS, { routerId });
console.log("data", data);
const userInfo = computed(() => store.state.userInfo); const userInfo = computed(() => store.state.userInfo);
console.log("userInfo", userInfo);
const activeName = ref("first"); const activeName = ref("first");
const handleClick = (tab, event) => { const handleClick = (tab, event) => {
@@ -416,6 +416,7 @@ function toFinish(d, sName) {
} }
if (typeof types.value.path[d.type] === "string") { if (typeof types.value.path[d.type] === "string") {
// console.log("dddddd", d);
types.value.path[d.type] && types.value.path[d.type] &&
types.value.path[d.type].startsWith("http") && types.value.path[d.type].startsWith("http") &&
window.open(types.value.path[d.type] + d.targetId); window.open(types.value.path[d.type] + d.targetId);