- Creazione di un Nuovo Catalogo (e la sua relativa pagina), a partire da un modello ed un catalogo esistente.
- Aggiunta dei bottoni sul Ccatalogocard
This commit is contained in:
@@ -7,10 +7,12 @@ import { useProducts } from '@store/Products';
|
||||
import { CCopyBtn } from '@src/components/CCopyBtn';
|
||||
import { CSingleCart } from '@src/components/CSingleCart';
|
||||
import { CTitleBanner } from '@src/components/CTitleBanner';
|
||||
import { tools } from '@store/Modules/tools';
|
||||
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import MixinUsers from '../../mixins/mixin-users';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyCart',
|
||||
@@ -21,9 +23,14 @@ export default defineComponent({
|
||||
const globalStore = useGlobalStore();
|
||||
const productStore = useProducts();
|
||||
const { t } = useI18n();
|
||||
const $q = useQuasar();
|
||||
|
||||
const { getnumItemsCart } = MixinUsers();
|
||||
|
||||
const codice_sconto = ref('')
|
||||
const descr_sconto = ref('')
|
||||
const caricamentodati = ref(false)
|
||||
|
||||
const myCart = computed(() => productStore.cart);
|
||||
const myTotalPrice = computed(() => {
|
||||
if (productStore.cart) {
|
||||
@@ -69,6 +76,43 @@ export default defineComponent({
|
||||
return productStore.getNumOrders() > 0;
|
||||
}
|
||||
|
||||
async function applicaSconto(codice: string) {
|
||||
try {
|
||||
caricamentodati.value = true;
|
||||
const rissconto = await productStore.ApplicaSconto({
|
||||
cart_id: myCart.value._id,
|
||||
codice_sconto: codice,
|
||||
});
|
||||
|
||||
if (rissconto) {
|
||||
if (rissconto.msg) {
|
||||
tools.showNeutralNotif($q, `${rissconto.msg}`);
|
||||
} else if (rissconto.valido && rissconto.mycart) {
|
||||
tools.showPositiveNotif($q, 'Sconto Applicato!');
|
||||
} else {
|
||||
tools.showNegativeNotif($q, `${rissconto.errmsg}`);
|
||||
}
|
||||
codice_sconto.value = '';
|
||||
descr_sconto.value = '';
|
||||
if (rissconto.mycart) {
|
||||
recOrderCart.value = rissconto.mycart
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('error ApplicaSconto', error);
|
||||
tools.showNegativeNotif($q, `Sconto Non Applicato! ${error.message}`);
|
||||
codice_sconto.value = '';
|
||||
descr_sconto.value = '';
|
||||
} finally {
|
||||
caricamentodati.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function confermaCodiceSconto() {
|
||||
await applicaSconto(codice_sconto.value);
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted);
|
||||
|
||||
return {
|
||||
@@ -82,6 +126,10 @@ export default defineComponent({
|
||||
existsOrders,
|
||||
globalStore,
|
||||
t,
|
||||
codice_sconto,
|
||||
confermaCodiceSconto,
|
||||
caricamentodati,
|
||||
descr_sconto,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -136,6 +136,15 @@
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="caricamentodati"
|
||||
class="overlay"
|
||||
>
|
||||
<q-spinner-hourglass
|
||||
color="primary"
|
||||
size="50px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user