Browse Source

评估页面获取数据

丸子 9 months ago
parent
commit
144a3f877d

+ 10 - 0
src/api/personalized/index.js

@@ -7,4 +7,14 @@ export function saveRecord (data) {
     method: 'post',
     data: data
   })
+}
+
+
+// 获取评估报告
+export function getReport (data) {
+  return axios({
+    url: 'bjdxReport/progress/getReportProgress',
+    method: 'get',
+    data: data
+  })
 }

+ 4 - 2
src/components/HomePage.vue

@@ -91,7 +91,7 @@
           :style="{ backgroundImage: `url(${indexImages[3]})` }"
           @click="goToPersonalized"
         >
-          <span>个性化学习</span>
+          <span>评估报告</span>
         </div>
       </div>
     </div>
@@ -151,7 +151,7 @@ const goToEvaluation = () =>{
  })
 }
 
-// 个性化学习
+// 评估报告
 const goToPersonalized = () =>{
   router.push({
     path:'/personalized'
@@ -165,6 +165,8 @@ const classData = ref([])
 const fetchCtTypes = async () => {
   try {
     const response = await ClassList()
+    console.log(response);
+    
     if (response.code === 0) {
       classData.value = response.data
       // 获取到数据,将第一个选项的值作为默认选中值

+ 38 - 1
src/views/AIDevelop.vue

@@ -297,6 +297,8 @@ import auto from "@/assets/icon/auto_awesome.png";
 
 import { ClassType } from "@/api/class.js";
 import { Message } from "@/utils/message/Message.js";
+// import { saveRecord } from '@/api/personalized/index.js'
+
 
 import DefaultMessage from "@/components/DefaultMessage/index.vue";
 import { CreateDialogue, sendChatMessageStream } from "@/api/questions.js";
@@ -333,7 +335,9 @@ const course = ref({});
 // 菜单数据
 const menuItems = ref([]);
 // 课程集合数据
-const videoPathMap = ref({});
+const videoPathMap = ref({})
+// 已观看课程ID列表
+const watchedCourseIds = ref([]);
 
 //课程小节字典(需要新加接口调取字典)
 const menuDict = ref({
@@ -349,10 +353,21 @@ onMounted(async () => {
   const typeId = router.currentRoute.value.query.typeId;
   if (typeId) {
     try {
+      // 存储typeId到localStorage
+      localStorage.setItem('typeId', typeId);
+
       // 取接口课程数据
       const res = await ClassType(typeId);
       console.log(res);
       courseList.value = res.data;
+
+      // 初始化已观看课程ID
+      const savedWatchedIds = localStorage.getItem('watchedCourseIds');
+      if (savedWatchedIds) {
+        watchedCourseIds.value = JSON.parse(savedWatchedIds);
+      }
+
+
       //课程数据
       courseList.value.forEach((courseTemp, index) => {
         let menuIndex = courseTemp.courseLabel + "-" + (index + 1);
@@ -411,6 +426,22 @@ onMounted(async () => {
   }
 });
 
+
+// 保存记录
+// onMounted(()=>{
+//   let as = {
+//     "brpNjId": 1,
+//     "brpCtId": 1,
+//     "brpCourseId": 1, 
+//     "brpType": "course",
+//     "brpProgress": 30
+//   }
+//     console.log(as);
+//   saveRecord(as).then(res=>{
+//     console.log(res);
+//   })
+// })
+
 // 菜单打开和关闭的处理函数
 const handleOpen = () => {};
 const handleClose = () => {};
@@ -469,6 +500,12 @@ const playNextVideo = () => {
   //测试账号禁用视频
   if (disableVideo()) return;
 
+  // 记录当前视频ID为已观看
+  if (course.value && course.value.id && !watchedCourseIds.value.includes(course.value.id)) {
+    watchedCourseIds.value.push(course.value.id);
+    localStorage.setItem('watchedCourseIds', JSON.stringify(watchedCourseIds.value));
+  }
+
   const allIndices = flattenMenuItems();
   const currentIndexInList = allIndices.indexOf(course.value.key);
   if (currentIndexInList !== -1 && currentIndexInList < allIndices.length - 1) {

+ 4 - 0
src/views/AIGeneralCourse.vue

@@ -165,6 +165,10 @@ const handleGradeSelect = command => {
   localStorage.setItem('selectedGrade', command)
   // 年级切换时重新加载数据的逻辑
   const selectedItem = classData.value.find(item => item.ctType === command)
+  // 存储年级id
+  if (selectedItem) {
+    localStorage.setItem('selectedGradeId', selectedItem.id)
+  }
   if (selectedItem) {
     ClassOutline(selectedItem.id).then(res => {
       if (res.code === 0) {

+ 12 - 19
src/views/personalized/Personalized.vue

@@ -70,14 +70,14 @@
 
 <script setup>
 import { ref,onMounted } from "vue";
-import { ArrowLeftBold } from "@element-plus/icons-vue";
-import { saveRecord } from '@/api/personalized/index.js'
+import { ArrowLeftBold } from '@element-plus/icons-vue'
+import { getReport } from '@/api/personalized/index.js'
 import { useRouter } from "vue-router";
 const router = useRouter();
 
 // 返回首页
 const goBack = () => {
-  router.back();
+  router.push('/home');
 };
 
 // 课程开课率进度条数据
@@ -92,21 +92,6 @@ const progressData = ref([
   { id: 8, desc: "08 AI伦理安全", percentage: 0 },
 ]);
 
-// 保存记录
-onMounted(()=>{
-  let as = {
-    "brpNjId": 1,
-    "brpCtId": 1,
-    "brpCourseId": 1, 
-    "brpType": "course",
-    "brpProgress": 24
-  }
-    console.log(as);
-  saveRecord(as).then(res=>{
-    console.log(res);
-  })
-})
-
 // 互动完成率进度条数据
 const interactionData = ref([
   { id: 1, desc: "01 AI初体验", percentage: 50 },
@@ -119,13 +104,21 @@ const interactionData = ref([
   { id: 8, desc: "08 AI伦理安全", percentage: 0 },
 ]);
 
+// 获取进度
+onMounted(async()=>{
+  try {
+    const res = await getReport({ "brpNjld": "1" });
+    console.log(res);
+  } catch (error) {
+    console.error('获取进度失败:', error);
+  }
+})
 
 
 </script>
 
 <style scoped lang="scss">
 @use "sass:math";
-
 // 定义rpx转换函数
 @function rpx($px) {
   @return math.div($px, 750) * 100vw;