This commit is contained in:
Jaume Solís 2023-12-19 11:51:23 +01:00
parent 7f0a6290da
commit 4c4e04a182
2 changed files with 36 additions and 7 deletions

View File

@ -10,7 +10,12 @@
<p v-if="discount" class="tag discount">-{{ discount }}%</p> <p v-if="discount" class="tag discount">-{{ discount }}%</p>
</div> </div>
<img class="card-img" :src="imgSrc" :alt="alt" @load="handleLoad" /> <img
class="card-img"
:src="imgSrc ? imgSrc : '../../assets/empty-img.png'"
:alt="alt"
@load="handleLoad"
/>
<div class="head-hovered"> <div class="head-hovered">
<IconEyes /> <IconEyes />
@ -23,7 +28,7 @@
<div class="card-values"> <div class="card-values">
<p class="price" v-if="productValue">{{ productValue }}</p> <p class="price" v-if="productValue">{{ productValue }}</p>
<p class="price offer tachado" v-if="valueWithDiscount"> <p class="price offer tachado" v-if="+valueWithDiscount > 0">
{{ valueWithDiscount() }} {{ valueWithDiscount() }}
</p> </p>
</div> </div>
@ -32,7 +37,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent, ref } from 'vue';
import IconEyes from '../icons/IconEyes.vue'; import IconEyes from '../icons/IconEyes.vue';
type Size = 'sm-card' | 'md-card' | 'lg-card'; type Size = 'sm-card' | 'md-card' | 'lg-card';
@ -78,15 +83,17 @@ export default defineComponent({
}, },
}, },
setup({ productValue, discount }) { setup({ productValue, discount }) {
const loadingImg = ref(true);
const handleLoad = () => { const handleLoad = () => {
// console.log('Carregou'); loadingImg.value = false;
}; };
const valueWithDiscount = () => { const valueWithDiscount = () => {
const productWithouCaracters = ~~productValue.replaceAll('€', '');
if (discount) { if (discount) {
const finalValue = (+discount / 100) * +productValue; const finalValue = (+discount / 100) * productWithouCaracters;
// console.log(finalValue); return finalValue.toFixed(2);
return finalValue;
} }
}; };
@ -179,6 +186,7 @@ export default defineComponent({
& .card-img { & .card-img {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
} }

View File

@ -0,0 +1,21 @@
<template>
<q-btn flat @click="handleClick"><IconChat /></q-btn>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import IconChat from '../icons/IconChat.vue';
export default defineComponent({
name: 'chat-component',
components: { IconChat },
setup() {
const handleClick = () => {
console.log('click');
};
return { handleClick };
},
});
</script>
<style lang="scss" scoped></style>