SPA-91
This commit is contained in:
1 parent
b829574822
commit
9c97a6649b
5 files changed
+113
-20
No files matched your search
@@ -0,0 +1,76 @@
|
|||||||
|
<template>
|
||||||
|
<div class="px-4">
|
||||||
|
{{ displayDays + declOfNum(displayDays, [' день', ' дня', ' дней']) }}
|
||||||
|
{{ displayHours + declOfNum(displayHours, [' час', ' часа', ' часов']) }}
|
||||||
|
{{ displayMinutes + declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}
|
||||||
|
{{ displaySeconds + declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
endTime: {
|
||||||
|
type: Date,
|
||||||
|
default: () => { return new Date.setFullYear() }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setup(props) {
|
||||||
|
|
||||||
|
const seconds = 1000
|
||||||
|
const displayMinutes = ref(0);
|
||||||
|
const displayHours = ref(0);
|
||||||
|
const displayDays = ref(0);
|
||||||
|
const displaySeconds = ref(0)
|
||||||
|
|
||||||
|
const minutes = computed(() => {
|
||||||
|
return seconds * 60
|
||||||
|
})
|
||||||
|
|
||||||
|
const hours = computed(() => {
|
||||||
|
return minutes.value * 60
|
||||||
|
})
|
||||||
|
|
||||||
|
const days = computed(() => {
|
||||||
|
return hours.value * 24
|
||||||
|
})
|
||||||
|
|
||||||
|
function declOfNum(value, titles) {
|
||||||
|
const cases = [2, 0, 1, 1, 1, 2]
|
||||||
|
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]]
|
||||||
|
}
|
||||||
|
|
||||||
|
function countDown() {
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
const date = new Date()
|
||||||
|
const distance = props.endTime.getTime() - date.getTime()
|
||||||
|
|
||||||
|
if (distance < 0) {
|
||||||
|
clearInterval(timer)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
displayDays.value = Math.floor(distance / days.value)
|
||||||
|
displayHours.value = Math.floor((distance % days.value) / hours.value)
|
||||||
|
displayMinutes.value = Math.floor((distance % hours.value) / minutes.value)
|
||||||
|
displaySeconds.value = Math.floor((distance % minutes.value) / seconds)
|
||||||
|
|
||||||
|
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
countDown()
|
||||||
|
|
||||||
|
return {
|
||||||
|
displayMinutes,
|
||||||
|
displayHours,
|
||||||
|
displayDays,
|
||||||
|
displaySeconds,
|
||||||
|
declOfNum,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -1,44 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container>
|
<v-row justify="center mb-1">
|
||||||
<v-row dense justify="center">
|
<v-card class="py-1" variant="otlined">
|
||||||
<v-card class="bg-red-darken-2 py-5">
|
<v-card-title> До окончания голосования осталось: </v-card-title>
|
||||||
<v-card-title class="text-uppercase"> До окончания голосования осталось: </v-card-title>
|
|
||||||
<v-row dense class="align-baseline justify-center">
|
<v-row dense class="align-baseline justify-center">
|
||||||
<v-col cols="2" class="text-center">
|
<v-col cols="2" class="text-center">
|
||||||
<v-card class="bg-yellow-darken-4">
|
<v-card class="bg-yellow-darken-4">
|
||||||
<v-card-title>{{ displayDays }}</v-card-title>
|
<v-card-title>{{ displayDays }}</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
<span class="text-caption">{{ declOfNum(displayDays, [' день', ' дня', ' дней']) }}</span>
|
||||||
</v-col>
|
</v-col>
|
||||||
<div>:</div>
|
<v-col cols="auto">:</v-col>
|
||||||
<v-col cols="2" class="text-center">
|
<v-col cols="2" class="text-center">
|
||||||
<v-card class="bg-yellow-darken-4">
|
<v-card class="bg-yellow-darken-4">
|
||||||
<v-card-title>{{ displayHours }}</v-card-title>
|
<v-card-title>{{ displayHours }}</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
<span class="text-caption">{{ declOfNum(displayHours, [' час', ' часа', ' часов']) }}</span>
|
||||||
</v-col>
|
</v-col>
|
||||||
<div>:</div>
|
<v-col cols="auto">:</v-col>
|
||||||
<v-col cols="2" class="text-center">
|
<v-col cols="2" class="text-center">
|
||||||
<v-card class="bg-yellow-darken-4">
|
<v-card class="bg-yellow-darken-4">
|
||||||
<v-card-title>{{ displayMinutes }}</v-card-title>
|
<v-card-title>{{ displayMinutes }}</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
<span class="text-caption">{{ declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}</span>
|
||||||
</v-col>
|
</v-col>
|
||||||
<div>:</div>
|
<v-col cols="auto">:</v-col>
|
||||||
<v-col cols="2" class="text-center">
|
<v-col cols="2" class="text-center">
|
||||||
<v-card class="bg-yellow-darken-4">
|
<v-card class="bg-yellow-darken-4">
|
||||||
<v-card-title>{{ displaySeconds }}</v-card-title>
|
<v-card-title>{{ displaySeconds }}</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
<span class="text-caption">{{ declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}</span>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row dense class="justify-center">
|
|
||||||
<v-card-subtitle opacity="false" class="text-uppercase">
|
|
||||||
{{ displayDays == 1 ? 'День' : displayDays > 1 && displayDays <= 4 ? 'Дня' : displayDays <= 0 ? 'Дней' : 'Дней'}}
|
|
||||||
</v-card-subtitle>
|
|
||||||
<v-card-subtitle opacity="false" class="text-uppercase">Часов</v-card-subtitle>
|
|
||||||
<v-card-subtitle opacity="false" class="text-uppercase">Минут</v-card-subtitle>
|
|
||||||
<v-card-subtitle opacity="false" class="text-uppercase">Секунд</v-card-subtitle>
|
|
||||||
</v-row>
|
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
@@ -70,7 +64,12 @@ export default {
|
|||||||
const days = computed(() => {
|
const days = computed(() => {
|
||||||
return hours.value * 24
|
return hours.value * 24
|
||||||
})
|
})
|
||||||
console.log(days.value);
|
|
||||||
|
function declOfNum(value, titles) {
|
||||||
|
const cases = [2, 0, 1, 1, 1, 2]
|
||||||
|
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]]
|
||||||
|
}
|
||||||
|
|
||||||
function countDown() {
|
function countDown() {
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
@@ -101,6 +100,7 @@ export default {
|
|||||||
displayHours,
|
displayHours,
|
||||||
displayDays,
|
displayDays,
|
||||||
displaySeconds,
|
displaySeconds,
|
||||||
|
declOfNum,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,6 +152,12 @@ const routes = [
|
|||||||
component: () =>
|
component: () =>
|
||||||
import("@/views/VoteHomePage.vue")
|
import("@/views/VoteHomePage.vue")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/secret',
|
||||||
|
name: 'Secret Page',
|
||||||
|
component: () =>
|
||||||
|
import("@/views/secret/SecretPage.vue")
|
||||||
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -32,8 +32,9 @@
|
|||||||
Окончание: {{ formatDate(voting.endDate) }}
|
Окончание: {{ formatDate(voting.endDate) }}
|
||||||
</v-card-subtitle>
|
</v-card-subtitle>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
Осталось: {{ timeRemaining(voting.endDate) }}
|
Осталось до окончания голосования:
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
<TimerUI :endTime="endTimeOfVote"/>
|
||||||
<v-card-actions class="justify-space-between">
|
<v-card-actions class="justify-space-between">
|
||||||
<v-btn
|
<v-btn
|
||||||
v-if="!voting.voted"
|
v-if="!voting.voted"
|
||||||
@@ -120,9 +121,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import {computed, ref} from "vue";
|
import {computed, ref} from "vue";
|
||||||
import VoteConstructor from "@/views/VoteConstructor.vue";
|
import VoteConstructor from "@/views/VoteConstructor.vue";
|
||||||
|
import SmallTimer from "@/components/secret/SmallTimer.vue";
|
||||||
|
import TimerUI from "@/components/secret/TimerUI.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {VoteConstructor},
|
components: { VoteConstructor, SmallTimer, TimerUI },
|
||||||
setup() {
|
setup() {
|
||||||
const currentTab = ref("current");
|
const currentTab = ref("current");
|
||||||
const votes = ref([
|
const votes = ref([
|
||||||
@@ -199,6 +202,8 @@ export default {
|
|||||||
votes.value = votes.value.filter((v) => v.id !== id);
|
votes.value = votes.value.filter((v) => v.id !== id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const endTimeOfVote = new Date(2025, 0, 14, 15, 58, 5)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentTab,
|
currentTab,
|
||||||
votes,
|
votes,
|
||||||
@@ -215,6 +220,7 @@ export default {
|
|||||||
openResultsModal,
|
openResultsModal,
|
||||||
closeResultsModal,
|
closeResultsModal,
|
||||||
deleteVoting,
|
deleteVoting,
|
||||||
|
endTimeOfVote,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<v-container>
|
||||||
<TimerUI :endTime="end" />
|
<TimerUI :endTime="end" />
|
||||||
|
<SmallTimer :endTime="end"/>
|
||||||
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TimerUI from "@/components/secret/TimerUI.vue"
|
import TimerUI from "@/components/secret/TimerUI.vue"
|
||||||
|
import SmallTimer from "@/components/secret/SmallTimer.vue"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
TimerUI,
|
TimerUI,
|
||||||
|
SmallTimer,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const end = new Date(2025, 0, 16, 13, 2, 59)
|
const end = new Date(2025, 0, 14, 15, 58, 5)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user