Исправила индикатор , настроила таймер

This commit is contained in:
Daria Golova
2022-10-17 12:45:00 +03:00
parent c1e1a3a4cd
commit bc7e82b88e
2 changed files with 37 additions and 19 deletions

View File

@@ -6,7 +6,7 @@
span.member-name.font-medium.text-base.mr-6 {{ info.name }} span.member-name.font-medium.text-base.mr-6 {{ info.name }}
img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg") img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg")
base-doc-ok-button base-doc-ok-button
.flex.flex-col .body.flex.flex-col
span.block.time-indicator(v-if="isShownIndicator" :style="indicatorLocation") span.block.time-indicator(v-if="isShownIndicator" :style="indicatorLocation")
.line.flex.items-center(v-for="hour in hoursArray" :key="hour") .line.flex.items-center(v-for="hour in hoursArray" :key="hour")
.middle-line .middle-line
@@ -44,8 +44,8 @@ export default {
let newTime = this.currentTime let newTime = this.currentTime
.split(":") .split(":")
.map((elem) => parseInt(elem, 10)); .map((elem) => parseInt(elem, 10));
let result = (newTime[0] - 7) * 60.5 + newTime[1]; let result = (newTime[0] - 8) * 62 + newTime[1] * 1.03;
if (result > 666) { if (result > 620) {
this.isShownIndicator = false; this.isShownIndicator = false;
return 0; return 0;
} }
@@ -58,11 +58,12 @@ export default {
<style lang="sass" scoped> <style lang="sass" scoped>
.calendar-column-wrapper .calendar-column-wrapper
width: 100% width: 100%
position: relative
.header .header
height: 48px height: 48px
border-bottom: 1px solid var(--border-light-grey-color)
.body
position: relative
.avatar-wrapper .avatar-wrapper
width: 32px width: 32px
@@ -78,6 +79,9 @@ export default {
.line .line
border-bottom: 1px solid var(--border-light-grey-color) border-bottom: 1px solid var(--border-light-grey-color)
height: 62px height: 62px
&:nth-child(2)
height: 63px
border-top: 1px solid var(--border-light-grey-color)
&:last-child &:last-child
display: none display: none

View File

@@ -39,6 +39,12 @@ export default {
}; };
}, },
methods: { methods: {
hours() {
return parseInt(this.currentTime.slice(0, -6), 10);
},
hoursMinutes() {
return this.currentTime.slice(0, -3);
},
previousDate() { previousDate() {
this.$emit("previous-date"); this.$emit("previous-date");
}, },
@@ -48,43 +54,51 @@ export default {
selectedLayout(option) { selectedLayout(option) {
this.$emit("selected-layout", option); this.$emit("selected-layout", option);
}, },
updateTime() { startTimer() {
let currentHour = parseInt(this.currentTime.slice(0, -6), 10); if (this.hours() <= 18 && this.hours() >= 8) {
if (currentHour < 20 && currentHour > 8) {
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.changeCurrentTime(); this.changeCurrentTime();
this.changeHoursArray(); this.changeHoursArray();
}, 30000); }, 30000);
} }
}, },
stopTimer() {
clearInterval(this.timer);
this.timer = null;
},
changeCurrentTime() { changeCurrentTime() {
this.currentTime = moment().format("HH:mm:ss"); this.currentTime = moment().format("HH:mm:ss");
}, },
hoursArrayInitialization() { hoursArrayInitialization() {
for (let i = 8; i <= 18; i++) { for (let i = 8; i <= 18; i++) {
let startTime = this.currentTime.slice(0, -3); if (i === this.hours()) {
let currentHour = parseInt(startTime.slice(0, -3), 10); this.hoursArray.push(this.hoursMinutes());
if (i === currentHour) {
this.hoursArray.push(startTime);
} else this.hoursArray.push(`${i}:00`); } else this.hoursArray.push(`${i}:00`);
} }
}, },
changeHoursArray() { changeHoursArray() {
let newCurrentTime = this.currentTime.slice(0, -3); this.hoursArray = this.hoursArray.map((elem) => {
let currentHour = parseInt(newCurrentTime.slice(0, -3), 10); if (parseInt(elem.slice(0, -3), 10) === this.hours()) {
let newHoursArray = this.hoursArray.map((elem) => { return this.hoursMinutes();
if (parseInt(elem.slice(0, -3), 10) === currentHour) {
return this.currentTime.slice(0, -3);
} }
return elem; return elem;
}); });
this.hoursArray = newHoursArray; },
},
watch: {
currentTime() {
if (this.hours() >= 18) {
this.stopTimer();
}
}, },
}, },
mounted() { mounted() {
this.changeCurrentTime(); this.changeCurrentTime();
this.hoursArrayInitialization(); this.hoursArrayInitialization();
this.updateTime(); this.startTimer();
},
beforeUnmount() {
this.stopTimer();
}, },
}; };
</script> </script>