Files
lilishop-uniapp/pages/tabbar/home/template/tpl_group.vue
Yer11214 349ffa4f34 refactor: 重构多个组件以支持 Vue 3 语法和功能
- 将多个组件转换为 `<script setup>` 语法,提升可读性和性能
- 优化状态管理和事件处理逻辑,简化代码结构
- 更新样式和布局以适应新组件结构
- 添加新功能和修复已知问题,提升用户体验
2026-07-08 18:37:11 +08:00

116 lines
2.5 KiB
Vue

<template>
<div class="layout" v-if="goodsList.length">
<div class="join-list">
<div class="join-title" @click="goMore">
<div class="join-title-name">{{ res.list[0].title }}</div>
<div class="join-title-more">更多</div>
</div>
<div class="join-box">
<div
class="join-item"
@click="goDetail(item)"
v-for="(item, index) in goodsList"
:key="index"
>
<div class="item-img-box">
<u-image
class="item-img"
width="150rpx"
height="150rpx"
:src="item.goodsImage || item.thumbnail"
/>
</div>
<div class="item-price">
<span class="price-text">{{ item.price }}</span>
</div>
<div class="item-line-through">
<span class="price-text">{{ item.originalPrice }}</span>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from "vue";
import * as API_Promotions from "@/api/promotions";
const props = defineProps<{ res: any }>();
const goodsList = ref<any[]>([]);
onMounted(() => {
API_Promotions.getAssembleList({
pageNumber: 1,
pageSize: props.res.list[0].count || 3,
promotionStatus: "START",
}).then((res) => {
if (res.data.success && res.data.result && res.data.result.records) {
goodsList.value = res.data.result.records.slice(
0,
props.res.list[0].count || 3
);
}
});
});
function goMore() {
uni.navigateTo({ url: "/pages/promotion/joinGroup" });
}
function goDetail(item: any) {
uni.navigateTo({
url: `/pages/product/goods?id=${item.skuId}&goodsId=${item.goodsId}`,
});
}
</script>
<style lang="scss" scoped>
@import "./tpl.scss";
.join-box {
display: flex;
}
.item-price {
.price-text {
font-size: 15px;
font-weight: 500;
color: $main-color;
}
}
.join-item {
flex: 1;
text-align: center;
}
.item-img {
width: 75px;
height: 75px;
margin: 0 auto;
display: block;
}
.item-img-box {
position: relative;
}
.item-line-through {
.price-text {
font-size: 10px;
font-weight: 400;
text-decoration: line-through;
color: #999;
}
}
.join-title {
display: flex;
justify-content: space-between;
align-items: center;
background: #fff;
height: 50px;
.join-title-name {
font-size: 16px;
font-weight: bold;
}
.join-title-more {
font-size: 12px;
color: #999;
}
}
</style>