Files
frontend-app/pages/other_package/productInfo/evaluate-dialog.vue
T

338 lines
7.9 KiB
Vue
Raw Normal View History

2026-07-02 17:02:55 +08:00
<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"
2026-07-07 17:51:33 +08:00
:class="['filter-tab', { active: activeTab === tab.value }]"
@click="handleTabClick(tab)"
2026-07-02 17:02:55 +08:00
>
{{ tab.name }}
</view>
</view>
<!-- 可上下滚动的评价列表区域 -->
<scroll-view
class="eval-scroll"
scroll-y
:enhanced="true"
:show-scrollbar="false"
>
2026-07-07 17:51:33 +08:00
<view class="eval-list" >
2026-07-02 17:02:55 +08:00
<view
class="eval-item"
v-for="(item, index) in evalList"
:key="index"
2026-07-07 17:51:33 +08:00
@click="handleClick(item)"
2026-07-02 17:02:55 +08:00
>
<view class="user-info-row">
<view class="user-avatar-name">
2026-07-07 17:51:33 +08:00
<image
class="avatar-wrap"
:src="item.userImage"
mode="aspectFill"
></image>
2026-07-02 17:02:55 +08:00
<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="{
2026-07-07 17:51:33 +08:00
color: s <= item.rating ? '#7934f6' : '#e5e5e5',
2026-07-02 17:02:55 +08:00
}"
>★</text
>
</view>
<text class="tag">{{ item.tag }}</text>
</view>
</view>
<view class="product-sku"
2026-07-07 17:51:33 +08:00
>已购{{item.goodsName}}</view
2026-07-02 17:02:55 +08:00
>
<view class="eval-content-text">
2026-07-08 16:17:37 +08:00
<text style="white-space:pre-wrap"
2026-07-07 17:51:33 +08:00
>{{item.content}}</text
2026-07-02 17:02:55 +08:00
>
</view>
2026-07-07 17:51:33 +08:00
<view class="eval-images" v-if="item.images">
2026-07-02 17:02:55 +08:00
<image
class="eval-img"
2026-07-07 17:51:33 +08:00
:src="item.images"
2026-07-02 17:02:55 +08:00
mode="aspectFill"
></image>
</view>
</view>
</view>
</scroll-view>
</view>
</up-popup>
</view>
</template>
<script>
2026-07-07 17:51:33 +08:00
import { getGoodsReviewsList } from "@/api/product.js";
2026-07-02 17:02:55 +08:00
export default {
name: "EvaluateDialog",
props: {
show: {
type: Boolean,
default: false,
},
2026-07-07 17:51:33 +08:00
evalId: {
type: Number,
default: 0,
},
mainGraph: {
type: String,
default: '',
},
name: {
type: String,
default: '',
},
2026-07-02 17:02:55 +08:00
},
data() {
return {
2026-07-07 17:51:33 +08:00
activeTab: "all",
2026-07-02 17:02:55 +08:00
tabs: [
{ name: "全部", value: "all" },
2026-07-07 17:51:33 +08:00
{ name: "好评", value: "5" },
{ name: "中/差评", value: "4" },
2026-07-02 17:02:55 +08:00
],
2026-07-07 17:51:33 +08:00
evalList: [],
2026-07-02 17:02:55 +08:00
};
2026-07-07 17:51:33 +08:00
},
mounted(){
this.getGoodsReviewsList();
2026-07-02 17:02:55 +08:00
},
methods: {
2026-07-07 17:51:33 +08:00
async getGoodsReviewsList() {
const params = {
page: 1,
pageSize: 15,
goodsId: this.evalId,
};
if (this.activeTab !== "all") {
params.rating = this.activeTab;
}
const resp = await getGoodsReviewsList(params);
if (resp && resp.bizcode === 100) {
this.evalList = resp.data.entitys || [];
}
},
handleTabClick(item) {
this.activeTab = item.value
this.getGoodsReviewsList();
},
2026-07-02 17:02:55 +08:00
handleClose() {
this.$emit("close");
},
handleClick(item) {
2026-07-07 17:51:33 +08:00
console.log('点击评价',item.goodsName);
2026-07-02 17:02:55 +08:00
uni.navigateTo({
2026-07-07 17:51:33 +08:00
url: "/pages/other_package/productInfo/evaluateDetail?evalId=" + item.id + "&mainGraph=" + this.mainGraph + "&name=" + this.name+"&goodsName="+item.goodsName,
2026-07-02 17:02:55 +08:00
});
},
},
};
</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;
2026-07-03 11:41:17 +08:00
margin: 0 20rpx;
2026-07-02 17:02:55 +08:00
}
.filter-tabs {
display: flex;
background-color: #ffffff;
padding: 10rpx 30rpx 30rpx;
gap: 24rpx; /* 标签之间的标准间距 */
2026-07-03 11:41:17 +08:00
margin: 0 20rpx;
border-top: 1rpx solid #f6f6f6;
2026-07-02 17:02:55 +08:00
.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;
2026-07-03 11:41:17 +08:00
border-radius: 16rpx;
margin: 0 20rpx;
2026-07-02 17:02:55 +08:00
}
.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%;
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;
2026-07-08 16:17:37 +08:00
word-break: break-all;
2026-07-02 17:02:55 +08:00
}
.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>