jichoi / lms_front star
woals 2024-08-13
240813 권민수 학생 정보 받아오기 기능 구현(테스트)
@feb23e1ed6f62dc00734bc4219fdd564f8099de8
client/views/layout/Side.vue
--- client/views/layout/Side.vue
+++ client/views/layout/Side.vue
@@ -7,8 +7,8 @@
             <div class="flex align-start">
                 <img src="../../resources/img/img16_s.png" alt="">
                 <div class="ml25" >
-                    <p class="name mb10">학생이름</p>
-                    <p class="mb5">xx중학교 3학년 x반</p>
+                    <p class="name mb10">{{ studentInfo.studentName }}</p>
+                    <p class="mb5">{{ studentInfo.institutionName }} {{ studentInfo.grade }}학년 {{ studentInfo.className }}</p>
                     <progress-bar :progress="progress"></progress-bar>
                     <span @click="increaseProgress">오늘의 공부</span>
                     <span class="brown ml10">{{ progress }}%</span>
@@ -17,8 +17,9 @@
             <hr>
             <p class="title2 mb25">최근 학습 히스토리</p>
             <ul class="flex justify-between ml30 mb30">
-                <li>자학사 3학년 2학기</li>
-                <li>자학사 3학년 2학기</li>
+                <li v-for="historyItem in studentInfo.history" :key="historyItem.unitId">
+                    {{ historyItem.bookName }} {{ historyItem.unitName }}
+                </li>
             </ul>
         </div>
         <div class="ask mb30">
@@ -40,22 +41,47 @@
  
 <script>
 import ProgressBar from '../component/ProgressBar.vue';
+import axios from 'axios';
 
 export default {
     data () {
         return {
             buttonText: '오답노트',
-            progress: 20
+            progress: 20,
+            studentInfo: {
+                studentName: '',
+                institutionName: '',
+                grade: '',
+                className: '',
+                studentQuestion: '',
+                history: []
+            },
+            userId: '1' // userId 임시 설정
         }
     },
     methods: {
+
+        // 학생 정보를 가져오는 메서드
+        fetchStudentInfo() {
+            axios.post('/studentInfo/getInfo.json', { userId: this.userId })
+            .then(response => {
+                console.log(response.data);
+                this.studentInfo = response.data;
+            })
+            .catch(error => {
+                console.error('학생 정보 가져오기 실패:', error);
+            });
+        },
+
         handleClick() {
             this.toggleText();
             this.goToPage('PreviewNote');
         },
+
         handleClick() {
             this.toggleTextAndNavigate();
         },
+
         toggleTextAndNavigate() {
             if (this.buttonText === '오답노트') {
                 this.buttonText = '학습 코스';
@@ -67,14 +93,16 @@
                  // 버튼 텍스트가 '오답노트'일 때 이동할 경로
             }
         },
+
         goToPage(page) {
             this.$router.push({ name: page });
         },
+
         increaseProgress() {
-      if (this.progress < 100) {
-        this.progress += 10;
-      }
-    }
+            if (this.progress < 100) {
+                this.progress += 10;
+            }
+        }
 
     },
     watch: {
@@ -84,10 +112,11 @@
 
     },
     components: {
-    ProgressBar
+        ProgressBar
   },
     mounted() {
-        console.log('Menu mounted');
+        console.log('Side mounted');
+        this.fetchStudentInfo(); 
     }
 }
 </script>
(파일 끝에 줄바꿈 문자 없음)
Add a comment
List