From 932a023d84bb9c567fe244429ac3569cdf357387 Mon Sep 17 00:00:00 2001 From: xy <2115269706@qq.com> Date: Sat, 22 Mar 2025 17:12:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E4=B8=8E?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E7=82=B9=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.ts | 18 +++++++++++- src/layout/knowledgePage.vue | 53 ++++++++++++++++++++++++------------ src/layout/spacePage.vue | 18 ++++++------ 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/src/api/user.ts b/src/api/user.ts index c526980..5d893e2 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -22,4 +22,20 @@ export const sturegister = (data: any) => { method: 'POST', data, }) -} \ No newline at end of file +} + +// 获取用户信息 +export const getUserInfoService = () => { + return request({ + url: "/xnRecords/getIndividualScore", + method: "get", + }); +}; + +//获取知识点信息 +export const getKnowledgeService = () => { + return request({ + url: "knowledgepoint/xnKnowledgePoint/list", + method: "get", + }); +}; \ No newline at end of file diff --git a/src/layout/knowledgePage.vue b/src/layout/knowledgePage.vue index dcbb5ef..cbfe8c4 100644 --- a/src/layout/knowledgePage.vue +++ b/src/layout/knowledgePage.vue @@ -8,11 +8,11 @@ <!-- 左边按钮 --> <button class="submit-left" @click="SubLeft"></button> <div class="question-body"> - <div class="sumTotal">第一个/共X个</div> - <div class="question">知识点学习</div> + <div class="sumTotal">第<span>{{currentKnowledgeIndex+1}}</span>个/共{{Knowledges .length}}个</div> + <div class="question">{{currentKnowledgeTitle}}</div> <el-scrollbar height="210px"> - <div class="txt" v-html="Text"></div> + <div class="txt" v-html="currentKnowledge"></div> </el-scrollbar> <div class="finished">已学习</div> </div> @@ -26,32 +26,51 @@ </div> </template> -<script lang="ts" setup> +<script lang="ts" setup name="knowledgePage"> import settingStore from "@/store/modules/setting"; -import { getExperiment } from '@/api/index' -import { ref, computed, onMounted, onUnmounted } from "vue" -import { useRouter } from 'vue-router'; +import { ref, computed, onMounted, } from "vue" +import { ElMessage } from 'element-plus' +import {getKnowledgeService } from '@/api/user' const setting = settingStore(); //左箭头 const SubLeft = () => { - + console.log(currentKnowledgeIndex.value) + if(currentKnowledgeIndex.value >= 1){ + currentKnowledgeIndex.value = currentKnowledgeIndex.value - 1 + }else{ + ElMessage.warning('无法上翻') + } } //右箭头 const SubRight = () => { } -const Text = ref() -const getContent = async () => { - const res: any = await getExperiment(); - // console.log(res.result.purposeRequirements,'res') - Text.value = res.result.purposeRequirements - console.log(Text.value); - +const Knowledges = ref<any[]>([]); +const getKnowledge = async () => { + const res: any = await getKnowledgeService(); + Knowledges.value = res.result.records + // console.log(Knowledges.value,'ress') } +// 当前题目的索引 + 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 ''; + }); -onMounted(() => { getContent() }); - +onMounted(() => { getKnowledge() }); </script> <style lang="scss" scoped> diff --git a/src/layout/spacePage.vue b/src/layout/spacePage.vue index 2a755b4..4a8861b 100644 --- a/src/layout/spacePage.vue +++ b/src/layout/spacePage.vue @@ -43,7 +43,7 @@ 班级 </div> <div class="right"> - <el-input v-model="formModel.clssid" style="border-color: #20bec8;"></el-input> + <el-input v-model="formModel.className" style="border-color: #20bec8;"></el-input> </div> </el-form-item> @@ -57,7 +57,7 @@ 学号 </div> <div class="right"> - <el-input v-model="formModel.studentNumb" + <el-input v-model="formModel.workNo" style="border-color: #20bec8"></el-input> </div> </div> @@ -99,7 +99,7 @@ import { useRouter } from 'vue-router' import settingStore from "@/store/modules/setting"; const setting = settingStore(); import userStore from '@/store/modules/user'; -import { getUserInfo } from "@/api"; +import { getUserInfoService } from '@/api/user' const router = useRouter() const user = userStore(); const loginFn = () => { @@ -120,15 +120,17 @@ const formRef = ref(); const formModel = ref({ username: "", realname: "", - clssid: '', - studentNumb: "", + className: '', + workNo: "", phone: '', score: '' }); const getUser=async()=>{ - const res: any = await getUserInfo(); - formModel.value = res.result.userInfo; - console.log(formModel, 'formModel'); + const res: any = await getUserInfoService(); + // console.log(res.result,'aaaaa'); + + formModel.value = res.result; + // console.log(formModel, 'formModel'); }