From ed820ce2aca5949285dbe326985cedd8310c2667 Mon Sep 17 00:00:00 2001 From: xy <2115269706@qq.com> Date: Tue, 25 Mar 2025 15:26:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=A5=E8=AF=86=E7=82=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.ts | 7 +- src/layout/knowledgePage.vue | 101 +++++++++++++++---------- src/layout/spacePage.vue | 127 ++++++++++++++++++-------------- src/layout/studyPage.vue | 1 + src/views/subjectTest/index.vue | 1 + 5 files changed, 143 insertions(+), 94 deletions(-) diff --git a/src/api/user.ts b/src/api/user.ts index 36da266..7381d99 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -35,7 +35,7 @@ export const getUserInfoService = () => { //获取知识点信息 export const getKnowledgeService = () => { return request({ - url: "knowledgepoint/xnKnowledgePoint/list", + url: "/pointrecords/xnPointRecords/api/list", method: "get", }); }; @@ -43,4 +43,9 @@ export const getKnowledgeService = () => { //修改密码 export const userChangePasswordService = (params) => { return request.post('/xnRecords/changeStuPassword', params) +} + +// 修改个人信息 +export const userChangeService = (params) => { + return request.post('/xnRecords/editInfo', params) } \ No newline at end of file diff --git a/src/layout/knowledgePage.vue b/src/layout/knowledgePage.vue index 220fe9d..83364d5 100644 --- a/src/layout/knowledgePage.vue +++ b/src/layout/knowledgePage.vue @@ -8,19 +8,18 @@ <!-- 左边按钮 --> <button class="submit-left" @click="SubLeft"></button> <div class="question-body"> - <div class="sumTotal">第<span>{{currentKnowledgeIndex+1}}</span>个/共{{Knowledges .length}}个</div> - <div class="question">{{currentKnowledgeTitle}}</div> - - <el-scrollbar height="210px"> - <div class="txt" v-html="currentKnowledge"></div> + <div class="sumTotal">第<span>{{ currentKnowledgeIndex + 1 }}</span>个/共{{ Knowledges.length }}个</div> + <div class="question">{{ currentKnowledgeTitle }}</div> + <el-scrollbar max-height="210px"> + <div class="txt" v-html="currentKnowledge"></div> </el-scrollbar> - <div class="finished">已学习</div> + <div class="finished" v-show="isStudy">已学习</div> </div> <div class="submit-buttons"> - <!-- <button class="submit-btn" @click="reset">退出</button> --> - <!-- <button class="submit-btn" @click="enter">进入仿真实验</button> --> - <router-link class="submit-btn" to="">返回</router-link> - <router-link class="submit-btn" to="/program">完成学习</router-link> + <button class="submit-btn" @click="reset">退出</button> + <button class="submit-btn" @click="enter">完成学习</button> + <!-- <router-link class="submit-btn" :to="{ path:'/studyPage'}" >返回</router-link> --> + <!-- <router-link class="submit-btn" @click="finishStudy">完成学习</router-link> --> </div> </div> @@ -30,50 +29,75 @@ import settingStore from "@/store/modules/setting"; import { ref, computed, onMounted, } from "vue" import { ElMessage } from 'element-plus' -import {getKnowledgeService } from '@/api/user' +import { getKnowledgeService } from '@/api/user' +import { useRouter } from 'vue-router'; +const router = useRouter() const setting = settingStore(); +const isStudy = ref(false) //左箭头 const SubLeft = () => { - console.log(currentKnowledgeIndex.value) - if(currentKnowledgeIndex.value >= 1){ - currentKnowledgeIndex.value = currentKnowledgeIndex.value - 1 - }else{ - ElMessage.warning('无法上翻') - } + console.log(currentKnowledgeIndex.value) + if (currentKnowledgeIndex.value >= 1) { + currentKnowledgeIndex.value = currentKnowledgeIndex.value - 1 + } else { + ElMessage.warning('已是第一个知识点') + } + isStudy.value = true } +const index = ref(0) //右箭头 +// const activeData = ref({}) const SubRight = () => { - if (currentKnowledgeIndex.value+1 < Knowledges.value.length) { + + Knowledges.value[currentKnowledgeIndex.value].isStudy = true + if (currentKnowledgeIndex.value + 1 < Knowledges.value.length) { currentKnowledgeIndex.value++; // 更新到下一题 + } else { ElMessage.success('知识点已学习完毕,请提交') } + isStudy.value = Knowledges.value[currentKnowledgeIndex.value].isStudy + console.log(Knowledges.value); + } const Knowledges = ref<any[]>([]); const getKnowledge = async () => { const res: any = await getKnowledgeService(); - Knowledges.value = res.result.records - // console.log(Knowledges.value,'ress') + Knowledges.value = res.result.kpVlist + // isStudy.value = Knowledges.value[currentKnowledgeIndex.value].isStudy + console.log(Knowledges.value, 'ress') } // 当前题目的索引 - const currentKnowledgeIndex = ref(0); +const currentKnowledgeIndex = ref(0); const currentKnowledge = computed(() => { - // 确保 questions.value 至少有一个元素 - if (Knowledges.value.length > 0) { - return Knowledges.value[currentKnowledgeIndex.value].knowledgeContext; - } - return ''; - }); - const currentKnowledgeTitle = computed(() => { - // 确保 questions.value 至少有一个元素 - if (Knowledges.value.length > 0) { - return Knowledges.value[currentKnowledgeIndex.value].knowledgeName; - - } - return ''; - }); + // 确保 questions.value 至少有一个元素 + if (Knowledges.value.length > 0) { + return Knowledges.value[currentKnowledgeIndex.value].knowledgeContext; + } + return ''; +}); +const currentKnowledgeTitle = computed(() => { + // 确保 questions.value 至少有一个元素 + if (Knowledges.value.length > 0) { + return Knowledges.value[currentKnowledgeIndex.value].knowledgeName; + } + return ''; +}); + +const reset = () => { + router.push('/studyPage') +} +const enter = () => { + console.log('gggg'); + const allStudied = Knowledges.value.every(item => item.isStudy); + if (allStudied) { + router.push('/studyPage'); + } else { + ElMessage.error('请先完成所有学习内容') + } +} onMounted(() => { getKnowledge() }); </script> @@ -212,7 +236,7 @@ onMounted(() => { getKnowledge() }); letter-spacing: 3px; /* 字符间距,单位可以是 px、em 等 */ color: #dc4758; - margin-top: -235px; + margin-top: 30px; margin-right: 20px; } } @@ -237,7 +261,7 @@ onMounted(() => { getKnowledge() }); /* 背景颜色设置为透明 */ border: none; /* 移除边框 */ - cursor: pointer; + //cursor: pointer; /* 鼠标悬停时显示手型 */ width: 300px; height: 41px; @@ -253,5 +277,8 @@ onMounted(() => { getKnowledge() }); text-decoration: none } + .el-scrollbar { + height: 290px; + } } </style> diff --git a/src/layout/spacePage.vue b/src/layout/spacePage.vue index 694ddb7..c9a9a58 100644 --- a/src/layout/spacePage.vue +++ b/src/layout/spacePage.vue @@ -98,13 +98,13 @@ <el-form-item prop="name" label="姓名" label-width="58px"> <el-input v-model="dialogForm.name"></el-input> </el-form-item> - <el-form-item prop="mobile" label="手机号" label-width="58px"> - <el-input v-model="dialogForm.phone" placeholder="请输入手机号"></el-input> + <el-form-item prop="phone" label="手机号" label-width="58px"> + <el-input v-model="dialogForm.phone"></el-input> </el-form-item> - <el-form-item prop="clssid" label="班级" label-width="58px"> + <!-- <el-form-item prop="clssid" label="班级" label-width="58px"> <el-cascader placeholder="请选择所属班级" :props="props" style="width: 142%; height: 0.2344rem" v-model="dialogForm.clssid" @change="handleChange" /> - </el-form-item> + </el-form-item> --> </el-form> <template #footer> <div class="dialog-footer"> @@ -118,14 +118,14 @@ </template> <script setup lang="ts" name="spacePage"> - +import { ElMessage } from 'element-plus' import { ref,onMounted} from "vue" import { useRouter } from 'vue-router' import settingStore from "@/store/modules/setting"; const setting = settingStore(); import userStore from '@/store/modules/user'; -import { getUserInfoService } from '@/api/user' -import {getFaculties } from '@/api/user' +import { getUserInfoService,userChangeService } from '@/api/user' +// import {getFaculties } from '@/api/user' const router = useRouter() const user = userStore(); const loginFn = () => { @@ -152,7 +152,6 @@ const formModel = ref({ const dialogForm=ref({ username: "", name: "", - clssid: '', phone: '', }) const getUser=async()=>{ @@ -184,71 +183,87 @@ const rules = { // }, // ], name: [{ required: true, message: "请输入姓名", trigger: "blur" }], - clssid: [ - { required: true, message: "请选择所属班级", trigger: "blur" }, - ], - mobile: [ + // clssid: [ + // { required: true, message: "请选择所属班级", trigger: "blur" }, + // ], + phone: [ { required: true, message: "请输入手机号", trigger: "blur" }, - { - pattern: /^1[3-9]\d{9}$/, - message: "手机号格式不正确", - trigger: ["change", "blur"], - }, + // { + // pattern: /^1[3-9]\d{9}$/, + // message: "手机号格式不正确", + // trigger: ["change", "blur"], + // }, ] - // score:[ - // { required: true, message: "成绩", trigger: "blur" }, - // ] }; onMounted(()=>{ getUser() }) + + +// // 班级 +// const FacultiesList = ref([]) +// const getFacultiesList = async (data: any) => { +// const res: any = await getFaculties(data) +// console.log(res, 'res11') +// FacultiesList.value = res.result +// } +// const deepValues = ref([]) +// // 配置部门级联选择器 +// const props = { +// lazy: true, +// checkStrictly: true, +// emitPath: false, +// async lazyLoad(node: any, resolve: any) { +// console.log(node); +// deepValues.value = node.pathValues +// await getFacultiesList({ +// primaryType: node.level + 1, +// pid: node.value, +// }) +// const nodes = FacultiesList.value.map((item: any) => ({ +// value: item.id, +// label: item.name, +// })) +// resolve(nodes) +// }, +// } +// const handleChange = (e: any) => { +// console.log(e); +// dialogForm.value.clssid = e +// } + + const loading = ref(false) -const dialog=ref(false) -const changeInformation = () => { +const dialog = ref(false) +const changeInformation =async() => { + await formRef.value.validate(); + await userChangeService({ + realname: dialogForm.value.name, + phone: dialogForm.value.phone, + + }) + .then(() => { + ElMessage.success('修改成功') + }) + .catch((error) => { + // console.log(error, 'error') + ElMessage.error(error.response.data.message) + }) loading.value = true setTimeout(() => { dialog.value = false }, 400) + getUser() } -const openDialog=()=>{ -dialog.value=true +const openDialog = () => { + dialog.value = true + dialogForm.value.name = formModel.value.realname + dialogForm.value.phone = formModel.value.phone } const handleClose = () => { dialog.value = false } - -// 班级 -const FacultiesList = ref([]) -const getFacultiesList = async (data: any) => { - const res: any = await getFaculties(data) - console.log(res, 'res11') - FacultiesList.value = res.result -} -const deepValues = ref([]) -// 配置部门级联选择器 -const props = { - lazy: true, - checkStrictly: true, - emitPath: false, - async lazyLoad(node: any, resolve: any) { - console.log(node); - deepValues.value = node.pathValues - await getFacultiesList({ - primaryType: node.level + 1, - pid: node.value, - }) - const nodes = FacultiesList.value.map((item: any) => ({ - value: item.id, - label: item.name, - })) - resolve(nodes) - }, -} -const handleChange = (e: any) => { - console.log(e); - dialogForm.value.clssid = e -} </script> <style lang="less" scoped> diff --git a/src/layout/studyPage.vue b/src/layout/studyPage.vue index 9d2ec13..6640097 100644 --- a/src/layout/studyPage.vue +++ b/src/layout/studyPage.vue @@ -45,6 +45,7 @@ const handleBoxClick = (boxNumber) => { case 1: isBox1Clicked.value = true; // router.push('/page1'); // 跳转到对应的页面,这里以 /page1 为例 + router.push('/knowledgePage') break; case 2: isBox2Clicked.value = true; diff --git a/src/views/subjectTest/index.vue b/src/views/subjectTest/index.vue index 3f99451..1c6f31a 100644 --- a/src/views/subjectTest/index.vue +++ b/src/views/subjectTest/index.vue @@ -62,6 +62,7 @@ import { useRouter } from 'vue-router'; } //右箭头 const SubRight = async()=>{ + const res:any = await checkapi(selectedOption.value[currentQuestionIndex.value]); // answer.value = res.result; console.log(selectedOption.value);