v4.0.17 小程序版本优化
CI / verify (pull_request) Has been cancelled

This commit is contained in:
2026-09-03 23:28:37 +08:00
parent 8a196c377e
commit 0e711be6c6
18 changed files with 254 additions and 84 deletions
@@ -57,8 +57,10 @@ function readCachedRecord(): RedeemRecord | null {
export default function RedeemSuccessPage() {
const router = useRouter();
const [fromHistory, setFromHistory] = useState(false);
const [fromStore, setFromStore] = useState(false);
const [record, setRecord] = useState<RedeemRecord | null>(null);
const [score, setScore] = useState(5);
const [serviceScore, setServiceScore] = useState(5);
const [envScore, setEnvScore] = useState(5);
const [tags, setTags] = useState<string[]>(['菜品好', '环境佳', '服务周到']);
const [comment, setComment] = useState('');
const [imageUrls, setImageUrls] = useState<string[]>([]);
@@ -68,8 +70,12 @@ export default function RedeemSuccessPage() {
const rated = Boolean(record?.rating);
const applyRating = useCallback((rating: StoreRatingDto) => {
const nextScore = Number(rating.serviceScore || rating.envScore || 5);
setScore(Number.isFinite(nextScore) && nextScore > 0 ? Math.min(5, Math.round(nextScore)) : 5);
const nextService = Number(rating.serviceScore || 5);
const nextEnv = Number(rating.envScore || 5);
setServiceScore(
Number.isFinite(nextService) && nextService > 0 ? Math.min(5, Math.round(nextService)) : 5,
);
setEnvScore(Number.isFinite(nextEnv) && nextEnv > 0 ? Math.min(5, Math.round(nextEnv)) : 5);
setTags(Array.isArray(rating.tags) ? rating.tags : []);
setComment(String(rating.comment || ''));
setImageUrls(Array.isArray(rating.imageUrls) ? rating.imageUrls : []);
@@ -105,6 +111,7 @@ export default function RedeemSuccessPage() {
const id = String(options?.id || router.params.id || '').trim();
const from = String(options?.from || router.params.from || '');
setFromHistory(from === 'history');
setFromStore(from === 'store');
if (id) {
void loadRecord(id);
return;
@@ -138,7 +145,7 @@ export default function RedeemSuccessPage() {
function leave() {
clearCache();
const pages = Taro.getCurrentPages();
if (fromHistory && pages.length > 1) {
if ((fromHistory || fromStore) && pages.length > 1) {
Taro.navigateBack();
return;
}
@@ -187,8 +194,8 @@ export default function RedeemSuccessPage() {
method: 'POST',
data: {
redeemRecordId: record.id,
serviceScore: score,
envScore: score,
serviceScore,
envScore,
comment: comment.trim(),
tags,
imageUrls,
@@ -199,7 +206,7 @@ export default function RedeemSuccessPage() {
prev
? {
...prev,
rating: { serviceScore: score, envScore: score, comment, tags, imageUrls },
rating: { serviceScore, envScore, comment, tags, imageUrls },
}
: prev,
);
@@ -228,21 +235,39 @@ export default function RedeemSuccessPage() {
</View>
<View className="review-card">
<Text className="review-card-title">本次到店体验</Text>
<Text className="review-card-title">服务评分</Text>
<View className="review-star-row">
{[1, 2, 3, 4, 5].map((value) => (
<Text
key={value}
className={`review-star${value <= score ? ' review-star--active' : ''}`}
key={`service-${value}`}
className={`review-star${value <= serviceScore ? ' review-star--active' : ''}`}
onClick={() => {
if (!rated) setScore(value);
if (!rated) setServiceScore(value);
}}
>
★
</Text>
))}
</View>
<Text className="review-score-label">{SCORE_LABELS[score]}</Text>
<Text className="review-score-label">{SCORE_LABELS[serviceScore]}</Text>
</View>
<View className="review-card">
<Text className="review-card-title">环境评分</Text>
<View className="review-star-row">
{[1, 2, 3, 4, 5].map((value) => (
<Text
key={`env-${value}`}
className={`review-star${value <= envScore ? ' review-star--active' : ''}`}
onClick={() => {
if (!rated) setEnvScore(value);
}}
>
★
</Text>
))}
</View>
<Text className="review-score-label">{SCORE_LABELS[envScore]}</Text>
</View>
<View className="review-card">