Files
xinlong-shop-taro/src/pages/order/evaluate-detail.tsx
赵忠林 f3886664f7 fix(api): 替换所有接口请求的域名为 guilixu-api.websoft.top
- 将获取 STS Token 的接口地址由 paopao-api 改为 guilixu-api
- 更新图片上传接口地址为新的 guilixu-api 域名
- 修改用户推广页面中邀请码链接和二维码接口的域名
- 更改注册页微信登录接口请求的域名为 guilixu-api
2026-06-16 17:15:59 +08:00

187 lines
7.3 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useState } from 'react'
import { View, Text, ScrollView, Swiper, SwiperItem } from '@tarojs/components'
import Taro from '@tarojs/taro'
definePageConfig({
navigationBarTitleText: '评价详情',
})
const EvaluateDetailPage: React.FC = () => {
const [evaluation, setEvaluation] = useState({
id: 1,
goodsId: 1,
goodsName: '高品质保温杯',
goodsImage: '',
score: 5,
content: '质量很好,保温效果非常棒!物流也很快,包装严实,非常满意的一次购物体验。\n\n杯子的外观设计很时尚颜色也很正同事们都问我在哪里买的。保温效果真的很好早上装的开水到下午还是温热的。\n\n唯一的小缺点就是盖子有点紧不过用多了应该会好一些。总体来说非常满意推荐大家购买',
images: ['', '', ''],
isAnonymous: false,
userName: '张***',
createTime: '2026-05-10 14:30:00',
likes: 12,
isLiked: false,
replies: [
{
id: 1,
content: '感谢您的好评!我们会继续努力提供优质产品和服务。',
createTime: '2026-05-10 15:00:00',
isOfficial: true,
},
],
})
// 渲染星星
const renderStars = (score: number) => {
const stars = []
for (let i = 1; i <= 5; i++) {
stars.push(
<Text key={i} className={i <= score ? 'text-orange-400' : 'text-gray-300'}>
</Text>
)
}
return stars
}
// 处理点赞
const handleLike = () => {
setEvaluation(prev => ({
...prev,
isLiked: !prev.isLiked,
likes: prev.isLiked ? prev.likes - 1 : prev.likes + 1,
}))
Taro.showToast({ title: evaluation.isLiked ? '已取消点赞' : '点赞成功', icon: 'success' })
}
// 图片预览
const handleImagePreview = (index: number) => {
// 这里应该调用 Taro.previewImage
Taro.showToast({ title: `查看第${index + 1}张图片`, icon: 'none' })
}
return (
<View className='bg-gray-50 flex flex-col' style={{ minHeight: '100vh' }}>
<ScrollView scrollY className='flex-1'>
{/* 用户信息 */}
<View className='bg-white p-4 mb-3'>
<View className='flex items-center gap-2 mb-3'>
<View className='w-10 h-10 rounded-full flex items-center justify-center' style={{ background: 'linear-gradient(to right, #60a5fa, #c084fc)' }}>
<Text className='text-white font-bold'>{evaluation.isAnonymous ? '匿' : evaluation.userName[0]}</Text>
</View>
<View className='flex-1'>
<Text className='text-sm text-gray-700 font-medium block'>{evaluation.userName}</Text>
<View className='flex items-center gap-1'>
{renderStars(evaluation.score)}
</View>
</View>
<Text className='text-xs text-gray-400'>{evaluation.createTime.split(' ')[0]}</Text>
</View>
</View>
{/* 商品信息 */}
<View
className='bg-white p-4 mb-3'
onClick={() => Taro.navigateTo({ url: `/pages/shop/product-detail?id=${evaluation.goodsId}` })}
>
<View className='flex items-center gap-2'>
<View className='w-12 h-12 bg-gray-100 rounded-lg flex items-center justify-center flex-shrink-0'>
<Text className='text-2xl'>🛍</Text>
</View>
<View className='flex-1'>
<Text className='text-sm text-gray-700 block'>{evaluation.goodsName}</Text>
<Text className='text-xs text-gray-400 mt-1 block'></Text>
</View>
<Text className='text-gray-400'></Text>
</View>
</View>
{/* 评价内容 */}
<View className='bg-white p-4 mb-3'>
<Text className='text-sm text-gray-700 leading-7 block whitespace-pre-wrap'>
{evaluation.content}
</Text>
{/* 评价图片 */}
{evaluation.images && evaluation.images.length > 0 && (
<View className='mt-3'>
<Swiper
className='h-48 rounded-lg'
indicatorColor='#999'
indicatorActiveColor='#333'
circular
autoplay={false}
>
{evaluation.images.map((_, index) => (
<SwiperItem key={index}>
<View className='w-full h-48 bg-gray-100 flex items-center justify-center'>
<Text className='text-4xl'>🖼</Text>
<Text className='text-xs text-gray-400 mt-2'> {index + 1}</Text>
</View>
</SwiperItem>
))}
</Swiper>
<View className='flex justify-center gap-1 mt-2'>
{evaluation.images.map((_, index) => (
<View key={index} className='w-1 h-1 rounded-full bg-gray-300' />
))}
</View>
</View>
)}
</View>
{/* 商家回复 */}
{evaluation.replies && evaluation.replies.length > 0 && (
<View className='bg-white p-4 mb-3'>
<Text className='text-sm font-medium text-gray-800 mb-2 block'></Text>
{evaluation.replies.map(reply => (
<View key={reply.id} className='bg-orange-50 rounded-lg p-3'>
<View className='flex items-center gap-2 mb-2'>
{reply.isOfficial && (
<View className='bg-orange-500 px-2 py-1 rounded'>
<Text className='text-xs text-white'></Text>
</View>
)}
<Text className='text-xs text-gray-400'>{reply.createTime}</Text>
</View>
<Text className='text-sm text-gray-700 leading-6'>{reply.content}</Text>
</View>
))}
</View>
)}
</ScrollView>
{/* 底部操作栏 */}
<View className='bg-white border-t border-gray-100 px-4 py-2 flex items-center justify-around' style={{ paddingBottom: '20px' }}>
<View className='flex flex-col items-center' onClick={handleLike}>
<Text className={`text-2xl ${evaluation.isLiked ? 'text-red-500' : 'text-gray-400'}`}>
{evaluation.isLiked ? '❤️' : '🤍'}
</Text>
<Text className={`text-xs ${evaluation.isLiked ? 'text-red-500' : 'text-gray-400'}`}>
{evaluation.likes}
</Text>
</View>
<View className='flex flex-col items-center' onClick={() => Taro.showToast({ title: '收藏成功', icon: 'success' })}>
<Text className='text-2xl'></Text>
<Text className='text-xs text-gray-400'></Text>
</View>
<View className='flex flex-col items-center' onClick={() => Taro.showToast({ title: '举报已提交', icon: 'success' })}>
<Text className='text-2xl'></Text>
<Text className='text-xs text-gray-400'></Text>
</View>
<View
className='bg-orange-500 text-white px-6 py-2 rounded-full'
onClick={() => Taro.navigateTo({ url: `/pages/shop/product-detail?id=${evaluation.goodsId}` })}
>
<Text className='text-sm text-white'></Text>
</View>
</View>
</View>
)
}
export default EvaluateDetailPage