- Cataloghi: BestSeller, Novità

This commit is contained in:
Surya Paolo
2024-11-28 16:04:48 +01:00
parent e10ff192bf
commit 6932590f3e
30 changed files with 1086 additions and 456 deletions

View File

@@ -74,7 +74,7 @@ export default defineComponent({
type: Object as PropType<IMyScheda>,
required: false,
default: () => ({
}),
},
},
@@ -160,7 +160,7 @@ export default defineComponent({
if (myproduct.value) {
const ris = await products.addtoCartBase({ $q, t, id: myproduct.value._id, order: myorder, addqty: add })
updateproduct()
updateproduct(false)
if (ris && ris.myord) {
}
@@ -217,10 +217,22 @@ export default defineComponent({
}
async function updateproduct() {
async function updateproduct(atload: boolean) {
myproduct.value = null;
myproduct.value = await products.getProductById(props.id)
let carica = true
if (atload) {
if (props.product) {
myproduct.value = props.product
carica = false
}
} else {
}
if (carica) {
myproduct.value = null;
myproduct.value = await products.getProductById(props.id)
}
// products.updateQuantityAvailable(myproduct.value._id)
}
@@ -325,7 +337,7 @@ export default defineComponent({
updateTimerLabel()
}
async function mounted() {
async function mounted() {
await load()
// Start the timer when the component is mounted
@@ -360,7 +372,7 @@ export default defineComponent({
async function load() {
indvariazSel.value = -1
initproduct()
await updateproduct()
await updateproduct(true)
labelDataArrivoMerce.value = ''
labelDataRitiro.value = ''
@@ -512,6 +524,31 @@ export default defineComponent({
return !escludiArticolo(variazione)
}
function isProductNovita() {
const monthsAgo = props.scheda.etichette?.novita?.months ?? 6; // Numero di mesi da considerare "recenti"
const publishingDate = new Date(myproduct.value!.productInfo.date_publishing!);
// Calcola i millisecondi corrispondenti a X mesi fa
const monthsInMilliseconds = monthsAgo * 30 * 24 * 60 * 60 * 1000; // Approssimazione, non tutti i mesi hanno 30 giorni
// Crea una data che rappresenta X mesi fa
const monthsAgoDate = new Date(tools.getTimeNow() - monthsInMilliseconds);
// Confronta la data di pubblicazione con la data X mesi fa
return publishingDate > monthsAgoDate;
}
function isProductBestseller() {
try {
//return myproduct.value!.productInfo.rank1Y! > 0 && (myproduct.value!.productInfo.rank1Y! < props.scheda.etichette?.bestseller?.primiNInClassifica!)
return myproduct.value!.indiceRanking! > 0 && (myproduct.value!.indiceRanking! < props.scheda.etichette?.bestseller?.primiNInClassifica!)
} catch (e) {
return false
}
}
onMounted(mounted)
onBeforeUnmount(beforeDestroy)
@@ -568,6 +605,8 @@ export default defineComponent({
click_author,
click_opendetail,
checkIfVariazioneDaVisu,
isProductNovita,
isProductBestseller,
}
}
})

View File

@@ -76,13 +76,15 @@
'flex', // Classi comuni
'image-container',
{ 'shadow-2': options.in_3d }, // Classe condizionale
scheda.posiz_text === costanti.POSIZ_TESTO.IN_BASSO
scheda.testo_right.font?.posiz_text ===
costanti.POSIZ_TESTO.IN_BASSO
? 'flex-col'
: 'flex-row', // Layout flessibile
]"
:style="{
justifyContent:
scheda.posiz_text === costanti.POSIZ_TESTO.IN_BASSO
scheda.testo_right.font?.posiz_text ===
costanti.POSIZ_TESTO.IN_BASSO
? 'center'
: 'flex-start',
alignItems: 'stretch', // Cambiato in 'stretch' per occupare l'altezza
@@ -113,6 +115,7 @@
: myproduct.productInfo.image_link
"
:alt="myproduct.productInfo.name"
:fit="scheda.dimensioni?.immagine_prodotto?.size?.fit ?? 'cover'"
:class="{
'book-image-fixed': complete,
'cursor-pointer': !complete,
@@ -120,10 +123,11 @@
'image-wrapper': optcatalogo.pdf,
}"
:style="{
zIndex: 9000,
zIndex: 2,
width:
scheda.posiz_text === costanti.POSIZ_TESTO.IN_BASSO
? '50%'
scheda.testo_right.font?.posiz_text ===
costanti.POSIZ_TESTO.IN_BASSO
? scheda.testo_right.font?.perc_text ?? '50%'
: '45%',
...(tools.adjustSize(
optcatalogo,
@@ -135,6 +139,12 @@
scheda.dimensioni?.immagine_prodotto.size?.width
) + ' !important',
}),
height: scheda.dimensioni?.immagine_prodotto?.size?.height
? tools.adjustSize(
optcatalogo,
scheda.dimensioni?.immagine_prodotto?.size?.height
)
: undefined,
display: 'block',
}"
@click="click_opendetail()"
@@ -143,12 +153,14 @@
<div
:style="{
width:
scheda.posiz_text === costanti.POSIZ_TESTO.IN_BASSO
scheda.testo_right.font?.posiz_text ===
costanti.POSIZ_TESTO.IN_BASSO
? '100%'
: '50%',
: scheda.testo_right.font?.perc_text ?? '50%',
textAlign: 'center',
marginTop:
scheda.posiz_text === costanti.POSIZ_TESTO.IN_BASSO
scheda.testo_right.font?.posiz_text ===
costanti.POSIZ_TESTO.IN_BASSO
? '0.5rem'
: '0',
}"
@@ -157,7 +169,7 @@
v-if="scheda.testo_right && scheda.testo_right"
:style="{
'--scalecatalog': optcatalogo.areadistampa.scale,
'line-height': scheda.line_height,
'line-height': scheda.testo_right.font?.line_height,
height: '100%',
display: 'flex',
flexDirection: 'column',
@@ -171,22 +183,50 @@
scheda.testo_right
)
"
style="display: flex; flex-direction: column; justify-content: space-between; height: 100%;"
style="
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
"
></div>
<div v-if="scheda.barcode && scheda.barcode.show">
<CBarCode
:value="myproduct.productInfo.code"
:format="scheda.barcode.format"
:fontsize="scheda.barcode.font?.size"
:width="
parseInt(
tools.adjustSize(optcatalogo, scheda.barcode.size?.width)
)
"
:widthlines="scheda.barcode.widthlines"
:height="scheda.barcode.size?.height"
>
</CBarCode>
<div class="row justify-center">
<div v-if="scheda.barcode && scheda.barcode.show">
<CBarCode
:value="myproduct.productInfo.code"
:format="scheda.barcode.format"
:fontsize="scheda.barcode.font?.size"
:width="
parseInt(
tools.adjustSize(
optcatalogo,
scheda.barcode.size?.width
)
)
"
:widthlines="scheda.barcode.widthlines"
:height="scheda.barcode.size?.height"
>
</CBarCode>
</div>
<div v-if="scheda.etichette?.bestseller?.show && isProductBestseller()">
<q-img
src="images/bestseller.png"
alt="Bestseller"
width="40px"
height="40px"
fit="contain"
></q-img>
</div>
<div v-else-if="scheda.etichette?.novita?.show && isProductNovita()">
<q-img
src="images/novita.png"
alt="Novita"
width="40px"
height="40px"
fit="contain"
></q-img>
</div>
</div>
</div>
</div>
@@ -200,28 +240,7 @@
<div
:style="{
'--scalecatalog': optcatalogo.areadistampa.scale,
'line-height': scheda.line_height,
}"
v-html="
products.replaceKeyWordsByProduct(
optcatalogo,
myproduct,
scheda.testo_bottom
)
"
></div>
</div>
<div
v-if="scheda.testo_bottom && scheda.testo_bottom.contenuto"
:style="{
width: '100%',
textAlign: 'center',
}"
>
<div
:style="{
'--scalecatalog': optcatalogo.areadistampa.scale,
'line-height': scheda.line_height,
'line-height': scheda.testo_bottom.font?.line_height,
}"
v-html="
products.replaceKeyWordsByProduct(