92 lines
2.5 KiB
JavaScript
Vendored
92 lines
2.5 KiB
JavaScript
Vendored
import Axios from 'axios';
|
|
import Vue from 'vue';
|
|
import Vuex from 'vuex';
|
|
import VueContentPlaceholders from 'vue-content-placeholders';
|
|
import '../../../../../node_modules/@fortawesome/fontawesome-free/js/all.min.js';
|
|
import { LdcwebCn } from "./vendor/ldcweb-cookies.js";
|
|
import './utilities/bootstrap';
|
|
import './utilities/swiper';
|
|
import './utilities/simplebar';
|
|
import './fo/common';
|
|
|
|
// Ldcweb cookies
|
|
window.LdcwebCn = LdcwebCn;
|
|
|
|
Vue.use(VueContentPlaceholders)
|
|
Vue.component('filter-component', require('./components/FilterComponent.vue').default);
|
|
|
|
Vue.use(Vuex);
|
|
Vue.component('timeslot-picker', require('./components/TimeSlotPicker.vue').default);
|
|
Vue.component('basket-panel', require('./components/BasketPanel.vue').default);
|
|
Vue.component('basket-counter', {
|
|
computed: {
|
|
count() {
|
|
return this.$store.state.cartTotals.countItems;
|
|
}
|
|
},
|
|
template: '<span class="header-actions__item-icon icon icon_cart"><span class="icon__count">{{ count }}</span></span>'
|
|
});
|
|
Vue.component('basket-amount', {
|
|
computed: {
|
|
amount() {
|
|
return this.currencyFormatter(this.$store.state.cartTotals.totalTTC);
|
|
}
|
|
},
|
|
methods: {
|
|
currencyFormatter(num) {
|
|
if (isNaN(num)) {
|
|
return num;
|
|
}
|
|
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(num);
|
|
}
|
|
},
|
|
template: '<span>{{ amount }}</span>'
|
|
});
|
|
Vue.component('basket-buttons', require('./components/BasketButtons.vue').default);
|
|
|
|
const store = new Vuex.Store({
|
|
state: {
|
|
panier: {},
|
|
cartTotals: {},
|
|
},
|
|
mutations: {
|
|
Reload (state,payload) {
|
|
state.reload = payload.reload;
|
|
},
|
|
updatePanier (state, payload) {
|
|
state.panier = payload.panier;
|
|
},
|
|
updateCartTotals (state, payload) {
|
|
state.cartTotals = payload.cartTotals;
|
|
},
|
|
}
|
|
});
|
|
|
|
const metaCSRFToken = document.querySelector(
|
|
"meta[name='csrf-token']"
|
|
)
|
|
|
|
if (!metaCSRFToken) {
|
|
throw new Error("Missing meta CSRF token");
|
|
}
|
|
|
|
Axios.defaults.headers.common = {
|
|
Accept: "application/json, text/plain, */*",
|
|
"X-Requested-With": "XMLHttpRequest",
|
|
"X-CSRF-TOKEN": metaCSRFToken.getAttribute("content"),
|
|
};
|
|
|
|
window.axios = Axios;
|
|
|
|
const app = new Vue({
|
|
el: '#app',
|
|
store,
|
|
data: {
|
|
num: 1 //for the numeric stepper on product pages
|
|
},
|
|
methods: {
|
|
addtocart(product,qtty) {
|
|
this.$refs.basketpanel.addtocart(product,qtty);
|
|
},
|
|
},
|
|
});
|