99 lines
2.3 KiB
Vue
Raw Normal View History

<template>
2025-05-22 16:11:32 +08:00
<div class="c-goods-item-warp" @click="toDetail(data.id)">
<div class="goods-img">
2025-05-22 16:11:32 +08:00
<img :src="data.goodUrl ? data.goodUrl : ''" alt="" style="width: 100%" />
<!-- <el-image :src="encodeURIComponent(data.goodUrl) ? encodeURIComponent(data.goodUrl) : ''" fit="cover" @error="handleImageError" />-->
</div>
2025-05-22 16:11:32 +08:00
<div class="goods-name txt-ellipsis clamp2">{{ data.title }}</div>
<div class="goods-do">
2025-05-22 16:11:32 +08:00
<div class="price txt-ellipsis clamp">{{ data.goodPrice }}</div>
<div class="do">
<div class="iconfont icon-cart"></div>
</div>
</div>
</div>
</template>
<script setup>
2025-05-22 16:11:32 +08:00
import { ref, onMounted, computed } from 'vue';
import { isEmpty, getAssetsFile } from '@/utils';
2025-04-09 17:25:08 +08:00
import { useRoute, useRouter } from 'vue-router';
2025-05-22 16:11:32 +08:00
import { encodeURL } from 'js-base64';
2025-04-09 17:25:08 +08:00
const route = useRoute();
const router = useRouter();
2025-05-22 16:11:32 +08:00
const props = defineProps({
data: {
type: Object,
default: () => {},
},
});
const handleImageError = (e) => {
console.error('图片加载失败:', e);
};
const toDetail = (id) => {
2025-04-11 17:32:55 +08:00
router.push('/sub-operation-service/ecommerce-agriculturalDetail?id=' + id);
2025-04-09 17:25:08 +08:00
};
</script>
<style lang="scss" scoped>
.c-goods-item-warp {
padding: 8px;
2025-05-20 13:05:37 +08:00
width: 100%;
2025-04-12 14:32:47 +08:00
cursor: pointer;
.goods-img {
2025-05-20 13:05:37 +08:00
overflow: hidden;
width: 100%;
height: 168px;
border-radius: 16px;
::v-deep() {
.el-image {
width: 100%;
height: 168px;
}
}
}
.goods-name {
margin-top: 8px;
font-size: 16px;
color: $color-666;
}
.goods-do {
display: inline-flex;
justify-content: space-between;
2025-05-20 13:05:37 +08:00
width: 100%;
.price {
2025-05-20 13:05:37 +08:00
padding-right: 8px;
width: calc(100% - 32px);
font-size: 22px;
font-weight: 700;
2025-05-20 13:05:37 +08:00
text-align: left;
color: $color-main;
}
.price::before {
content: ' ¥';
font-size: 16px !important;
font-weight: normal !important;
}
.do {
2025-05-20 13:05:37 +08:00
position: relative;
display: inline-block;
width: 32px;
height: 32px;
border-radius: 50%;
text-align: center;
background: $color-main;
cursor: pointer;
.iconfont {
position: absolute;
top: 50%;
2025-05-20 13:05:37 +08:00
left: 50%;
font-size: 20px;
2025-05-20 13:05:37 +08:00
color: $color-fff;
transform: translate(-50%, -50%);
}
}
}
}
</style>