This commit is contained in:
Jonathan Chevalier
2022-09-29 17:11:17 +02:00
parent efa0296c1d
commit c219e317b1
4 changed files with 51 additions and 13 deletions

View File

@@ -3,7 +3,8 @@
<li v-for="step in stepList" :class="(step.stepNumber<currentStep) ? 'complete' : ''"> <li v-for="step in stepList" :class="(step.stepNumber<currentStep) ? 'complete' : ''">
<router-link :to="step.path"> <router-link :to="step.path">
<div class="step"><i :class="step.class"></i></div> <div class="step"><i :class="step.class"></i></div>
<div class="caption d-none d-sm-block">Etape <span>{{step.stepNumber}}</span>: <span>{{ step.name }}</span></div> <div class="caption d-none d-sm-block">Etape <span>{{ step.stepNumber }}</span>: <span>{{ step.name }}</span>
</div>
</router-link> </router-link>
</li> </li>
</ol> </ol>
@@ -53,7 +54,7 @@ export default {
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const currentStep = computed(() => stepList.filter(step=>step.path === route.path)[0].stepNumber) const currentStep = computed(() => stepList.filter(step => step.path === route.path).length > 0 ? stepList.filter(step => step.path === route.path)[0].stepNumber : 6)
return { return {
stepList, stepList,

View File

@@ -33,6 +33,11 @@ const routes = [
name: 'delivery-option-summary', name: 'delivery-option-summary',
component: () => import('/src/views/delivery-option-summary.vue'), component: () => import('/src/views/delivery-option-summary.vue'),
}, },
{
path: '/final-step',
name: 'final-step',
component: () => import('/src/views/final-step.vue'),
},
] ]
const router = createRouter({ const router = createRouter({

View File

@@ -8,33 +8,43 @@
<span v-else>Non</span> <span v-else>Non</span>
</div> </div>
<div class="mb-2"><strong>Date de livraison des medicaments : </strong>{{ store.dateDeliveryString }}</div> <div class="mb-2"><strong>Date de livraison des medicaments : </strong>{{ store.dateDeliveryString }}</div>
<button class="btn btn-primary" @click="addToCart"><i class="fa-regular fa-circle-check fa-fw"></i> Ajouter au panier</button> <button class="btn btn-primary" @click="addToCart">
<i v-if="suspens" class="fa-solid fa-circle-notch fa-spin fa-fw"></i>
<i v-else class="fa-regular fa-circle-check fa-fw"></i>
Ajouter au panier
</button>
</div> </div>
</template> </template>
<script> <script>
import {useMMCMStore} from '../stores/mmcm.js' import {useMMCMStore} from '../stores/mmcm.js'
import {ref} from "vue";
export default { export default {
setup() { setup() {
const suspens = ref(false)
const store = useMMCMStore() const store = useMMCMStore()
return { return {
suspens,
store store
} }
}, },
name: "delivery-option-summary", name: "delivery-option-summary",
methods: { methods: {
addToCart: async function (idProduct) { addToCart: async function (idProduct) {
this.suspens = true
const urlApi = '/php/api/v3/mmcm.php?EXEC=addToCart&ID_PRODUCT=' + this.store.idProduct const urlApi = '/php/api/v3/mmcm.php?EXEC=addToCart&ID_PRODUCT=' + this.store.idProduct
+ '&with_prescription=' + this.store.widthPrescription + '&with_prescription=' + this.store.widthPrescription
+ '&date_delivery=' + this.store.dateDelivery + '&date_delivery=' + this.store.dateDelivery
; ;
const result = await fetch(urlApi) const result = await fetch(urlApi)
.then(response => { .then(response => {
if (response.ok) { if (response.ok) {
this.suspens = false
this.$router.push({path : '/final-step'})
return response.json(); return response.json();
} }
}) })

22
src/views/final-step.vue Normal file
View File

@@ -0,0 +1,22 @@
<template>
<h2 class="mb-4">Votre ordonnance livré à domicile a été ajoutée au panier</h2>
<button class="btn btn-secondary me-4" @click="exitVueApp('/')">Continuer mes achats</button>
<button class="btn btn-primary" @click="exitVueApp('/cart/p/AFF_COMM/0/0/')">Finaliser ma commande</button>
</template>
<script>
export default {
name: "final-step",
methods: {
exitVueApp(url) {
window.location = 'https://para-php7-dev.parapharmacie-et-medicament.com' + url
}
}
}
</script>
<style scoped>
</style>