feat:修改重新报名

This commit is contained in:
lixg
2023-03-09 11:56:33 +08:00
parent 4c99334e3c
commit daa85bad28
10 changed files with 79 additions and 48 deletions

View File

@@ -27,7 +27,7 @@ import { GET_USER_INFO } from "@/api/ThirdApi";
import { getCookie } from "@/api/utils";
import { USER_INFO } from "@/api/api";
console.log("版本2.1.10------------");
console.log("版本2.1.11------------");
const store = useStore();
const router = useRouter();

View File

@@ -46,7 +46,6 @@ export function useRequest(_url, params = {}, callback) {
const state = reactive({
data: {},
loading: false,
})
watch(params, () => {
@@ -58,7 +57,7 @@ export function useRequest(_url, params = {}, callback) {
request(_url, params).then(r => {
state.data = r.data
state.loading = false
callback(r)
callback?.(r)
})
}

View File

@@ -2,7 +2,7 @@
* @Author: lixg lixg@dongwu-inc.com
* @Date: 2023-01-18 14:40:26
* @LastEditors: lixg lixg@dongwu-inc.com
* @LastEditTime: 2023-02-19 16:37:15
* @LastEditTime: 2023-03-09 11:39:58
* @FilePath: /stu_h5/src/components/img/UploadImg.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@@ -63,6 +63,17 @@ const closeLoading = () => {
function handleChange(e) {
openLoading();
console.log("上传", e);
if (
e.raw.name.includes(".mp4") ||
e.raw.name.includes(".jpeg") ||
e.raw.name.includes(".JPEG")
) {
files.value = [];
emit("update:value", files.value);
ElMessage.error(`暂不支持此格式文件上传`);
closeLoading();
return;
} else {
if (e.response && e.response.code === 200) {
e.url = e.response.data;
}
@@ -75,6 +86,8 @@ function handleChange(e) {
}
emit("update:fileList", files.value);
files.value = [];
}
closeLoading();
}

View File

@@ -165,7 +165,11 @@ const state = reactive({
isAllowSign: false,
closeBtn: true,
});
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
const { isAllowSign, closeBtn } = toRefs(state);
const { data } = useRequest(ACTIVITY, { activityId, type }, (e) => {
@@ -240,11 +244,6 @@ function isSignClick() {
}, 1000);
}
isSignClick();
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
//是否显示头部公告
const isShowClose = () => {

View File

@@ -190,6 +190,12 @@ const router = useRouter();
const {
query: { courseId, chapterOrStageId, infoId, id, btype, type },
} = useRoute();
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
const userInfo = computed(() => store.state.userInfo);
const { data } = useRequest(VOTE_DETAIL3, { voteId: courseId, type }, (e) => {
if (e.code === 6) {
@@ -229,9 +235,6 @@ let timer = setInterval(() => {
clearInterval(timer);
}
}, 1000);
onUnmounted(() => {
clearInterval(timer);
});
// 答题时间
const answerTime = dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss");

View File

@@ -96,6 +96,11 @@ const {
},
} = useRoute();
const router = useRouter();
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
const { data } = useRequest(EVALUATION_DETAIL, { evaluationId, type }, (e) => {
if (e.code === 6) {
router.push({
@@ -130,9 +135,7 @@ let timer = setInterval(() => {
clearInterval(timer);
}
}, 1000);
onUnmounted(() => {
clearInterval(timer);
});
const goOuterChain = () => {
console.log("点击去查看");
if (quizTaskId == null) {

View File

@@ -400,7 +400,11 @@ const returnclick = () => {
const {
query: { courseId, type, id: taskId, projectStatus, projectEndTime },
} = useRoute();
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
const { data } = useRequest(STU_OFFCOURSE_DETAIL, { courseId });
console.log("datadatadatadatadatadatadata", data);
// console.log("项目状态字段传递", projectStatus, projectEndTime);
@@ -606,12 +610,6 @@ function toExamItem(obj) {
// router.push({ path: import.meta.env.VITE_BOE_EXAM_DETAIL_URL+ obj.examinationTestId });
}
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->

View File

@@ -43,7 +43,7 @@
<botton
class="titlebtn"
v-if="data.planDto?.applyFlag"
@click="onLineSignUp"
@click="onLineSignUp(false)"
:style="{
background: isAllowSign
? data.isSignUp || data.isRefused
@@ -60,7 +60,7 @@
}}
</botton>
<botton
v-if="data.isRefused"
v-if="data.isRefused && !data.isSignUpAgain"
class="titlebtn"
style="background: rgb(57, 146, 249)"
@click="onLineSignUp(true)"
@@ -260,18 +260,21 @@ watch(data, () => {
isSignClick();
});
// 报名
function onLineSignUp() {
function onLineSignUp(isAgain) {
if (!state.isAllowSign) {
// console.log("data.signFlag", data.value.signFlag, isAllowSign);
ElMessage.warning("未在允许报名时间范围内");
return;
}
if (data.value.isSignUp && data.value.isSignUp) {
if (data.value.isSignUp && !isAgain) {
return;
}
request(FACETEACH_SIGNUP, { courseId });
data.value.isSignUp = true;
ElMessage.success("报名成功");
//重置按钮
data.value.isSignUpAgain = isAgain;
data.value.isRefused = false;
ElMessage.success(isAgain ? "重新报名成功" : "报名成功");
}
function formateArr(strs) {

View File

@@ -83,7 +83,15 @@
</template>
<script setup>
import { computed, onUnmounted, reactive, ref, toRefs, watch } from "vue";
import {
computed,
onUnmounted,
onBeforeUnmount,
reactive,
ref,
toRefs,
watch,
} from "vue";
import { request, useRequest } from "@/api/request";
import {
TASK_WORK_COMMIT,
@@ -114,6 +122,14 @@ const returnclick = () => {
const {
query: { courseId: workId, type, id: taskId, infoId },
} = useRoute();
// 从报错信息来看 是因为内部 把这个组件看成了个异步组件 中间有代码是异步执行的 导致unmounted执行的时机不对。。放上面就好了
onBeforeUnmount(() => {
console.log("清除定时器");
if (timer) {
clearInterval(timer);
timer = null;
}
});
// console.log("type", type);
const loading = ref(false); // loading
const openLoading = () => {
@@ -127,6 +143,7 @@ openLoading();
const closeLoading = () => {
loading.value.close();
};
const { data } =
taskId && taskId !== "undefined"
? useRequest(TASK_WORK_DETAIL, { workId, taskId, type }, (e) => {
@@ -179,9 +196,6 @@ let timer = setInterval(() => {
}
}
}, 1000);
onUnmounted(() => {
clearInterval(timer);
});
const { data: submitList } = useRequest(TASK_WORK_SUBMIT_LIST, {
workerId: workId,

View File

@@ -221,7 +221,11 @@ const router = useRouter();
const returnclick = () => {
router.back();
};
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
const { data } = useRequest(TASK_BROADCAST_DETAIL, { liveId, type }, (e) => {
console.log("直播判断", e);
if (e.code === 6) {
@@ -349,11 +353,6 @@ const closeBtn = ref(true);
const isShowClose = () => {
closeBtn.value = false;
};
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->