-- fix 课程公开报名

This commit is contained in:
yuping
2023-01-17 04:32:33 +08:00
parent 56e935dfce
commit b4458895ee
6 changed files with 56 additions and 95 deletions

View File

@@ -1,9 +1,11 @@
import router from "@/router"; import router from "@/router";
import { reactive, ref, toRefs, watch } from "vue"; import {reactive, ref, toRefs, watch} from "vue";
import axios from 'axios'; import axios from 'axios';
import { getCookie } from "@/api/utils"; import {getCookie} from "@/api/utils";
import JSONBigInt from 'json-bigint'; import JSONBigInt from 'json-bigint';
const JSONBigIntStr = JSONBigInt({ storeAsString: true });
const JSONBigIntStr = JSONBigInt({storeAsString: true});
export function usePage(_url, param, callback) { export function usePage(_url, param, callback) {
const state = reactive({ const state = reactive({
@@ -12,11 +14,11 @@ export function usePage(_url, param, callback) {
total: 0, total: 0,
size: 10, size: 10,
current: 1, current: 1,
params: { pageNo: 1, pageSize: 10, ...param } params: {pageNo: 1, pageSize: 10, ...param}
}) })
watch(param, () => { watch(param, () => {
state.params = { ...state.params, ...param } state.params = {...state.params, ...param}
fetchData() fetchData()
}) })
@@ -88,14 +90,20 @@ export async function request(_url, params) {
method, method,
headers: { headers: {
'token': getCookie('token'), 'token': getCookie('token'),
...method !== 'get' ? { 'Content-Type': 'application/json' } : {} ...method !== 'get' ? {'Content-Type': 'application/json'} : {}
}, },
baseURL: import.meta.env.VITE_BASE_API, baseURL: import.meta.env.VITE_BASE_API,
...method !== 'get' ? { data: JSON.stringify(body) } : {} ...method !== 'get' ? {data: JSON.stringify(body)} : {}
}).then(resp => resp.data).then(response => { }).then(resp => resp.data).then(response => {
if (response.code !== 200 && response.code !== 0) { if (response.code !== 200 && response.code !== 0) {
if (response.code === 1000) { if (response.code === 1000) {
(import.meta.env.MODE === 'development' || import.meta.env.MODE === 'test') ? router.push({ path: '/login' }) : window.open(import.meta.env.VITE_BASE_LOGIN_URL,'_top') (import.meta.env.MODE === 'development' || import.meta.env.MODE === 'test') ? router.push({path: '/login'}) : window.open(import.meta.env.VITE_BASE_LOGIN_URL, '_top')
}
if (response.code === 2001) {
router.push({path: '/FaceTeachSignUp', query: {courseId: router.currentRoute.value.query.courseId,type:3}})
}
if (response.code === 2002) {
router.push({path: '/FaceTeachNoCommon', query: {courseId: router.currentRoute.value.query.courseId,type:3}})
} }
// if (import.meta.env.DEV && response.code === 1000) { // if (import.meta.env.DEV && response.code === 1000) {
// router.push({path: '/login'}) // router.push({path: '/login'})
@@ -106,12 +114,8 @@ export async function request(_url, params) {
// duration: 2, // duration: 2,
// }); // });
// } // }
throw new Error('接口异常')
} }
return response return response
}).catch(e => {
console.log('eeeee', e)
// router.push({path: '/login'})
}) })
} }
@@ -132,16 +136,16 @@ export async function boeRequest(_url, params) {
} }
} }
const body = method !== 'get' ? params || {} : {} const body = method !== 'get' ? params || {} : {}
return fetch(url,{ return fetch(url, {
method, method,
headers:{ headers: {
token: getCookie('token'), token: getCookie('token'),
...method !== 'get' ? {'Content-Type': 'application/json'} : {} ...method !== 'get' ? {'Content-Type': 'application/json'} : {}
}, },
...method !== 'get' ? {body: JSON.stringify(body)} : {} ...method !== 'get' ? {body: JSON.stringify(body)} : {}
}).then(res=>{ }).then(res => {
return res.text() return res.text()
}).then(res=>{ }).then(res => {
return JSONBigIntStr.parse(res) return JSONBigIntStr.parse(res)
}) })
} }

View File

@@ -34,25 +34,9 @@
<div style="margin-left: 8px">{{ data.planDto?.address }}</div> <div style="margin-left: 8px">{{ data.planDto?.address }}</div>
</div> </div>
</div> </div>
<div v-if="projectStatus && projectEndTime"> <div >
<div v-if="projectStatus !=='3' && new Date(projectEndTime).getTime() > new Date().getTime()" style="display: flex">
<botton class="btn" style="margin-right: 20px" :style="{
background: isAllowSign? data.signFlag ? '#999' : 'rgb(57, 146, 249)':'#999',
}" @click="signClick">{{ data.signFlag ? "已签到" : "签到" }}
</botton>
<!-- <botton style="background: #999" class="btn" @click="toSurvery" v-if="data.planDto?.evalFlag == 0">
评估
</botton> -->
<botton v-if="data.planDto?.evalFlag !== 0" :style="{
background: `${new Date(data.planDto?.beginTime).getTime() > new Date().getTime() ? '#999' : data.isSurvery ? '#999' : 'rgb(57, 146, 249)'}`,
}" class="btn" @click="toSurvery">{{ data.isSurvery ? "已评估" : "评估" }}
</botton>
</div>
</div>
<div v-else>
<div style="display: flex"> <div style="display: flex">
<botton class="btn" style="margin-right: 20px" :style="{ <botton class="btn" style="margin-right: 20px" :style="{
background: isAllowSign? data.signFlag ? '#999' : 'rgb(57, 146, 249)':'#999', background: isAllowSign? data.signFlag ? '#999' : 'rgb(57, 146, 249)':'#999',
}" @click="signClick">{{ data.signFlag ? "已签到" : "签到" }} }" @click="signClick">{{ data.signFlag ? "已签到" : "签到" }}
@@ -99,50 +83,39 @@
<FileTypeImg :v-model="el.name? el.name : el.slice(el.lastIndexOf('/')+1,el.indexOf('-')) + el.slice(el.lastIndexOf('.'))" :style="{width: '22px',height: '26px',marginLeft: '10px',}"></FileTypeImg> <FileTypeImg :v-model="el.name? el.name : el.slice(el.lastIndexOf('/')+1,el.indexOf('-')) + el.slice(el.lastIndexOf('.'))" :style="{width: '22px',height: '26px',marginLeft: '10px',}"></FileTypeImg>
<div style="margin-left: 20px">{{ el.name? el.name : el.slice(el.lastIndexOf('/')+1,el.indexOf('-')) + el.slice(el.lastIndexOf('.')) }}</div> <div style="margin-left: 20px">{{ el.name? el.name : el.slice(el.lastIndexOf('/')+1,el.indexOf('-')) + el.slice(el.lastIndexOf('.')) }}</div>
</div> </div>
<div v-if="projectStatus !=='3' && new Date(projectEndTime).getTime() > new Date().getTime()" > <div>
<div v-if="new Date(data.planDto.beginTime).getTime() > new Date().getTime()" class="download"> <div v-if="new Date(data.planDto.beginTime).getTime() > new Date().getTime()" class="download">
<img style="width: 16px; height: 15px" src="../../assets/image/download.png" /> <img style="width: 16px; height: 15px" src="../../assets/image/download.png" />
<div style="margin-left: 5px;color:#999;" @click="downloads(el)"> <div style="margin-left: 5px;color:#999;" @click="downloads(el)">
下载 下载
</div> </div>
</div> </div>
<div v-else class="download"> <!-- <div v-else class="download">-->
<img style="width: 16px; height: 15px" src="../../assets/image/download.png" /> <!-- <img style="width: 16px; height: 15px" src="../../assets/image/download.png" />-->
<div style="margin-left: 5px" @click="download(el.name? el.response.data : el)"> <!-- <div style="margin-left: 5px" @click="download(el.name? el.response.data : el)">-->
下载 <!-- 下载-->
</div> <!-- </div>-->
</div> <!-- </div>-->
</div> </div>
</div> </div>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="课程作业" name="second"> <el-tab-pane label="课程作业" name="second">
<div class="work" v-if="data.workDto"> <div class="work" v-if="data.workDto">
<div> <div>
<div class="question">{{ data.workDto?.workName }}</div> <div class="question">{{ data.workDto?.workName }}</div>
<div style="margin-top: 16px; display: flex"> <div style="margin-top: 16px; display: flex">
<div class="tag1" v-if="data.workDto?.workFlag">必修</div> <div class="tag1" v-if="data.workDto?.workFlag">必修</div>
<div class="tag3" style="margin-left: 11px">作业</div> <div class="tag3" style="margin-left: 11px">作业</div>
</div> </div>
</div> </div>
<div
:style="{ background: new Date(data.planDto?.beginTime).getTime() > new Date().getTime() ? '#999' : '' }"
<div class="submit" @click="toWork">
v-if="projectStatus !=='3' && new Date(projectEndTime).getTime() > new Date().getTime()" 交作业
:style="{ background: new Date(data.planDto?.beginTime).getTime() > new Date().getTime() ? '#999' : '' }" </div>
class="submit" @click="toWork">
交作业
</div>
<div
v-else-if="projectStatus == undefined && projectEndTime==undefined"
:style="{ background: new Date(data.planDto?.beginTime).getTime() > new Date().getTime() ? '#999' : '' }"
class="submit" @click="toWork">
交作业
</div>
</div> </div>
<div v-else <div v-else style=" font-size: 14px; font-weight: 400; line-height: 24px; cursor: pointer;margin-left: 40px;margin-top: 20px; ">
style=" font-size: 14px; font-weight: 400; line-height: 24px; cursor: pointer;margin-left: 40px;margin-top: 20px; ">
此课程无作业 此课程无作业
</div> </div>
</el-tab-pane> </el-tab-pane>
@@ -160,9 +133,7 @@
<div class="tag3" style="margin-left: 11px">考试</div> <div class="tag3" style="margin-left: 11px">考试</div>
</div> </div>
</div> </div>
<div <div
v-if="projectStatus !=='3' && new Date(projectEndTime).getTime() > new Date().getTime()"
:style="{ background: new Date(data.planDto?.beginTime).getTime() > new Date().getTime() ? '#999' : '' }" :style="{ background: new Date(data.planDto?.beginTime).getTime() > new Date().getTime() ? '#999' : '' }"
class="submit" @click="toExamItem(data.examinationDto)"> class="submit" @click="toExamItem(data.examinationDto)">
去考试 去考试
@@ -218,12 +189,10 @@ const returnclick = () => {
router.back(); router.back();
}; };
const { const {
query: { courseId, type, id: taskId, projectStatus, projectEndTime }, query: { courseId, type, id: taskId },
} = useRoute(); } = useRoute();
const { data } = useRequest(STU_OFFCOURSE_DETAIL, { courseId }); const { data } = useRequest(STU_OFFCOURSE_DETAIL, { courseId,usePermission:true });
console.log("datadatadatadatadatadatadata", data);
console.log("项目状态字段传递", projectStatus, projectEndTime);
const teacherInfo = useUserInfo( const teacherInfo = useUserInfo(
computed(() => data.value?.planDto?.teacherId) computed(() => data.value?.planDto?.teacherId)
); );
@@ -249,7 +218,7 @@ function formateArr(strs) {
try{ try{
newArr = JSON.parse(strs) newArr = JSON.parse(strs)
} catch { } catch {
newArr = strs.split(',') newArr = strs?.split(',')
} }
console.log('112233', newArr) console.log('112233', newArr)
return newArr return newArr
@@ -330,11 +299,7 @@ const signClick = () => {
data.value.signFlag = 1; data.value.signFlag = 1;
ElMessage.warning("签到成功"); ElMessage.warning("签到成功");
if (taskId) { request(TASK_OFFCOURSE_NOTASK_SIGN, { courseId: courseId });
request(TASK_OFFCOURSE_SIGN, { courseId: courseId, taskId, type });
} else {
request(TASK_OFFCOURSE_NOTASK_SIGN, { courseId: courseId });
}
}; };
function toSurvery() { function toSurvery() {
@@ -379,7 +344,7 @@ function toWork() {
query: { query: {
courseId: data.value.workDto.workId, courseId: data.value.workDto.workId,
id: taskId, id: taskId,
infoId: data.value.offcourseDto.offcourseId, infoId: data.value.planDto.offcoursePlanId,
chapterOrStageId: 0, chapterOrStageId: 0,
type, type,
pName: "面授课", pName: "面授课",

View File

@@ -126,9 +126,6 @@ import FileTypeImg from "@/components/FileTypeImg.vue";
import {request, useRequest} from "@/api/request"; import {request, useRequest} from "@/api/request";
import { import {
STU_OFFCOURSE_DETAIL, STU_OFFCOURSE_DETAIL,
TASK_OFFCOURSE_NOTASK_SIGN,
TASK_OFFCOURSE_SIGN,
TASK_BROADCAST_SIGN,
FACETEACH_SIGNUP FACETEACH_SIGNUP
} from "@/api/api"; } from "@/api/api";
import {useRoute, useRouter} from "vue-router"; import {useRoute, useRouter} from "vue-router";

View File

@@ -22,7 +22,7 @@
<div class="bascinfo"> <div class="bascinfo">
<div style="display:flex;"> <div style="display:flex;">
<img style="width:405px;height:230px;margin-left: 48px;border-radius: 8px;margin-top: 40px;" <img style="width:405px;height:230px;margin-left: 48px;border-radius: 8px;margin-top: 40px;"
:src="data.offcourseDto.picUrl" alt=""> :src="data.offcourseDto?.picUrl" alt="">
<div style="margin-left: 40px;margin-top: 56px;"> <div style="margin-left: 40px;margin-top: 56px;">
<div class="title">面授课{{ data.planDto?.name }}</div> <div class="title">面授课{{ data.planDto?.name }}</div>
<div class="time" style="margin-top: 30px"> <div class="time" style="margin-top: 30px">
@@ -39,7 +39,7 @@
<div style="margin-left: 8px">{{ data.planDto?.address }}</div> <div style="margin-left: 8px">{{ data.planDto?.address }}</div>
</div> </div>
<div class="time" style="margin-top: 37px"> <div class="time" style="margin-top: 37px">
<botton class="btn" style="margin-right: 20px;width: 160px;height: 46px;" v-if="data.planDto.applyFlag" @click="onLineSignUp" :style="{ background: data.isSignUp ? '#999' : 'rgb(57, 146, 249)'}">{{data.isSignUp?'已报名':'立即报名'}}</botton> <botton class="btn" style="margin-right: 20px;width: 160px;height: 46px;" v-if="data.hasTask || data.planDto.applyFlag" @click="onLineSignUp" :style="{ background: data.isSignUp ? '#999' : 'rgb(57, 146, 249)'}">{{data.isSignUp?'已报名':'立即报名'}}</botton>
</div> </div>
</div> </div>
</div> </div>
@@ -126,9 +126,6 @@ import FileTypeImg from "@/components/FileTypeImg.vue";
import {request, useRequest} from "@/api/request"; import {request, useRequest} from "@/api/request";
import { import {
STU_OFFCOURSE_DETAIL, STU_OFFCOURSE_DETAIL,
TASK_OFFCOURSE_NOTASK_SIGN,
TASK_OFFCOURSE_SIGN,
TASK_BROADCAST_SIGN,
FACETEACH_SIGNUP FACETEACH_SIGNUP
} from "@/api/api"; } from "@/api/api";
import {useRoute, useRouter} from "vue-router"; import {useRoute, useRouter} from "vue-router";
@@ -144,7 +141,7 @@ const {
query: {courseId, type, id: taskId}, query: {courseId, type, id: taskId},
} = useRoute(); } = useRoute();
const {data} = useRequest(STU_OFFCOURSE_DETAIL, {courseId}); const {data = {}} = useRequest(STU_OFFCOURSE_DETAIL, {courseId});
const teacherInfo = useUserInfo( const teacherInfo = useUserInfo(
computed(() => data.value?.planDto?.teacherId) computed(() => data.value?.planDto?.teacherId)

View File

@@ -117,7 +117,7 @@
</div> </div>
</div> </div>
<!-- <div ref="contentLoadingDom" id="loadings" v-else style="width:100%;height:400px;background:red;"> <!-- <div ref="contentLoadingDom" id="loadings" v-else style="width:100%;height:400px;background:red;">
</div> --> </div> -->
<!-- <div class="tag1">必修</div> <!-- <div class="tag1">必修</div>
<div class="tag2">选修</div> <div class="tag2">选修</div>
@@ -132,7 +132,7 @@
<el-tab-pane label="项目公告" name="first"> <el-tab-pane label="项目公告" name="first">
<pre class="notice">{{ data.notice || "暂无公告" }}</pre> <pre class="notice">{{ data.notice || "暂无公告" }}</pre>
</el-tab-pane> </el-tab-pane>
<!-- <!--
<el-tab-pane label="共享文档" name="second"> <el-tab-pane label="共享文档" name="second">
<div style="padding: 19px 30px 17px 28px">--> <div style="padding: 19px 30px 17px 28px">-->
<!-- <div--> <!-- <div-->
@@ -299,7 +299,7 @@ const { data } = useRequest(PROJECT_PROCESS, {
console.log("datadata", data); console.log("datadata", data);
const loading = ref(false); const loading = ref(false);
loading.value = ElLoading.service({ loading.value = ElLoading.service({
lock: true, lock: true,
text: 'Loading', text: 'Loading',
background: 'rgba(0, 0, 0, 0.7)' background: 'rgba(0, 0, 0, 0.7)'
@@ -361,7 +361,7 @@ const types = ref({
}, },
path: { path: {
1: import.meta.env.VITE_BOE_ONLINE_CLASS_URL, //在线 1: import.meta.env.VITE_BOE_ONLINE_CLASS_URL, //在线
2: "/faceteach", 2: ({ courseId }) => window.open(`${location.protocol}//${location.host}${import.meta.env.VITE_BASE_API}/stu/project/redirectDetail?courseId=${courseId}`, '_top'),
3: import.meta.env.VITE_BOE_CASS_DETAIL_URL, //案例 3: import.meta.env.VITE_BOE_CASS_DETAIL_URL, //案例
4: "/homeworkpage", 4: "/homeworkpage",
5: import.meta.env.VITE_BOE_EXAM_DETAIL_URL, //考试 5: import.meta.env.VITE_BOE_EXAM_DETAIL_URL, //考试
@@ -526,8 +526,6 @@ function toFinish(d, sName, chapterOrStageId) {
pName: data.value.name, pName: data.value.name,
sName, sName,
chapterOrStageId, chapterOrStageId,
projectStatus: data.value.status?data.value.status:0, // 项目状态 -- 用于判断当前项目是否已经结束
projectEndTime: data.value.endTime?data.value.endTime:0 // 项目结束 -- 用于判断当前项目是否已经结束
}, },
}); });
} else if (typeof types.value.path[d.type] === "function") { } else if (typeof types.value.path[d.type] === "function") {

View File

@@ -339,8 +339,8 @@ const types = ref({
}, },
path: { path: {
1: import.meta.env.VITE_BOE_ONLINE_CLASS_URL, //在线 1: import.meta.env.VITE_BOE_ONLINE_CLASS_URL, //在线
2: "/faceteach", 2: ({ courseId }) => window.open(`${location.protocol}//${location.host}${import.meta.env.VITE_BASE_API}/stu/project/redirectDetail?courseId=${courseId}`, '_top'),
3: import.meta.env.VITE_BOE_CASS_DETAIL_URL, //案例 3: import.meta.env.VITE_BOE_CASS_DETAIL_URL, //案例
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",