feat: 商品评价
This commit is contained in:
@@ -0,0 +1,345 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<TopSafe></TopSafe>
|
||||
<Header title="发表评价" />
|
||||
|
||||
<view class="setting-view">
|
||||
<!-- 评价核心白底卡片容器 -->
|
||||
<view class="review-card">
|
||||
<!-- 商品信息模块 -->
|
||||
<view class="product-section">
|
||||
<image class="product-img" src="https://images.unsplash.com/photo-1542291026-7eec264c27ff?q=80&w=200" mode="aspectFill"></image>
|
||||
<view class="product-detail">
|
||||
<text class="product-title">kechers斯凯奇2024年秋冬kechers斯凯奇2024年秋冬kechers斯凯奇2024年秋冬kechers斯凯奇2024年秋冬kechers斯凯奇2024年秋冬kechers斯凯奇2024年秋冬</text>
|
||||
<text class="product-spec">规格:白色;</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 信任度评分模块 -->
|
||||
<view class="rating-section">
|
||||
<text class="rating-label">信任度</text>
|
||||
<view class="stars-box">
|
||||
<text
|
||||
v-for="index in 5"
|
||||
:key="index"
|
||||
class="star-icon"
|
||||
:class="{ active: index <= rating }"
|
||||
@click="setRating(index)"
|
||||
>★</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 评价输入框模块 -->
|
||||
<view class="comment-section">
|
||||
<textarea
|
||||
class="comment-textarea"
|
||||
v-model="commentText"
|
||||
placeholder="您的评价可以帮助更多的人哦"
|
||||
maxlength="100"
|
||||
placeholder-class="placeholder-style"
|
||||
/>
|
||||
<view class="word-counter">已输入{{ commentText.length }}/100</view>
|
||||
</view>
|
||||
|
||||
<!-- 照片/视频上传模块 -->
|
||||
<view class="upload-section">
|
||||
<view class="upload-grid">
|
||||
<!-- 已上传媒体预览 -->
|
||||
<view class="upload-item" v-for="(item, idx) in mediaList" :key="idx">
|
||||
<image :src="item" mode="aspectFill" class="uploaded-media"></image>
|
||||
<view class="delete-btn" @click="deleteMedia(idx)">×</view>
|
||||
</view>
|
||||
|
||||
<!-- 上传触发按钮 -->
|
||||
<view class="upload-btn" @click="chooseMedia" v-if="mediaList.length < 9">
|
||||
<text class="plus-icon">+</text>
|
||||
<text class="upload-text">上传照片/视频</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部固定发表评价按钮 -->
|
||||
<view class="bottom-action-bar">
|
||||
<button class="submit-review-btn" @click="submitReview">发表评价</button>
|
||||
</view>
|
||||
|
||||
<up-toast ref="uToastRef"></up-toast>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Header from '@/components/common/header.vue';
|
||||
import TopSafe from '@/components/common/top-safe.nvue'
|
||||
import MyBtn from '@/components/common/my-btn.vue'
|
||||
|
||||
export default {
|
||||
components: { Header, TopSafe, MyBtn },
|
||||
data() {
|
||||
return {
|
||||
rating: 0, // 评分星级
|
||||
commentText: '', // 评价内容
|
||||
mediaList: [] // 已上传的图片/视频列表
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
|
||||
},
|
||||
onLoad() {
|
||||
},
|
||||
methods: {
|
||||
// 设置评分
|
||||
setRating(val) {
|
||||
this.rating = val;
|
||||
},
|
||||
// 调起系统相册/相机选择媒体
|
||||
chooseMedia() {
|
||||
uni.chooseImage({
|
||||
count: 9 - this.mediaList.length,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
this.mediaList = [...this.mediaList, ...res.tempFilePaths];
|
||||
}
|
||||
});
|
||||
},
|
||||
// 删除选中的媒体文件
|
||||
deleteMedia(idx) {
|
||||
this.mediaList.splice(idx, 1);
|
||||
},
|
||||
// 提交评价
|
||||
submitReview() {
|
||||
if (this.rating === 0) {
|
||||
this.$refs.uToastRef.show({ message: '请为商品信任度评分', type: 'warning' });
|
||||
return;
|
||||
}
|
||||
if (!this.commentText.trim()) {
|
||||
this.$refs.uToastRef.show({ message: '请输入您的评价内容', type: 'warning' });
|
||||
return;
|
||||
}
|
||||
// 模拟请求成功
|
||||
this.$refs.uToastRef.show({ message: '评价成功', type: 'success' });
|
||||
// 评价成功后,返回上一页
|
||||
uni.navigateBack({ delta: 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
background-color: #f7f7f7;
|
||||
min-height: 100vh;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.setting-view {
|
||||
width: 100%;
|
||||
height: calc(100vh - 220rpx - var(--status-bar-height)); /* 留出底部按钮区域空间 */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 核心内容白底卡片样式 */
|
||||
.review-card {
|
||||
width: 100%;
|
||||
background-color: #ffffff;
|
||||
border-radius: 16rpx;
|
||||
padding: 36rpx 24rpx;
|
||||
margin-top: 24rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 商品模块 */
|
||||
.product-section {
|
||||
display: flex;
|
||||
margin-bottom: 40rpx;
|
||||
|
||||
.product-img {
|
||||
width: 156rpx;
|
||||
height: 156rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.product-detail {
|
||||
margin-left: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
flex: 1;
|
||||
|
||||
.product-title {
|
||||
font-size: 28rpx;
|
||||
color: #111111;
|
||||
font-weight: bold;
|
||||
line-height: 38rpx;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.product-spec {
|
||||
font-size: 24rpx;
|
||||
color: #aaaaaa;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 信任度评分模块 */
|
||||
.rating-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 48rpx;
|
||||
|
||||
.rating-label {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
margin-right: 32rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.stars-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.star-icon {
|
||||
font-size: 42rpx;
|
||||
color: #e5e5e5;
|
||||
margin-right: 20rpx;
|
||||
transition: color 0.15s ease;
|
||||
cursor: pointer;
|
||||
|
||||
&.active {
|
||||
color: #7934f6; /* 选中状态呈现高亮蓝 */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 评价输入框模块 */
|
||||
.comment-section {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
margin-bottom: 32rpx;
|
||||
|
||||
.comment-textarea {
|
||||
width: 100%;
|
||||
height: 180rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
line-height: 40rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.placeholder-style {
|
||||
color: #cccccc;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.word-counter {
|
||||
text-align: right;
|
||||
font-size: 24rpx;
|
||||
color: #bbbbbb;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
/* 媒体文件上传模块 */
|
||||
.upload-section {
|
||||
width: 100%;
|
||||
|
||||
.upload-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.upload-item {
|
||||
position: relative;
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
|
||||
.uploaded-media {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
position: absolute;
|
||||
top: -12rpx;
|
||||
right: -12rpx;
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
color: #ffffff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.upload-btn {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
background-color: #f7f8fa;
|
||||
border-radius: 8rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.plus-icon {
|
||||
font-size: 52rpx;
|
||||
color: #999999;
|
||||
line-height: 1;
|
||||
margin-bottom: 12rpx;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.upload-text {
|
||||
font-size: 20rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 底部操作固定栏 */
|
||||
.bottom-action-bar {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
background-color: #ffffff;
|
||||
padding: 24rpx 32rpx calc(24rpx + env(safe-area-inset-bottom));
|
||||
box-sizing: border-box;
|
||||
z-index: 99;
|
||||
|
||||
.submit-review-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
background: #7F32FF; /* 高度还原UI图中的核心紫色 */
|
||||
color: #ffffff;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user