lsc 2 years ago
parent
commit
a3e08fbb1b
1 changed files with 7 additions and 6 deletions
  1. 7 6
      src/components/tools/time.vue

+ 7 - 6
src/components/tools/time.vue

@@ -103,15 +103,15 @@ export default {
       }
       this.displayTimeLeft(this.wholeTime);
     },
-    update(value, timePercent) {
+    update(value, timePercent, type) {
       this.offset = -this.length - (this.length * value) / timePercent;
-      if (value === 0) {
+      if (value === 0 && type === 1) {
         this.pointerTransform = `rotate(${360}deg)`;
       } else {
         this.pointerTransform = `rotate(${(360 * value) / timePercent}deg)`;
       }
     },
-    displayTimeLeft(timeLeft) {
+    displayTimeLeft(timeLeft, type) {
       //displays time on the input
       let minutes = Math.floor(timeLeft / 60);
       let seconds = timeLeft % 60;
@@ -119,7 +119,7 @@ export default {
         seconds < 10 ? "0" : ""
       }${seconds}`;
       // displayOutput.textContent = displayString;
-      this.update(timeLeft, this.wholeTime);
+      this.update(timeLeft, this.wholeTime, type);
     },
     timer(seconds) {
       //counts time, takes seconds
@@ -138,6 +138,7 @@ export default {
           //   btn.style.opacity = 1;
           // });
           _this.displayTimeLeft(_this.wholeTime);
+          _this.$message.success("时间到!!!");
           // pauseBtn.classList.remove("pause");
           // pauseBtn.classList.add("play");
           return;
@@ -170,8 +171,8 @@ export default {
       this.isPaused = false;
       this.wholeTime = 0;
       this.timeLeft = null;
-      this.update(this.wholeTime, this.wholeTime);
-      this.displayTimeLeft(this.wholeTime);
+      this.update(this.wholeTime, this.wholeTime, 1);
+      this.displayTimeLeft(this.wholeTime, 1);
     },
   },
   created() {