aggiornamento product
This commit is contained in:
@@ -39,8 +39,8 @@ export default defineComponent({
|
||||
})
|
||||
|
||||
const numOrders = computed(() => {
|
||||
if (!!products.cart) {
|
||||
return products.cart.items!.length
|
||||
if (!!products.cart && products.cart.items) {
|
||||
return products.cart.items.length
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</div>
|
||||
<div v-else style="text-align: center">
|
||||
<q-btn
|
||||
rounded icon="fas fa-shopping-cart" color="green" label="Vai alla Cassa" class="q-mb-sm" to="/checkout"
|
||||
rounded icon="fas fa-shopping-cart" color="green" :label="$t('ecomm.btn_cassa')" class="q-mb-sm" to="/checkout"
|
||||
@click="closecart"></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { defineComponent, ref, toRef, computed, PropType, watch } from 'vue'
|
||||
import { defineComponent, ref, toRef, computed, PropType, watch, onMounted } from 'vue'
|
||||
import { useI18n } from '@src/boot/i18n'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
@@ -42,7 +42,7 @@ export default defineComponent({
|
||||
|
||||
const myorder = ref(<IOrder>{
|
||||
idapp: process.env.APP_ID,
|
||||
quantity: 1,
|
||||
quantity: 0,
|
||||
idStorehouse: ''
|
||||
})
|
||||
|
||||
@@ -50,6 +50,12 @@ export default defineComponent({
|
||||
|
||||
const storeSelected = ref('')
|
||||
|
||||
const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean) => {
|
||||
// console.log('valoriopt', item.table)
|
||||
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter)
|
||||
})
|
||||
|
||||
|
||||
function iconWhishlist(order: IProduct) {
|
||||
if (true) {
|
||||
return 'far fa-heart'
|
||||
@@ -98,105 +104,111 @@ export default defineComponent({
|
||||
else
|
||||
tools.showPositiveNotif($q, msg)
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function getnumstore() {
|
||||
if (myproduct.value.storehouses)
|
||||
return myproduct.value.storehouses.length
|
||||
else
|
||||
return 0
|
||||
}
|
||||
function getnumstore() {
|
||||
if (myproduct.value.storehouses)
|
||||
return myproduct.value.storehouses.length
|
||||
else
|
||||
return 0
|
||||
}
|
||||
|
||||
function getSingleStorehouse() {
|
||||
const mystore = myproduct.value.storehouses[0]
|
||||
if (mystore)
|
||||
return mystore.name + ' (' + mystore.city + ')'
|
||||
else
|
||||
return ''
|
||||
}
|
||||
function getSingleStorehouse() {
|
||||
const mystore = myproduct.value.storehouses[0]
|
||||
if (mystore)
|
||||
return mystore.name + ' (' + mystore.city + ')'
|
||||
else
|
||||
return ''
|
||||
}
|
||||
|
||||
function getStorehouses() {
|
||||
function getStorehouses() {
|
||||
|
||||
const myarr: any = []
|
||||
let ind = 1
|
||||
myproduct.value.storehouses.forEach((store) => {
|
||||
myarr.push(
|
||||
{
|
||||
id: ind,
|
||||
label: store.name + ' (' + store.city + ')',
|
||||
value: store._id
|
||||
const myarr: any = []
|
||||
let ind = 1
|
||||
myproduct.value.storehouses.forEach((store) => {
|
||||
myarr.push(
|
||||
{
|
||||
id: ind,
|
||||
label: store.name + ' (' + store.city + ')',
|
||||
value: store._id
|
||||
})
|
||||
|
||||
ind++
|
||||
})
|
||||
|
||||
ind++
|
||||
})
|
||||
// console.log('arraystore', myarr)
|
||||
return myarr
|
||||
}
|
||||
|
||||
// console.log('arraystore', myarr)
|
||||
return myarr
|
||||
}
|
||||
function checkifCartDisable() {
|
||||
return !myorder.value.idStorehouse
|
||||
}
|
||||
|
||||
function checkifCartDisable() {
|
||||
return !myorder.value.idStorehouse
|
||||
}
|
||||
watch(() => props.code, (newval, oldval) => {
|
||||
console.log('change code')
|
||||
load()
|
||||
})
|
||||
|
||||
watch(() => props.code, (newval, oldval) => {
|
||||
console.log('change code')
|
||||
load()
|
||||
})
|
||||
watch(() => storeSelected.value, (newval, oldval) => {
|
||||
myorder.value.idStorehouse = newval
|
||||
})
|
||||
|
||||
watch(() => storeSelected.value, (newval, oldval) => {
|
||||
myorder.value.idStorehouse = newval
|
||||
})
|
||||
async function load() {
|
||||
// console.log('created Cproductcard', code)
|
||||
if (props.code) {
|
||||
myproduct.value = await products.loadProduct({ code: props.code })
|
||||
} else {
|
||||
// @ts-ignore
|
||||
myproduct.value = props.product
|
||||
}
|
||||
|
||||
async function load() {
|
||||
// console.log('created Cproductcard', code)
|
||||
if (props.code) {
|
||||
myproduct.value = await products.loadProduct({ code: props.code })
|
||||
} else {
|
||||
// @ts-ignore
|
||||
myproduct.value = props.product
|
||||
}
|
||||
console.log('myproduct', myproduct, 'product', props.product)
|
||||
|
||||
console.log('myproduct', myproduct, 'product', props.product)
|
||||
if (!!myproduct.value) {
|
||||
if (myproduct.value.storehouses.length === 1) {
|
||||
myorder.value.idStorehouse = myproduct.value.storehouses[0]._id
|
||||
}
|
||||
}
|
||||
|
||||
if (!!myproduct.value) {
|
||||
if (myproduct.value.storehouses.length === 1) {
|
||||
myorder.value.idStorehouse = myproduct.value.storehouses[0]._id
|
||||
const ord = products.getOrderProductInCart(myproduct.value._id)
|
||||
if (ord) {
|
||||
myorder.value.quantity = ord.quantity
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getmycardcl() {
|
||||
return (props.complete) ? 'my-card-big' : 'my-card'
|
||||
}
|
||||
|
||||
function getclimg() {
|
||||
return (props.complete) ? 'myimgtitle centermydiv' : 'centermydiv'
|
||||
}
|
||||
|
||||
function enableSubQty() {
|
||||
return myorder.value ? myorder.value.quantity > 0 : true
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
|
||||
return {
|
||||
decqty,
|
||||
addqty,
|
||||
addtoCart,
|
||||
iconWhishlist,
|
||||
getmycardcl,
|
||||
getclimg,
|
||||
getnumstore,
|
||||
getSingleStorehouse,
|
||||
getStorehouses,
|
||||
checkifCartDisable,
|
||||
myproduct,
|
||||
myorder,
|
||||
tools,
|
||||
t,
|
||||
storeSelected,
|
||||
enableSubQty,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getmycardcl() {
|
||||
return (props.complete) ? 'my-card-big' : 'my-card'
|
||||
}
|
||||
|
||||
function getclimg() {
|
||||
return (props.complete) ? 'myimgtitle centermydiv' : 'centermydiv'
|
||||
}
|
||||
|
||||
function enableSubQty() {
|
||||
return myorder.value ? myorder.value.quantity > 0 : true
|
||||
}
|
||||
|
||||
load()
|
||||
|
||||
return {
|
||||
decqty,
|
||||
addqty,
|
||||
addtoCart,
|
||||
iconWhishlist,
|
||||
getmycardcl,
|
||||
getclimg,
|
||||
getnumstore,
|
||||
getSingleStorehouse,
|
||||
getStorehouses,
|
||||
checkifCartDisable,
|
||||
myproduct,
|
||||
myorder,
|
||||
tools,
|
||||
t,
|
||||
storeSelected,
|
||||
enableSubQty,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<template>
|
||||
<q-card :class="getmycardcl()" v-if="!!myproduct">
|
||||
<div v-if="myorder">myorder: {{ myorder }}</div>
|
||||
|
||||
<q-img
|
||||
:src="`` + myproduct.img"
|
||||
:alt="myproduct.name"
|
||||
@@ -87,7 +85,7 @@
|
||||
|
||||
<q-btn
|
||||
icon="fas fa-cart-arrow-down"
|
||||
:color="enableSubQty() ? 'negative': 'grey'"
|
||||
:color="enableSubQty() ? 'negative' : 'grey'"
|
||||
:disable="checkifCartDisable() || !enableSubQty()"
|
||||
rounded
|
||||
size="md"
|
||||
@@ -153,6 +151,15 @@
|
||||
<q-separator />
|
||||
|
||||
<q-card-actions vertical align="center">
|
||||
<q-btn
|
||||
v-if="myorder.quantity > 0"
|
||||
rounded
|
||||
icon="fas fa-shopping-cart"
|
||||
color="green"
|
||||
:label="$t('ecomm.btn_cassa')"
|
||||
class="q-mb-sm"
|
||||
to="/checkout"
|
||||
></q-btn>
|
||||
<!--
|
||||
<q-btn :icon="iconWhishlist(myproduct)" flat color="primary" rounded label="Lista Desideri">
|
||||
</q-btn>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</CVerifyTelegram>
|
||||
-->
|
||||
|
||||
<div v-if="tools.isLogged() && site.confpages.enableRegMultiChoice">
|
||||
<div v-if="tools.isLogged() && (site.confpages.enableRegMultiChoice || (!site.confpages.enabledRegNeedTelegram))">
|
||||
<CVerifyEmail v-if="!tools.isEmailVerified() && !tools.TelegVerificato()">
|
||||
</CVerifyEmail>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user