- aggiornato carrello e bottoni sul catalogo
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import { ref, onMounted, onBeforeMount, PropType, reactive, watch } from 'vue'
|
||||
import { CCardState } from '../CCardState'
|
||||
import { ref, onMounted, onBeforeMount, PropType, reactive, watch } from 'vue';
|
||||
import { CCardState } from '../CCardState';
|
||||
|
||||
import { computed, defineComponent } from 'vue'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useProducts } from '@store/Products'
|
||||
import { CCopyBtn } from '@src/components/CCopyBtn'
|
||||
import { CSingleCart } from '@src/components/CSingleCart'
|
||||
import { CTitleBanner } from '@src/components/CTitleBanner'
|
||||
import { computed, defineComponent } from 'vue';
|
||||
import { useGlobalStore } from '@store/globalStore';
|
||||
import { useProducts } from '@store/Products';
|
||||
import { CCopyBtn } from '@src/components/CCopyBtn';
|
||||
import { CSingleCart } from '@src/components/CSingleCart';
|
||||
import { CTitleBanner } from '@src/components/CTitleBanner';
|
||||
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import MixinUsers from '../../mixins/mixin-users'
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import MixinUsers from '../../mixins/mixin-users';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyCart',
|
||||
@@ -19,55 +18,63 @@ export default defineComponent({
|
||||
components: { CTitleBanner, CCardState, CCopyBtn, CSingleCart },
|
||||
|
||||
setup() {
|
||||
const globalStore = useGlobalStore()
|
||||
const products = useProducts()
|
||||
const { t } = useI18n()
|
||||
const globalStore = useGlobalStore();
|
||||
const productStore = useProducts();
|
||||
const { t } = useI18n();
|
||||
|
||||
const { getnumItemsCart } = MixinUsers()
|
||||
const { getnumItemsCart } = MixinUsers();
|
||||
|
||||
const myCart = computed(() => products.cart)
|
||||
const myCart = computed(() => productStore.cart);
|
||||
const myTotalPrice = computed(() => {
|
||||
if (products.cart) {
|
||||
return products.cart.totalPrice
|
||||
if (productStore.cart) {
|
||||
return productStore.cart.totalPrice.toFixed(2);
|
||||
} else {
|
||||
return 0
|
||||
return 0;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const totalPriceIntero = computed((): string => {
|
||||
if (productStore.cart && productStore.cart.totalPriceIntero) {
|
||||
return productStore.cart.totalPriceIntero.toFixed(2);
|
||||
} else {
|
||||
return '0';
|
||||
}
|
||||
});
|
||||
|
||||
const ordersCart = computed(() => {
|
||||
if (!!products.cart) {
|
||||
return products.cart.items
|
||||
if (!!productStore.cart) {
|
||||
return productStore.cart.items;
|
||||
} else {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const numOrders = computed(() => {
|
||||
if (!!products.cart && products.cart.items) {
|
||||
return products.cart.items.length
|
||||
if (!!productStore.cart && productStore.cart.items) {
|
||||
return productStore.cart.items.length;
|
||||
} else {
|
||||
return 0
|
||||
return 0;
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
function closecart() {
|
||||
globalStore.rightCartOpen = false
|
||||
globalStore.rightCartOpen = false;
|
||||
}
|
||||
|
||||
function mounted() {
|
||||
products.loadOrders()
|
||||
productStore.loadOrders();
|
||||
}
|
||||
|
||||
function existsOrders() {
|
||||
return products.getNumOrders() > 0
|
||||
return productStore.getNumOrders() > 0;
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
onMounted(mounted);
|
||||
|
||||
return {
|
||||
myCart,
|
||||
myTotalPrice,
|
||||
totalPriceIntero,
|
||||
ordersCart,
|
||||
numOrders,
|
||||
closecart,
|
||||
@@ -75,6 +82,6 @@ export default defineComponent({
|
||||
existsOrders,
|
||||
globalStore,
|
||||
t,
|
||||
}
|
||||
};
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user