jichoi / lms_front star
이은진 이은진 2024-08-14
240814 이은진 단어장3 수정
@618dff29bc0ec0c71b133d54740d8c2fff980839
client/views/pages/main/Chapter/Chapter2_2.vue
--- client/views/pages/main/Chapter/Chapter2_2.vue
+++ client/views/pages/main/Chapter/Chapter2_2.vue
@@ -1,10 +1,10 @@
 <template>
    <div id="Chapter2_2" class="content-wrap">
       <div style="margin: 30px 0px 50px; width: 20%">
-      <router-link to="/MyPlan.page">
-        <div class="logo mb25"><img src="../../../../resources/img/logo2.png" alt=""></div>
-      </router-link>
-    </div>
+         <router-link to="/MyPlan.page">
+            <div class="logo mb25"><img src="../../../../resources/img/logo2.png" alt=""></div>
+         </router-link>
+      </div>
       <div class="title-box mb25 flex align-center mt40">
          <span class="title mr40">1. Hello WORLD</span>
          <span class="subtitle">my name is dd</span>
@@ -17,13 +17,15 @@
             <div class="flex align-center mb30">
                <p class="subtitle2 mr20">카드를 뒤집어 보세요.</p>
                <!-- <button><img src="../../../../resources/img/btn10_s.png" alt="">
-          </button> --></div><div class="time-bg">
-            <div>
-              <div class="time">
-                <p class="second">{{timer}}</p>
-                <p class="text">sec</p>
-              </div>
+          </button> -->
             </div>
+            <div class="time-bg">
+               <div>
+                  <div class="time">
+                     <p class="second">{{ timer }}</p>
+                     <p class="text">sec</p>
+                  </div>
+               </div>
             </div>
 
             <div class="imgGroup">
@@ -32,7 +34,6 @@
                      <div class="listenGroup">
                         <img :src="item.imgSrc1">
                         <p class="textbox"><img :src="item.imgSrc"></p>
-
                      </div>
                      <div class="listenGroup" :style="{ display: item.isSecondImageVisible ? 'block' : 'none' }">
                         <img :src="item.imgSrc2">
@@ -54,11 +55,14 @@
    data() {
       return {
          items: [
-            { imgSrc1: 'client/resources/img/img49_s.png', imgSrc2: 'client/resources/img/img50_s.png', imgSrc: 'client/resources/img/img59_36s.png', isSecondImageVisible: false, title: 'a' },
-            { imgSrc1: 'client/resources/img/img49_s.png', imgSrc2: 'client/resources/img/img50_s.png', imgSrc: 'client/resources/img/img59_36s.png', isSecondImageVisible: false, title: 'a' },
-            { imgSrc1: 'client/resources/img/img49_s.png', imgSrc2: 'client/resources/img/img50_s.png', imgSrc: 'client/resources/img/img59_36s.png', isSecondImageVisible: false, title: 'a' },
-            { imgSrc1: 'client/resources/img/img49_s.png', imgSrc2: 'client/resources/img/img50_s.png', imgSrc: 'client/resources/img/img59_36s.png', isSecondImageVisible: false, title: 'a' }
-         ]
+            { imgSrc1: 'client/resources/img/img49_s.png', imgSrc2: 'client/resources/img/img50_s.png', imgSrc: 'client/resources/img/img77_41s.png', isSecondImageVisible: false, title: 'america' },
+            { imgSrc1: 'client/resources/img/img49_s.png', imgSrc2: 'client/resources/img/img50_s.png', imgSrc: 'client/resources/img/img47_s.png', isSecondImageVisible: false, title: 'airplane' },
+            { imgSrc1: 'client/resources/img/img49_s.png', imgSrc2: 'client/resources/img/img50_s.png', imgSrc: 'client/resources/img/img75_41s.png', isSecondImageVisible: false, title: 'cat' },
+            { imgSrc1: 'client/resources/img/img49_s.png', imgSrc2: 'client/resources/img/img50_s.png', imgSrc: 'client/resources/img/img74_41s.png', isSecondImageVisible: false, title: 'mountain' }
+         ],
+         timer: 0,
+         intervalId: null,
+         currentIndex: 0,
       };
    },
    methods: {
@@ -67,7 +71,48 @@
       },
       toggleImage(index) {
          this.items[index].isSecondImageVisible = !this.items[index].isSecondImageVisible;
+      },
+      startTimer() {
+      // 현재 실행 중인 타이머가 있다면 정리
+      if (this.intervalId) {
+        clearInterval(this.intervalId);
       }
+
+      // 타이머 및 이미지 토글 상태 초기화
+      this.timer = 0;
+      this.currentIndex = 0; // 현재 타이머 인덱스를 추적
+
+      // 시작 타이머 설정
+      this.runTimer();
+      },
+
+      runTimer() {
+         // 반복 타이머 설정
+         this.intervalId = setInterval(() => {
+            if (this.currentIndex == this.items.length)
+               return;
+            if (this.timer < 5) {
+               this.timer++; 
+            } else {
+               // 타이머가 끝났을 때, 다음 타이머 설정
+               this.timer = 0;
+
+               if (this.currentIndex < this.items.length) {
+                  // 현재 인덱스에 해당하는 아이템으로 이미지 토글
+                  this.toggleImage(this.currentIndex); 
+                  this.currentIndex++;
+               } else {
+                  // 모든 타이머가 완료되었으면 타이머 정리
+                  clearInterval(this.intervalId);
+                  this.intervalId = null;
+                  console.log('모든 타이머가 완료되었습니다.');
+               }
+            }
+         }, 1000);
+    },
+   },
+   mounted() {
+      this.startTimer()
    }
 }
 
@@ -86,6 +131,6 @@
 
 .listenGroup .textbox {
    top: 50%;
-    left: 50%;
+   left: 50%;
 }
 </style>
(No newline at end of file)
Add a comment
List