- Cataloghi: BestSeller, Novità
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user