Added functionality to start a Cache and view first station

This commit is contained in:
Katharina Will 2019-04-23 15:53:13 +02:00
parent bfe303f277
commit fe3070204d
2 changed files with 26 additions and 8 deletions

View File

@ -11,7 +11,7 @@
<div class="column q-gutter-y-md">
<q-input stack-label filled v-model="code" label="Code eingeben (wird mit Code scannen ersetzt)"/>
<q-btn unelevated color="primary" label="QR-Code scannen (absenden)"/>
<q-btn @click="checkStation()" unelevated color="primary" label="QR-Code scannen (absenden)"/>
</div>
</div>
</div>
@ -27,6 +27,9 @@
instruction: "Bitte begib Dich zu der auf der Karte angezeigten Position. An dieser Position wirst Du einen QR-Code finden. Wenn du ihn gefunden hast, drücke den Knopf zum Starten des QR-Scanners und gib uns die Berechtigung, Deine Kamera zu öffnen. Nachdem Du den QR-Code gescannt hast, erhältst du ein Rätsel zur Position der nächsten Station. Die Lösung zu dem Rätsel ist also das Versteck des nächsten QR-Codes."
}
},
created() {
this.fetchData();
},
methods: {
fetchData() {
this.$axios.get('/api/allCaches')
@ -41,16 +44,31 @@
})
},
checkStation() {
let params = {};
params.token ;
params.cacheID;
params.stationID;
params.durchgefuehrterCacheID;
let params = this.setParams();
console.log(params);
this.$axios.get('/api/checkStation', {params})
.then((response) => {
console.log(response);
console.log("Anfrage erfolgreich");
}) .catch((error) => {
console.log(error);
console.log("Anfrage fehlgeschlagen");
})
}
this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`})
},
setParams() {
console.log("setParams: ");
let params = {};
params.cacheID = this.code.split('/')[0];
params.stationID = this.code.split('/')[1];
params.durchgefuehrterCacheID = this.cacheID;
console.log(params.cacheID + " und " + params.stationID);
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
}
return params;
},
}
}
</script>

View File

@ -188,7 +188,7 @@
let stationID = this.caches.find(x => x.id === cacheID).stationen[0].id;
console.log(stationID);
//this.$router.push({path: `/station/${stationID}`})
this.$router.push({path: `/station/${cacheID}/${stationID}`})
this.$router.push({path: `/CacheStart/${cacheID}`})
}).catch((error) => {
// Error
let msg;