feat: 商品评价

This commit is contained in:
黄泽群
2026-07-09 14:10:48 +08:00
committed by charles
parent b95d54001f
commit 2ef2ceaa44
9 changed files with 1218 additions and 1047 deletions
@@ -0,0 +1,299 @@
<template>
<view class="content">
<up-popup
:show="show"
:round="20"
:closeOnClickOverlay="false"
:closeable="true"
:safeAreaInsetBottom="false"
@close="handleClose"
>
<view class="evaluate-popup">
<!-- 固定的标题头部 -->
<view class="popup-header">
<text class="title">评价</text>
</view>
<!-- 固定的切换标签 -->
<view class="filter-tabs">
<view
v-for="(tab, index) in tabs"
:key="index"
:class="['filter-tab', { active: activeTab === index }]"
@click="activeTab = index"
>
{{ tab.name }}
</view>
</view>
<!-- 可上下滚动的评价列表区域 -->
<scroll-view
class="eval-scroll"
scroll-y
:enhanced="true"
:show-scrollbar="false"
>
<view class="eval-list" @click="handleClick(item)">
<view
class="eval-item"
v-for="(item, index) in evalList"
:key="index"
>
<view class="user-info-row">
<view class="user-avatar-name">
<view class="avatar-wrap">
<text class="avatar-text">李</text>
</view>
<text class="username">{{ item.userName }}</text>
<view class="user-level">
<up-image
src="/static/common/rz.png"
width="13"
height="12"
bgColor="#f1f6ff00"
class="arrow"
></up-image>
<text class="level-text">星级用户</text>
</view>
</view>
<view class="rating-tag">
<view class="stars">
<text
v-for="s in 5"
:key="s"
class="star-icon"
:style="{
color: s <= item.score ? '#7934f6' : '#e5e5e5',
}"
>★</text
>
</view>
<text class="tag">{{ item.tag }}</text>
</view>
</view>
<view class="product-sku"
>已购韩版FILA斐乐Running MIXR猫爪鞋黑色男女运动...</view
>
<view class="eval-content-text">
<text
>包装非常严实,里三层外三层的,完全不用担心运输损坏。</text
>
</view>
<view class="eval-images" >
<image
class="eval-img"
src="https://img.yzcdn.cn/vant/cat.jpeg"
mode="aspectFill"
></image>
</view>
</view>
</view>
</scroll-view>
</view>
</up-popup>
</view>
</template>
<script>
export default {
name: "EvaluateDialog",
props: {
show: {
type: Boolean,
default: false,
},
},
data() {
return {
activeTab: 0,
tabs: [
{ name: "全部", value: "all" },
{ name: "好评", value: "good" },
{ name: "中/差评", value: "bad" },
],
evalList: [
{ userName: "李老八", score: 5, tag: "好评", images: ["https://img.yzcdn.cn/vant/cat.jpeg", "https://img.yzcdn.cn/vant/dog.jpeg", "https://img.yzcdn.cn/vant/fox.jpeg"] },
{ userName: "王老五", score: 4, tag: "好评", images: ["https://img.yzcdn.cn/vant/cat.jpeg", "https://img.yzcdn.cn/vant/dog.jpeg"] },
{ userName: "张三", score: 5, tag: "好评", images: ["https://img.yzcdn.cn/vant/cat.jpeg"] },
],
};
},
methods: {
handleClose() {
this.$emit("close");
},
handleClick(item) {
uni.navigateTo({
url: "/pages/other_package/productInfo/evaluateDetail?item=" + JSON.stringify(item),
});
},
},
};
</script>
<style lang="scss" scoped>
.evaluate-popup {
height: 85vh; /* 改为固定高度百分比,使内部 flex 自适应支撑起滚动条 */
background-color: #f6f6f6;
border-radius: 20rpx 20rpx 0 0;
display: flex;
flex-direction: column;
}
.popup-header {
text-align: center;
font-size: 30rpx;
background-color: #ffffff;
color: #333333;
font-weight: 500;
padding: 30rpx 0 20rpx;
position: relative;
border-radius: 20rpx 20rpx 0 0;
}
.filter-tabs {
display: flex;
background-color: #ffffff;
padding: 10rpx 30rpx 30rpx;
gap: 24rpx; /* 标签之间的标准间距 */
.filter-tab {
text-align: center;
font-size: 26rpx;
color: #333333;
padding: 12rpx 32rpx; /* 改用横向内边距,使其宽度根据内容自适应且规范 */
border-radius: 8rpx; /* 契合图片的轻微小圆角 */
background-color: #f5f5f7; /* 未激活状态的浅灰色 */
transition: all 0.2s ease-in-out;
&.active {
background-color: #f2ecff; /* 激活时如图片所示的极浅紫色背景 */
color: #7934f6; /* 激活时的标志性紫色字体 */
font-weight: 500;
}
}
}
.eval-scroll {
flex: 1; /* 核心:占满剩余所有的垂直空间 */
height: 0; /* 必须设置为0,防止容器被子内容撑开导致无法滚动 */
overflow: hidden;
}
.eval-list {
background-color: #f6f6f6;
display: flex;
flex-direction: column;
gap: 12rpx;
padding-bottom: 40rpx; /* 底部预留间距 */
.eval-item {
padding: 30rpx 30rpx 20rpx;
background-color: #ffffff;
}
.user-info-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
.user-avatar-name {
display: flex;
align-items: center;
.avatar-wrap {
width: 70rpx;
height: 70rpx;
border-radius: 50%;
background-color: #a46cfc;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16rpx;
.avatar-text {
font-size: 32rpx;
color: #ffffff;
}
}
.username {
font-size: 32rpx;
color: #000000;
font-weight: 500;
margin-right: 28rpx;
}
.user-level {
display: flex;
align-items: center;
background: rgba(248, 185, 75, 0.15);
border-radius: 8rpx;
padding: 4rpx 12rpx;
.level-text {
font-size: 20rpx;
color: #a26616;
margin-left: 4rpx;
}
}
}
.rating-tag {
display: flex;
align-items: center;
.stars {
display: flex;
margin-right: 10rpx;
.star-icon {
font-size: 24rpx;
}
}
.tag {
font-size: 28rpx;
color: #7934f6;
}
}
}
.product-sku {
font-size: 26rpx;
color: #aaaaaa;
margin-bottom: 20rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.eval-content-text {
margin-bottom: 24rpx;
font-size: 28rpx;
color: #333333;
line-height: 1.5;
}
.eval-images {
white-space: nowrap;
.eval-images-wrap {
display: inline-flex;
gap: 16rpx;
}
.eval-img {
width: 210rpx;
height: 210rpx;
border-radius: 12rpx;
background-color: #f0f2f5;
flex-shrink: 0;
}
}
}
</style>