WIP MMCM
This commit is contained in:
@@ -18,12 +18,22 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {useMMCMStore} from '../stores/mmcm.js'
|
||||
import {storeToRefs} from 'pinia'
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const store = useMMCMStore()
|
||||
|
||||
return {
|
||||
// you can return the whole store instance to use it in the template
|
||||
store,
|
||||
}
|
||||
},
|
||||
name: "address-check",
|
||||
data() {
|
||||
return {
|
||||
query: "",
|
||||
selectedChoice: {},
|
||||
searchResults: []
|
||||
}
|
||||
},
|
||||
@@ -39,22 +49,27 @@ export default {
|
||||
selectChoice(item) {
|
||||
this.searchResults = []
|
||||
this.query = item.properties.label
|
||||
this.selectedChoice = item;
|
||||
this.store.setStreet(item.properties.name)
|
||||
this.store.setZipCode(item.properties.postcode)
|
||||
this.store.setCity(item.properties.city)
|
||||
|
||||
},
|
||||
checkIdAddressIsEligible: async function () {
|
||||
|
||||
const urlApi = '/php/api/v3/mmcm.php?street=' + encodeURI(this.store.street)
|
||||
+ '&zip_code=' + this.store.zipCode
|
||||
+ '&city=' + this.store.city
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
let productList = await fetch(urlApi)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
})
|
||||
|
||||
this.store.setProductList(productList);
|
||||
this.$router.push({path: '/delivery-option'});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user