jichoi / lms_front star
홍아랑 홍아랑 08-13
240813 홍아랑 마이페이지 학생 반 관련 수정 + 퍼즐 및 다리 맞추는 문제 로직 추가
@e8e5a2eb81c7485d5c37ad6c376527b2fd677c82
client/views/pages/main/Chapter/Chapter2_4.vue
--- client/views/pages/main/Chapter/Chapter2_4.vue
+++ client/views/pages/main/Chapter/Chapter2_4.vue
@@ -66,6 +66,8 @@
          this.currentCon = this.items[index].con;
          this.startTimer();
       },
+
+      
       
    },
 }
client/views/pages/main/Chapter/Chapter2_6.vue
--- client/views/pages/main/Chapter/Chapter2_6.vue
+++ client/views/pages/main/Chapter/Chapter2_6.vue
@@ -8,52 +8,45 @@
       <div class="pre-btn" @click="goToPage('Chapter2_5')"><img src="../../../../resources/img/left.png" alt=""></div>
       <div class="content title-box">
         <p class="title mt25 title-bg">step2</p>
-          <div class="flex align-center mb30">
+        <div class="flex align-center mb30">
           <p class="subtitle2 mr20">앗! 퍼즐이 망가졌어! 퍼즐을 맞춰 문장을 완성해보자!</p>
-          <!-- <button><img src="../../../../resources/img/btn10_s.png" alt="">
-          </button> -->
         </div>
         <div class="text-ct">
-          <div class="dropGroup ">
+          <div class="dropGroup">
             <div class="flex justify-center">
-              <div class="popTxt" id="drop1">
-                <img src="../../../../resources/img/img66_38s_1.png" alt="" @click="showButton(1)" >
-                <button  v-if="showButton1"><img src="../../../../resources/img/img66_38s_1_color.png" alt="" ><p>i</p></button>
+              <div class="popTxt" id="drop1" @dragover.prevent @drop="handleDrop(1)">
+                <img src="../../../../resources/img/img66_38s_1.png" alt="">
+                <button v-if="showButton1"><img src="../../../../resources/img/img66_38s_1_color.png" alt=""><p>i</p></button>
               </div>
-              <div class="popTxt" id="drop2" >
-                <img src="../../../../resources/img/img66_38s_2.png" alt="" @click="showButton(2)" >
-                <button v-if="showButton2"><img src="../../../../resources/img/img66_38s_2_color.png" alt="" ><p>have</p></button>
+              <div class="popTxt" id="drop2" @dragover.prevent @drop="handleDrop(2)">
+                <img src="../../../../resources/img/img66_38s_2.png" alt="">
+                <button v-if="showButton2"><img src="../../../../resources/img/img66_38s_2_color.png" alt=""><p>have</p></button>
               </div>
-              <div class="popTxt" id="drop3">
-                <img src="../../../../resources/img/img66_38s_3.png" alt="" @click="showButton(3)" >
-                <button  v-if="showButton3"><img src="../../../../resources/img/img66_38s_3_color.png" alt="" ><p>banana</p></button>
+              <div class="popTxt" id="drop3" @dragover.prevent @drop="handleDrop(3)">
+                <img src="../../../../resources/img/img66_38s_3.png" alt="">
+                <button v-if="showButton3"><img src="../../../../resources/img/img66_38s_3_color.png" alt=""><p>banana</p></button>
               </div>
             </div>
-
           </div>
           <div class="dragGroup">
-            <article style="  right: 0;
-    top: 36%;  " @click="handleDrag(1)" v-show="!dragHidden1">
-              <button id="drag1">
+            <article style="right: 0; top: 36%;" @dragstart="handleDragStart(1)" v-show="!dragHidden1">
+              <button id="drag1" draggable="true">
                 <img src="../../../../resources/img/img67_38s.png" alt="">
                 <p>i</p>
               </button>
             </article>
-            <article style="  left: 0;
-    top: 36%;   " @click="handleDrag(2)" v-show="!dragHidden2">
-              <button id="drag2"> 
+            <article style="left: 0; top: 36%;" @dragstart="handleDragStart(2)" v-show="!dragHidden2">
+              <button id="drag2" draggable="true"> 
                 <img src="../../../../resources/img/img68_38s.png" alt="">
                 <p>have</p>
               </button>
             </article>
-           <article style="left: 50%;
-    top: 10%;"  @click="handleDrag(3)" v-show="!dragHidden3">
-              <button id="drag3">
+            <article style="left: 50%; top: 10%;" @dragstart="handleDragStart(3)" v-show="!dragHidden3">
+              <button id="drag3" draggable="true">
                 <img src="../../../../resources/img/img69_38s.png" alt="">
                 <p>banana</p>
               </button>
-           </article>
-
+            </article>
           </div>
         </div>
       </div>
@@ -72,55 +65,52 @@
       dragHidden1: false,
       dragHidden2: false,
       dragHidden3: false,
+      currentDrag: null // 드래그 중인 퍼즐의 번호를 저장합니다.
     }
   },
   methods: {
     goToPage(page) {
       this.$router.push({ name: page });
     },
-    handleDrag(dragNumber) {
-      // Drag 버튼 숨기기
-      // 여기서는 상태 관리를 통해 버튼을 제어합니다.
-      if (dragNumber === 1) {
-        this.showButton1 = false;
-      } else if (dragNumber === 2) {
-        this.showButton2 = false;
-      } else if (dragNumber === 3) {
-        this.showButton3 = false;
-      }
+    handleDragStart(dragNumber) {
+      // 현재 드래그 중인 퍼즐의 번호를 저장
+      this.currentDrag = dragNumber;
     },
-    showButton(dropNumber) {
-      // Drop 영역의 이미지 클릭 이벤트 핸들러 설정
-      // 여기서는 상태 관리를 통해 버튼을 보이게 합니다.
-      if (dropNumber === 1) {
-        this.showButton1 = true;
+    handleDrop(dropNumber) {
+      // 드래그한 퍼즐의 번호와 드롭할 영역의 번호가 일치하는지 확인
+      if (this.currentDrag === dropNumber) {
+        this.showButton(dropNumber); // 버튼을 보여주고
+        this.hideDragButton(dropNumber); // 드래그한 퍼즐은 숨김
+      }
+      // 드래그 후 상태 초기화
+      this.currentDrag = null;
+    },
+    hideDragButton(dragNumber) {
+      if (dragNumber === 1) {
         this.dragHidden1 = true;
-      } else if (dropNumber === 2) {
-        this.showButton2 = true;
+      } else if (dragNumber === 2) {
         this.dragHidden2 = true;
-      } else if (dropNumber === 3) {
-        this.showButton3 = true;
+      } else if (dragNumber === 3) {
         this.dragHidden3 = true;
       }
     },
-  },
-  watch: {
-
-  },
-  computed: {
-
-  },
-  components: {
-  },
-  mounted() {
-
+    showButton(dropNumber) {
+      if (dropNumber === 1) {
+        this.showButton1 = true;
+      } else if (dropNumber === 2) {
+        this.showButton2 = true;
+      } else if (dropNumber === 3) {
+        this.showButton3 = true;
+      }
+    }
   }
 }
 </script>
+
 <style scoped>
 .dropGroup button{ left: 0;}
 .dragGroup button p{color: #fff; font-size: 35px;}
 .dropGroup button p{
   font-size: 48px;
   color: #fff;}
-</style>
(파일 끝에 줄바꿈 문자 없음)
+</style>
client/views/pages/main/Chapter/Chapter2_7.vue
--- client/views/pages/main/Chapter/Chapter2_7.vue
+++ client/views/pages/main/Chapter/Chapter2_7.vue
@@ -8,34 +8,36 @@
       <div class="pre-btn" @click="goToPage('Chapter2_6')"><img src="../../../../resources/img/left.png" alt=""></div>
       <div class="content title-box">
         <p class="title mt25 title-bg">step2</p>
-          <div class="flex align-center mb30">
+        <div class="flex align-center mb30">
           <p class="subtitle2 mr20">앗! 다리가 무너져서 건널 수가 없어! 다리 조각을 옮겨줘!</p>
-          <!-- <button><img src="../../../../resources/img/btn10_s.png" alt="">
-          </button> -->
         </div>
 
         <div class="text-ct flex justify-center" style="gap: 80px;">
           <div class="dropGroup flex align-center justify-center">
-            <div class="flex" style="gap: 20px; position: relative;" >
+            <div class="flex" style="gap: 20px; position: relative;">
               <img src="../../../../resources/img/img70_39s.png" alt="">
               <div class="textbox">
-                <p style="    left: 247px;
-    bottom: 49px;">1</p>
-                <p  style="     left: 396px;
-    bottom: 97px;">2</p>
-                <p style="     left: 530px;
-    bottom: 179px;">3</p>
+                <p style="left: -180px;bottom: -200px;">I</p>
+                <p id="bridgeTarget" style="left: -105px;bottom: -150px;" @dragover.prevent @drop="handleDrop">?</p>
+                <p style="left: -30px;bottom: -65px;">banana</p>
               </div>
             </div>
-
           </div>
           <div class="dragGroup mt40">
             <div>
-              <button><img src="../../../../resources/img/img71_39s.png" alt=""><p>a</p></button>
-              <button><img src="../../../../resources/img/img71_39s.png" alt=""><p>b</p></button>
-              <button><img src="../../../../resources/img/img71_39s.png" alt=""><p>c</p></button>
+              <button id="have" draggable="true" @dragstart="handleDragStart">
+                <img src="../../../../resources/img/img71_39s.png" alt="">
+                <p>have</p>
+              </button>
+              <button id="has" draggable="true" @dragstart="handleDragStart">
+                <img src="../../../../resources/img/img71_39s.png" alt="">
+                <p>has</p>
+              </button>
+              <button id="had" draggable="true" @dragstart="handleDragStart">
+                <img src="../../../../resources/img/img71_39s.png" alt="">
+                <p>had</p>
+              </button>
             </div>
-
           </div>
         </div>
       </div>
@@ -48,33 +50,91 @@
 export default {
   data() {
     return {
-    }
+      draggedElementId: null, // 드래그한 요소의 ID를 저장
+      correctAnswer: "have",  // 정답 설정
+    };
   },
   methods: {
     goToPage(page) {
       this.$router.push({ name: page });
+    },
+    handleDragStart(event) {
+      // 드래그한 요소의 ID를 저장
+      this.draggedElementId = event.target.id;
+    },
+    handleDrop(event) {
+      const dropZone = event.target;
+      const draggedElement = document.getElementById(this.draggedElementId);
+
+      // 이미 드롭된 요소가 있는지 확인 -> 수정필요
+      const existingElement = dropZone.querySelector('button');
+
+      if (existingElement) {
+        // 이미 드롭된 요소가 있다면 원래 위치로 되돌림
+        const dragGroup = document.querySelector('.dragGroup > div');
+        existingElement.style.visibility = 'visible';
+        existingElement.style.position = '';
+        existingElement.style.top = '';
+        existingElement.style.left = '';
+        dragGroup.appendChild(existingElement);
+      }
+
+      // 새로운 다리 이미지와 텍스트를 드롭 영역에 추가
+      const cloneElement = draggedElement.cloneNode(true);
+      cloneElement.style.position = 'absolute';
+      cloneElement.style.top = "-70px";
+      cloneElement.style.left = "-50px";
+      dropZone.innerHTML = ""; // 기존 ? 텍스트 제거
+      dropZone.appendChild(cloneElement);
+
+      // 드래그한 요소 숨기기
+      draggedElement.style.visibility = "hidden";
+
+      // DOM 업데이트 후 알림을 비동기적으로 처리
+      setTimeout(() => {
+        if (this.draggedElementId === this.correctAnswer) {
+          alert("정답입니다!");
+        } else {
+          alert("오답입니다!");
+        }
+
+        // 드래그 상태 초기화
+        this.draggedElementId = null;
+      }, 0);
     }
-  },
-  watch: {
+
+
 
   },
-  computed: {
-
-  },
-  components: {
-  },
-  mounted() {
-
-  }
-}
+};
 </script>
+
+
 <style scoped>
-.textbox p{position: absolute; }
-.dragGroup button{display: block;}
-.dragGroup button p, .textbox p{    width: fit-content;
-    height: fit-content;
-    background: #ffffffb8;
-    border-radius: 5px;
-    padding: 10px;
-    font-size: 30px; font-family: 'ONEMobilePOP';}
-</style>
(파일 끝에 줄바꿈 문자 없음)
+.textbox p {
+  position: absolute;
+}
+
+.dragGroup button {
+  display: block;
+}
+
+.dragGroup button p,
+.textbox p {
+  width: fit-content;
+  height: fit-content;
+  background: #ffffffb8;
+  border-radius: 5px;
+  padding: 10px;
+  font-size: 30px;
+  font-family: 'ONEMobilePOP';
+}
+
+.dragGroup button {
+  cursor: grab;
+}
+
+.dragGroup button[draggable="true"]:active {
+  cursor: grabbing;
+}
+</style>
client/views/pages/main/MyPage.vue
--- client/views/pages/main/MyPage.vue
+++ client/views/pages/main/MyPage.vue
@@ -1,16 +1,17 @@
 <template>
-
-   <div class="mypage">
+    <div class="mypage">
         <div class="flex justify-between mb30" style="gap: 30px;">
             <div>
                 <div class="title-box flex justify-between mb20">
-                    <p class="title">입장하기</p>
-                    <div class="flex align-center look-btn"><p>더보기 </p><svg-icon type="mdi" :path="mdilArrowRight" class=" ml10"></svg-icon></div>
+                    <p class="title">소속 반</p>
+                    <div class="flex align-center look-btn">
+                        <!-- <p>더보기 </p><svg-icon type="mdi" :path="mdilArrowRight" class=" ml10"></svg-icon> -->
+                    </div>
                 </div>
                 <div class="wrap " style="width: 82rem;">
                     <section class="flex" style="gap: 20px;">
-                        <div class="class flex justify-between">
-                            <div class="box gd-col2" style="gap: 5px;" @click="goToPage('ClassDetail')">
+                        <div class="class flex justify-between" style="cursor: default;">
+                            <div class="box gd-col2" style="gap: 5px;">
                                 <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
                                 <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
                                 <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
@@ -21,51 +22,29 @@
                                 <span class="member">20명</span>
                             </div>
                         </div>
-                        <div class="class flex justify-between">
-                            <div class="box gd-col2" style="gap: 5px;" @click="goToPage('ClassDetail')">
-                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
-                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
-                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
-                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
-                            </div>
-                            <div class="text mt10">
-                                <p class="title1 mb10">A반</p>
-                                <span class="member">20명</span>
-                            </div>
-                        </div>
-                        <div class="class flex justify-between">
-                            <div class="box gd-col2" style="gap: 5px;" @click="goToPage('ClassDetail')">
-                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
-                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
-                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
-                                <div><img src="../../../resources/img/img176_82t.png" alt=""></div>
-                            </div>
-                            <div class="text mt10">
-                                <p class="title1 mb10">A반</p>
-                                <span class="member">20명</span>
-                            </div>
-                        </div>
+
                     </section>
                 </div>
             </div>
-            <div >
+            <div>
                 <div class="title-box flex justify-between mb20">
                     <p class="title">사진첩</p>
                 </div>
                 <div class="photobook">
                     <div class="flex justify-between">
-                            <div class="box" style="gap: 5px;" >
-                                <div><img src="../../../resources/img/img198_12p.png" alt=""></div>
-                            </div>
-                            <div class="text mt10">
-                                <p class="title1 mb10">나의 사진첩</p>
-                                <button @click="selectedTab = 'tab4'; goToPage('PhotoBook')" type="button" title="글쓰기" class="new-btn">
-   바로가기
-</button>
-
-                            </div>
+                        <div class="box" style="gap: 5px;">
+                            <div><img src="../../../resources/img/img198_12p.png" alt=""></div>
                         </div>
-                   
+                        <div class="text mt10">
+                            <p class="title1 mb10">나의 사진첩</p>
+                            <button @click="selectedTab = 'tab4'; goToPage('PhotoBook')" type="button" title="글쓰기"
+                                class="new-btn">
+                                바로가기
+                            </button>
+
+                        </div>
+                    </div>
+
                 </div>
             </div>
         </div>
@@ -112,13 +91,12 @@
                 </div>
             </div>
         </div>
-   </div>
-
+    </div>
 </template>
 
 <script>
 import SvgIcon from '@jamescoyle/vue-icon';
-import { mdiMagnify,  } from '@mdi/js';
+import { mdiMagnify, } from '@mdi/js';
 import { mdilArrowRight } from '@mdi/light-js';
 import ProgressBar from '../../component/ProgressBar.vue';
 import axios from "axios";
@@ -127,7 +105,7 @@
 export default {
     data() {
         return {
-            stdCount : 0,
+            stdCount: 0,
             rank: 0,
 
             mdiMagnify: mdiMagnify,
@@ -142,21 +120,21 @@
             axios({
                 url: "/userclass/classStdCount.json",
                 method: "post",
-                headers:{
+                headers: {
                     "Content-Type": "application/json; charset=UTF-8",
                 },
                 data: {
-                    sclsId:"1"
+                    sclsId: "1"
                 }
             })
-            .then(function (response) {
-                console.log("classStdCount - response : ", response.data);
-                vm.stdCount = response.data;
-            })
-            .catch(function (error) {
-                console.log("classStdCount - error : ", error);
-                alert("반 학생 수 조회에 오류가 발생했습니다.");
-            });
+                .then(function (response) {
+                    console.log("classStdCount - response : ", response.data);
+                    vm.stdCount = response.data;
+                })
+                .catch(function (error) {
+                    console.log("classStdCount - error : ", error);
+                    alert("반 학생 수 조회에 오류가 발생했습니다.");
+                });
         },
 
         photoRankByLikeData: function () {
@@ -164,22 +142,22 @@
             axios({
                 url: "/photo/photoRankByLikeData.json",
                 method: "post",
-                headers:{
+                headers: {
                     "Content-Type": "application/json; charset=UTF-8",
                 },
                 data: {
-                    sclsId:"1",
-                    stdId:"1"
+                    sclsId: "1",
+                    stdId: "1"
                 }
             })
-            .then(function (response) {
-                console.log("Rank - response : ", response.data);
-                vm.rank = response.data;
-            })
-            .catch(function (error) {
-                console.log("Rank - error : ", error);
-                alert("학생 사진 랭킹 조회에 오류가 발생했습니다.");
-            });
+                .then(function (response) {
+                    console.log("Rank - response : ", response.data);
+                    vm.rank = response.data;
+                })
+                .catch(function (error) {
+                    console.log("Rank - error : ", error);
+                    alert("학생 사진 랭킹 조회에 오류가 발생했습니다.");
+                });
         },
 
         goToPage(page) {
webpack.config.js
--- webpack.config.js
+++ webpack.config.js
@@ -41,11 +41,4 @@
     path: `${BASE_DIR}/client/build`,	// __dirname: webpack.config.js 파일이 위치한 경로
     filename: 'bundle.js'
   },
-  configureWebpack: {
-    resolve: {
-      alias: {
-        "@amcharts/amcharts5": "@amcharts/amcharts5/dist/amcharts5.esm.js"
-      }
-    }
-  },
 }
(파일 끝에 줄바꿈 문자 없음)
Add a comment
List