Api calls done within & refactored as housekeeping.
Strings "Følg med på utviklingen" and "chat om trekningen" scrolls the page content into view if clicked.
This commit is contained in:
@@ -5,7 +5,10 @@
|
|||||||
<div class="instructions">
|
<div class="instructions">
|
||||||
<h1 class="title">Virtuelt lotteri</h1>
|
<h1 class="title">Virtuelt lotteri</h1>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Vurder om du ønsker å bruke <router-link to="/generate" class="vin-link">loddgeneratoren</router-link>, eller sjekke ut <router-link to="/dagens" class="vin-link">dagens fangst.</router-link></li>
|
<li>
|
||||||
|
Vurder om du ønsker å bruke <router-link to="/generate" class="vin-link">loddgeneratoren</router-link>,
|
||||||
|
eller sjekke ut <router-link to="/dagens" class="vin-link">dagens fangst.</router-link>
|
||||||
|
</li>
|
||||||
<li>Send vipps med melding "Vinlotteri" for å bli registrert til lotteriet.</li>
|
<li>Send vipps med melding "Vinlotteri" for å bli registrert til lotteriet.</li>
|
||||||
<li>Send gjerne melding om fargeønske også.</li>
|
<li>Send gjerne melding om fargeønske også.</li>
|
||||||
</ol>
|
</ol>
|
||||||
@@ -16,17 +19,15 @@
|
|||||||
<VippsPill class="vipps-pill mobile-only" />
|
<VippsPill class="vipps-pill mobile-only" />
|
||||||
|
|
||||||
<p class="call-to-action">
|
<p class="call-to-action">
|
||||||
<span class="vin-link">Følg med på utviklingen</span> og <span class="vin-link">chat om trekningen</span>
|
<span class="vin-link" @click="scrollToContent">Følg med på utviklingen</span> og
|
||||||
<i class="icon icon--arrow-left" @click="scrollToContent"></i></p>
|
<span class="vin-link" @click="scrollToContent">chat om trekningen</span>
|
||||||
|
<i class="icon icon--arrow-left" @click="scrollToContent"></i>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="container" ref="content">
|
<div class="container" ref="content">
|
||||||
<WinnerDraw
|
<WinnerDraw :currentWinnerDrawn="currentWinnerDrawn" :currentWinner="currentWinner" :attendees="attendees" />
|
||||||
:currentWinnerDrawn="currentWinnerDrawn"
|
|
||||||
:currentWinner="currentWinner"
|
|
||||||
:attendees="attendees"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="todays-raffles">
|
<div class="todays-raffles">
|
||||||
<h2>Liste av lodd kjøpt i dag</h2>
|
<h2>Liste av lodd kjøpt i dag</h2>
|
||||||
@@ -51,15 +52,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container wines-container">
|
<div class="todays-wines">
|
||||||
<h2>Dagens fangst ({{ wines.length }})</h2>
|
<h2>Dagens fangst ({{ wines.length }})</h2>
|
||||||
|
<div class="wines-container">
|
||||||
<Wine :wine="wine" v-for="wine in wines" :key="wine" />
|
<Wine :wine="wine" v-for="wine in wines" :key="wine" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { attendees, winners, prelottery } from "@/api";
|
|
||||||
import Chat from "@/ui/Chat";
|
import Chat from "@/ui/Chat";
|
||||||
import Vipps from "@/ui/Vipps";
|
import Vipps from "@/ui/Vipps";
|
||||||
import VippsPill from "@/ui/VippsPill";
|
import VippsPill from "@/ui/VippsPill";
|
||||||
@@ -74,18 +76,18 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
attendees: [],
|
attendees: [],
|
||||||
|
attendeesFetched: false,
|
||||||
winners: [],
|
winners: [],
|
||||||
wines: [],
|
wines: [],
|
||||||
currentWinnerDrawn: false,
|
currentWinnerDrawn: false,
|
||||||
currentWinner: null,
|
currentWinner: null,
|
||||||
socket: null,
|
socket: null,
|
||||||
attendeesFetched: false,
|
|
||||||
wasDisconnected: false,
|
wasDisconnected: false,
|
||||||
ticketsBought: {
|
ticketsBought: {
|
||||||
"red": 0,
|
red: 0,
|
||||||
"blue": 0,
|
blue: 0,
|
||||||
"green": 0,
|
green: 0,
|
||||||
"yellow": 0
|
yellow: 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -129,42 +131,45 @@ export default {
|
|||||||
this.socket = null;
|
this.socket = null;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getWinners: async function() {
|
getWinners() {
|
||||||
let response = await winners();
|
fetch("/api/lottery/winners")
|
||||||
if (response) {
|
.then(resp => resp.json())
|
||||||
this.winners = response;
|
.then(response => (this.winners = response.winners));
|
||||||
}
|
|
||||||
},
|
},
|
||||||
getTodaysWines() {
|
getTodaysWines() {
|
||||||
prelottery()
|
fetch("/api/lottery/wines")
|
||||||
|
.then(resp => resp.json())
|
||||||
|
.then(response => response.wines)
|
||||||
.then(wines => {
|
.then(wines => {
|
||||||
this.wines = wines;
|
this.wines = wines;
|
||||||
this.todayExists = wines.length > 0;
|
this.todayExists = wines.length > 0;
|
||||||
})
|
})
|
||||||
.catch(_ => this.todayExists = false)
|
.catch(_ => (this.todayExists = false));
|
||||||
},
|
},
|
||||||
getAttendees: async function() {
|
getAttendees() {
|
||||||
let response = await attendees();
|
fetch("/api/lottery/attendees")
|
||||||
if (response) {
|
.then(resp => resp.json())
|
||||||
this.attendees = response;
|
.then(response => {
|
||||||
if (this.attendees == undefined || this.attendees.length == 0) {
|
const { attendees } = response;
|
||||||
this.attendeesFetched = true;
|
this.attendees = attendees || [];
|
||||||
|
|
||||||
|
if (attendees == undefined || attendees.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const addValueOfListObjectByKey = (list, key) =>
|
|
||||||
list.map(object => object[key]).reduce((a, b) => a + b);
|
const addValueOfListObjectByKey = (list, key) => list.map(object => object[key]).reduce((a, b) => a + b);
|
||||||
|
|
||||||
this.ticketsBought = {
|
this.ticketsBought = {
|
||||||
red: addValueOfListObjectByKey(response, "red"),
|
red: addValueOfListObjectByKey(attendees, "red"),
|
||||||
blue: addValueOfListObjectByKey(response, "blue"),
|
blue: addValueOfListObjectByKey(attendees, "blue"),
|
||||||
green: addValueOfListObjectByKey(response, "green"),
|
green: addValueOfListObjectByKey(attendees, "green"),
|
||||||
yellow: addValueOfListObjectByKey(response, "yellow")
|
yellow: addValueOfListObjectByKey(attendees, "yellow")
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
this.attendeesFetched = true;
|
.finally(_ => (this.attendeesFetched = true));
|
||||||
},
|
},
|
||||||
scrollToContent() {
|
scrollToContent() {
|
||||||
console.log(window.scrollY)
|
console.log(window.scrollY);
|
||||||
const intersectingHeaderHeight = this.$refs.header.getBoundingClientRect().bottom - 50;
|
const intersectingHeaderHeight = this.$refs.header.getBoundingClientRect().bottom - 50;
|
||||||
const { scrollY } = window;
|
const { scrollY } = window;
|
||||||
let scrollHeight = intersectingHeaderHeight;
|
let scrollHeight = intersectingHeaderHeight;
|
||||||
@@ -178,14 +183,13 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
track() {
|
track() {
|
||||||
window.ga('send', 'pageview', '/lottery/game');
|
window.ga("send", "pageview", "/lottery/game");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
@import "../styles/variables.scss";
|
@import "../styles/variables.scss";
|
||||||
@import "../styles/media-queries.scss";
|
@import "../styles/media-queries.scss";
|
||||||
|
|
||||||
@@ -201,7 +205,8 @@ export default {
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
|
||||||
> div, > section {
|
> div,
|
||||||
|
> section {
|
||||||
@include mobile {
|
@include mobile {
|
||||||
grid-column: span 5;
|
grid-column: span 5;
|
||||||
}
|
}
|
||||||
@@ -343,6 +348,8 @@ header {
|
|||||||
|
|
||||||
> div {
|
> div {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
max-height: 638px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
|
||||||
-webkit-box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.15);
|
-webkit-box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.15);
|
||||||
-moz-box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.15);
|
-moz-box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.15);
|
||||||
@@ -369,11 +376,14 @@ header {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.todays-wines {
|
||||||
|
width: 80vw;
|
||||||
|
padding: 0 10vw;
|
||||||
|
|
||||||
.wines-container {
|
@include mobile {
|
||||||
display: flex;
|
width: 90vw;
|
||||||
flex-wrap: wrap;
|
padding: 0 5vw;
|
||||||
margin-bottom: 4rem;
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
Reference in New Issue
Block a user