优化myWineReview页面UI设计:调整点赞数量位置,保留一位小数,优化布局

This commit is contained in:
davy 2025-04-07 18:35:15 +08:00
parent 4096897a05
commit e09f1371d6

View File

@ -1,38 +1,105 @@
<template> <template>
<view class="page-content"> <view class="page">
<scroll-view v-if="myReviewList.length > 0" style="height: 100%;" scroll-y="true" @scrolltolower="changePage"> <!-- 排序选项 -->
<view class="review-item" v-for="(item, index) in myReviewList" :key="index"> <view class="sort-options">
<view class="flex margin-bottom-sm"> <view
<!-- <image src="" class="avatar"></image> --> class="sort-item"
<view class="flex flex-col"> :class="{ active: sortType === 'time' }"
<text class="beerName">{{ item.userName}}</text> @tap="changeSortType('time')"
<text class="time">{{ item.createTime.slice(0,10)}}</text> >
</view> <text class="cuIcon-time"></text>
<text>最新酒评</text>
</view> </view>
<view class="margin-bottom flex "> <view
<text class="word-all flex-1"> class="sort-item"
{{ item.reviewContent }} :class="{ active: sortType === 'score' }"
</text> @tap="changeSortType('score')"
<image v-if="item.reviewImg" :src="item.reviewImg" style="width: 200rpx;height:200rpx;flex-shrink: 0;margin-left: 20rpx;"></image> >
</view> <text class="cuIcon-favorfill"></text>
<view class="flex align-center justify-between"> <text>评分排序</text>
<view class="flex align-center justify-start">
<image src="@/static/vector.png" class="icon"></image>
<text style="color:#5F5F63;margin-right: 40rpx;">{{ item.overallRating }}</text>
<!-- <image src="@/static/message.png" class="icon"></image>
<text style="color:#979797">(100)</text> -->
</view>
<view class="cu-btn btn" @click="delReview(item)">删除</view>
</view> </view>
</view> </view>
<!-- 评价列表 -->
<scroll-view
v-if="myReviewList.length > 0"
class="review-list"
scroll-y="true"
@scrolltolower="changePage"
>
<view class="review-item" v-for="(item, index) in myReviewList" :key="index">
<!-- 酒款信息头部 -->
<view class="review-header">
<view class="beer-info">
<view class="beer-meta">
<text class="beer-name">{{item.beerName || '未知酒款'}}</text>
<view class="rating-row">
<uni-rate
:value="item.overallRating"
:readonly="true"
:size="16"
:touchable="false"
color="#ECECEC"
active-color="#FEE034"
/>
<text class="score-text">{{item.overallRating.toFixed(1)}}</text>
<view class="like-count">
<image src="/static/like.png" class="like-icon"></image>
<text class="count-text">{{item.reviewLike || 0}}</text>
</view>
</view>
</view>
</view>
<view class="review-meta">
<text class="review-time">{{item.createTime.slice(0,10)}}</text>
<view class="review-tag">我的评价</view>
</view>
</view>
<!-- 评论内容区域 -->
<view class="review-content">
<!-- 评论文本 -->
<view class="review-text">{{item.reviewContent}}</view>
<!-- 底部区域图片和删除按钮 -->
<view class="bottom-section">
<!-- 评论图片区域 -->
<scroll-view v-if="item.reviewImg" class="image-scroll" scroll-x="true">
<view class="image-container">
<image
v-for="(img, imgIndex) in item.reviewImg.split(',')"
:key="imgIndex"
:src="img"
class="review-image"
mode="aspectFill"
@tap="previewImage(item.reviewImg.split(','), imgIndex)"
></image>
</view>
</scroll-view>
<!-- 操作区域 -->
<view class="action-section">
<!-- 删除按钮 -->
<view class="action-btn delete-btn" @click="delReview(item)">
<text class="cuIcon-delete"></text>
<text>删除</text>
</view>
</view>
</view>
</view>
</view>
<!-- 加载更多 -->
<view class="load-more" v-if="myReviewList.length < total">
<text class="load-text">加载更多...</text>
</view>
</scroll-view> </scroll-view>
<template v-else>
<view class="flex align-center justify-center" <!-- 空状态 -->
style="height: 140rpx;width: 100%;color: #747783;font-size: 24rpx;">暂无评价</view> <view v-else class="empty-state">
</template> <text class="cuIcon-info"></text>
<text class="empty-text">暂无评价</text>
</view>
</view> </view>
</template> </template>
@ -48,35 +115,17 @@
total: 0, total: 0,
queryForm: { queryForm: {
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10,
} sortType: 'time' //
},
sortType: 'time'
} }
}, },
onLoad() { onLoad() {
//
console.log('开始测试接口...')
//
listMyReview({
pageNum: 1,
pageSize: 10
}).then(res => {
console.log('获取我的酒评列表测试成功:', res)
}).catch(err => {
console.error('获取我的酒评列表失败:', err)
})
// (ID)
// delReview('xxx').then(res => {
// console.log(':', res)
// }).catch(err => {
// console.error(':', err)
// })
//
this.getMyReviewList() this.getMyReviewList()
}, },
methods: { methods: {
//
getMyReviewList() { getMyReviewList() {
listMyReview(this.queryForm).then(res => { listMyReview(this.queryForm).then(res => {
this.total = res.total this.total = res.total
@ -85,9 +134,10 @@
this.myReviewList.push(item) this.myReviewList.push(item)
}) })
} }
// this.myReviewList = res.rows
}) })
}, },
//
delReview(item) { delReview(item) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
@ -103,70 +153,335 @@
icon: 'success' icon: 'success'
}) })
}) })
} else if (res.cancel) {
console.log('用户点击取消');
} }
} }
}) })
}, },
//
changePage() { changePage() {
if(this.myReviewList.length < this.total) { if(this.myReviewList.length < this.total) {
this.queryForm.pageNum++ this.queryForm.pageNum++
this.getMyReviewList() this.getMyReviewList()
} }
},
//
previewImage(urls, current) {
uni.previewImage({
urls: urls,
current: urls[current]
})
},
//
changeSortType(type) {
if (this.sortType === type) return
this.sortType = type
this.queryForm.sortType = type
this.queryForm.pageNum = 1
this.myReviewList = []
this.getMyReviewList()
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.page-content { .page {
padding: 32rpx; min-height: 100vh;
background: #FDFDFD; background: #F7F7F7;
height: 100vh; padding-bottom: 32rpx;
.review-item { .sort-options {
width: 100%; display: flex;
// height: 200rpx; background: #FFFFFF;
padding: 24rpx 0; padding: 24rpx 32rpx;
border-radius: 16rpx; margin: 24rpx 32rpx;
border-bottom: 1px solid rgba(242, 242, 242, 0.9); box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
border-radius: 16rpx;
position: sticky;
top: 0;
z-index: 10;
.avatar { .sort-item {
width: 60rpx; margin-right: 48rpx;
height: 60rpx; padding: 12rpx 24rpx;
border-radius: 50%; border-radius: 8rpx;
margin-right: 36rpx; transition: all 0.3s ease;
display: flex;
align-items: center;
.cuIcon-time, .cuIcon-favorfill {
font-size: 28rpx;
margin-right: 8rpx;
} }
.beerName { text {
font-size: 24rpx; font-size: 28rpx;
font-weight: bold; color: #666666;
color: #32343E;
margin-bottom: 8rpx;
} }
.time { &.active {
font-size: 24rpx; background: rgba(25, 54, 122, 0.1);
color: #9C9BA6;
text {
color: #19367A;
font-weight: 600;
}
.cuIcon-time, .cuIcon-favorfill {
color: #19367A;
}
} }
.icon { &:active {
width: 40rpx; transform: scale(0.95);
height: 40rpx;
margin-right: 10rpx;
} }
} }
.btn {
width: 118rpx;
height: 42rpx;
font-size: 20rpx;
border-radius: 12rpx;
box-sizing: border-box;
border: 1px solid #979797;
background: #fff;
}
} }
.review-list {
height: calc(100vh - 180rpx);
padding: 0 32rpx;
}
.review-item {
background: #FFFFFF;
border-radius: 16rpx;
margin-bottom: 24rpx;
padding: 32rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
position: relative;
overflow: hidden;
transition: all 0.3s ease;
&:active {
transform: translateY(2rpx);
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 8rpx;
height: 100%;
background: linear-gradient(to bottom, #19367A, #4A6FCC);
border-radius: 4rpx 0 0 4rpx;
}
.review-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
// margin-bottom: 24rpx;
padding-bottom: 24rpx;
// border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
.beer-info {
flex: 1;
.beer-meta {
.beer-name {
font-size: 32rpx;
font-weight: 600;
color: #333333;
margin-bottom: 12rpx;
display: block;
}
.rating-row {
display: flex;
align-items: center;
.score-text {
font-size: 24rpx;
color: #FFB800;
margin-left: 8rpx;
font-weight: 600;
}
.like-count {
display: flex;
align-items: center;
margin-left: 16rpx;
padding: 4rpx 12rpx;
background: rgba(25, 54, 122, 0.05);
border-radius: 20rpx;
transition: all 0.3s ease;
&:active {
transform: scale(0.95);
background: rgba(25, 54, 122, 0.1);
}
.like-icon {
width: 24rpx;
height: 24rpx;
margin-right: 4rpx;
}
.count-text {
font-size: 22rpx;
color: #666666;
font-weight: 500;
}
}
}
}
}
.review-meta {
display: flex;
flex-direction: column;
align-items: flex-end;
.review-time {
font-size: 24rpx;
color: #999999;
margin-bottom: 8rpx;
}
.review-tag {
font-size: 20rpx;
color: #FFFFFF;
background: linear-gradient(to right, #19367A, #4A6FCC);
padding: 4rpx 12rpx;
border-radius: 20rpx;
box-shadow: 0 2rpx 8rpx rgba(25, 54, 122, 0.2);
}
}
}
.review-content {
margin-bottom: 24rpx;
.review-text {
font-size: 28rpx;
color: #666666;
line-height: 1.6;
margin-bottom: 24rpx;
position: relative;
padding: 16rpx 24rpx;
word-break: break-all;
white-space: pre-wrap;
overflow-wrap: break-word;
background: rgba(25, 54, 122, 0.02);
border-radius: 12rpx;
box-shadow: inset 0 2rpx 8rpx rgba(0, 0, 0, 0.02);
&::before {
content: '"';
position: absolute;
left: 16rpx;
top: -8rpx;
font-size: 40rpx;
color: rgba(25, 54, 122, 0.2);
font-family: serif;
}
}
.bottom-section {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 16rpx;
padding-top: 16rpx;
// border-top: 1rpx solid rgba(0, 0, 0, 0.05);
.image-scroll {
flex: 1;
width: 70%;
white-space: nowrap;
.image-container {
display: inline-flex;
.review-image {
width: 160rpx;
height: 160rpx;
border-radius: 12rpx;
margin-right: 16rpx;
object-fit: cover;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
&:active {
transform: scale(0.98);
}
&:last-child {
margin-right: 0;
}
}
}
}
.action-section {
display: flex;
align-items: center;
justify-content: flex-end;
width: 30%;
.action-btn {
display: flex;
align-items: center;
padding: 8rpx 16rpx;
border-radius: 8rpx;
transition: all 0.3s ease;
&:active {
transform: scale(0.95);
}
text {
font-size: 24rpx;
}
&.delete-btn {
background: rgba(255, 77, 79, 0.1);
color: #FF4D4F;
box-shadow: 0 2rpx 8rpx rgba(255, 77, 79, 0.1);
.cuIcon-delete {
margin-right: 8rpx;
}
}
}
}
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 0;
.cuIcon-info {
font-size: 64rpx;
color: #CCCCCC;
margin-bottom: 24rpx;
}
.empty-text {
font-size: 28rpx;
color: #999999;
}
}
.load-more {
text-align: center;
padding: 24rpx 0;
.load-text {
font-size: 24rpx;
color: #999999;
}
}
}
</style> </style>