This commit is contained in:
Jonathan Chevalier
2022-09-22 18:45:13 +02:00
parent 9a7bcf49fb
commit 6c05551126
13 changed files with 2467 additions and 91 deletions

View File

@@ -0,0 +1,70 @@
<template>
<h1 class="product_name_area primary_color">Indiquez votre adresse de livraison (domicile, travail...) :</h1>
<div class="input-group mb-3">
<input type="text" placeholder="Exemple : 2 rue de la Libération 78120 Rambouillet" class="form-control"
v-model="query"
@input="updateSearchResult" aria-describedby="button-addon">
<button class="btn btn-outline-secondary" type="button" id="button-addon" @click="checkIdAddressIsEligible">
Valider
</button>
</div>
<ul class="list-group">
<li class="list-group-item text-start" v-for="(item, index) in searchResults" :key="index"
@click="selectChoice(item)">
{{ item.properties.label }}
</li>
</ul>
</template>
<script>
export default {
name: "address-check",
data() {
return {
query: "",
selectedChoice: {},
searchResults: []
}
},
methods: {
updateSearchResult: async function () {
this.searchResults = await fetch('https://api-adresse.data.gouv.fr/search/?q=' + this.query)
.then(function (response) {
return response.json();
}).then(function (jsonObj) {
return jsonObj.features;
});
},
selectChoice(item) {
this.searchResults = []
this.query = item.properties.label
this.selectedChoice = item;
},
checkIdAddressIsEligible: async function () {
await fetch('/php/api/v3/?NUMC=ZIWR5659&controller=MMCMController&street=' + encodeURI(this.selectedChoice.properties.name)
+ '&zip_code=' + encodeURI(this.selectedChoice.properties.postcode)
+ '&city=' + encodeURI(this.selectedChoice.properties.city)
)
.then(function (response) {
return response.json();
}).then(function (jsonObj) {
console.log(jsonObj)
return jsonObj;
});
}
}
}
</script>
<style scoped>
.list-group li:hover {
background-color: #d7fdc0;
cursor: pointer;
}
</style>

27
src/views/index.vue Normal file
View File

@@ -0,0 +1,27 @@
<template>
<h1 class="product_name_area primary_color">
Vous ne pouvez pas vous déplacer à votre pharmacie habituelle ?
Faites livrer vos médicaments à votre domicile !
</h1>
<div class="mb-3">
Livraison par La Poste en express en moins de 2 heures par coursier <br />
ou le surlendemain par facteur dans les zones éligibles.
</div>
<router-link to="/address-check" class="btn btn-primary">
Je me fais livrer
</router-link>
</template>
<script>
export default {
name: "Index"
}
</script>
<style scoped>
</style>