From 0403f9bd525ab776332d7330515fe65d649994be Mon Sep 17 00:00:00 2001 From: Jonathan Chevalier Date: Thu, 10 Nov 2022 14:58:01 +0100 Subject: [PATCH] WIP MMCM --- src/views/address-check.vue | 77 +++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/src/views/address-check.vue b/src/views/address-check.vue index ba5a576..5b12c63 100644 --- a/src/views/address-check.vue +++ b/src/views/address-check.vue @@ -2,6 +2,13 @@
Indiquez votre adresse de livraison :
+ +
@@ -10,8 +17,8 @@ - @@ -23,12 +30,35 @@ - @@ -57,9 +87,20 @@ export default { searchResults: [], isSearching: false, isChecking: false, + addressBook: [], + isConnected: null, + currentBtSearch : null } }, methods: { + useAddressBook(address,i) { + this.currentBtSearch = 'addressBook'+i + + this.store.setStreet(address.street) + this.store.setZipCode(address.zip_code) + this.store.setCity(address.city) + this.checkIdAddressIsEligible() + }, updateSearchResult: async function () { this.store.setStreet(null) @@ -84,7 +125,7 @@ export default { this.store.setZipCode(item.properties.postcode) this.store.setCity(item.properties.city) }, - checkIdAddressIsEligible: async function () { + checkIdAddressIsEligible: async function (e) { this.isChecking = true const urlApi = '/php/api/v3/mmcm.php?EXEC=getEligibility&street=' + encodeURI(this.store.street) @@ -111,6 +152,28 @@ export default { } + }, + async mounted() { + let urlApi = '/php/api/v3/mmcm.php?EXEC=getAccountAddress' + + if (import.meta.env.DEV) { + urlApi += '&ID_SESSION=wqG6cX5g'; + console.log(urlApi) + } + + let apiResult = await fetch(urlApi) + .then(response => { + if (response.ok) { + return response.json(); + } + }) + + this.isConnected = apiResult.connected + + if (apiResult.connected && apiResult.nb > 0) { + this.addressBook = apiResult.list + } + } }