liujie
2026-09-11 4f6f15b818704079ff2e4e4719b798f48d68a335
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<template>
  <view class="rating-page" :class="{ leaving: isLeaving }">
    <guide-nav-bar title="我的评分" @back="goBack" />
 
    <view class="score-summary">
      <text class="summary-label">综合评分:</text>
      <text class="summary-stars">{{ starText(summaryScore) }}</text>
      <text class="summary-score">{{ summaryScoreText }}</text>
    </view>
 
    <picker mode="date" :value="selectedDate" @change="changeDate">
      <view class="date-filter">
        <text>筛选日期</text>
        <image class="calendar-icon" src="/static/icons/calendar-days.svg" mode="aspectFit" />
      </view>
    </picker>
 
    <scroll-view class="rating-list" scroll-y>
      <view v-for="item in reviews" :key="item.id" class="review-row" :class="{ 'with-images': item.images.length }">
        <view class="review-head">
          <text class="review-date">{{ item.date }}</text>
          <text class="review-stars">{{ starText(item.score) }}</text>
        </view>
        <view class="review-comment">{{ item.comment }}</view>
        <view v-if="item.images.length" class="image-list">
          <view
            v-for="(image, index) in item.images"
            :key="`${item.id}_${index}`"
            class="review-image-wrap"
            @tap="previewImages(item.images, index)"
          >
            <image class="review-image" :src="image" mode="aspectFill" />
          </view>
        </view>
      </view>
      <view v-if="!loading && !reviews.length" class="empty-state">
        {{ selectedDate ? '该日期暂无评价' : '暂无评价' }}
      </view>
    </scroll-view>
  </view>
</template>
 
<script>
import GuideNavBar from '../../components/guide-nav-bar/guide-nav-bar.vue'
import { getGuideRatings, normalizeRatingImages, resolveRatingImageUrl } from '../../services/rating'
import { formatRatingStars } from '../../utils/rating'
import { backOrHome } from '../../utils/router'
 
export default {
  components: {
    GuideNavBar
  },
  data() {
    return {
      selectedDate: '',
      isLeaving: false,
      summaryScore: 0,
      reviews: [],
      loading: false
    }
  },
  computed: {
    summaryScoreText() {
      return Number(this.summaryScore || 0).toFixed(1)
    }
  },
  onLoad() {
    this.loadRatings()
  },
  methods: {
    loadRatings() {
      this.loading = true
      return getGuideRatings({ date: this.selectedDate })
        .then((data) => {
          this.summaryScore = Number(data.score || 0)
          this.reviews = (data.rows || []).map((item) => ({
            id: item.id,
            date: item.dateText || '',
            score: Number(item.score || 0),
            comment: item.comment || '游客未填写评价内容',
            images: normalizeRatingImages(item).map(resolveRatingImageUrl)
          }))
        })
        .catch((error) => {
          uni.showToast({ title: error.message || '评分加载失败', icon: 'none' })
        })
        .finally(() => {
          this.loading = false
        })
    },
    starText(score) {
      return formatRatingStars(score)
    },
    goBack() {
      if (this.isLeaving) {
        return
      }
      this.isLeaving = true
      setTimeout(() => {
        backOrHome()
      }, 280)
    },
    changeDate(event) {
      this.selectedDate = event.detail.value
      this.loadRatings()
    },
    previewImages(images, index) {
      uni.previewImage({
        current: images[index],
        urls: images
      })
    }
  }
}
</script>
 
<style>
.rating-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #ffffff;
  animation: pageSlideIn 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
  will-change: transform, opacity;
}
 
.rating-page.leaving {
  animation: pageSlideOut 280ms cubic-bezier(0.4, 0, 1, 1) both;
}
 
@keyframes pageSlideIn {
  from {
    opacity: 0.35;
    transform: translateX(72rpx);
  }
 
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
 
@keyframes pageSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
 
  to {
    opacity: 0.2;
    transform: translateX(260rpx);
  }
}
 
.score-summary {
  display: flex;
  align-items: center;
  height: 174rpx;
  padding: 0 78rpx;
  border-bottom: 1rpx solid #d9d9d9;
  background: #ffffff;
}
 
.summary-label {
  color: #0f172a;
  font-size: 27rpx;
  font-weight: 600;
}
 
.summary-stars {
  margin-left: 8rpx;
  color: #ffbf00;
  font-size: 31rpx;
  letter-spacing: 4rpx;
  line-height: 1;
}
 
.summary-score {
  margin-left: 22rpx;
  color: #0f172a;
  font-size: 27rpx;
}
 
.date-filter {
  display: flex;
  align-items: center;
  height: 84rpx;
  padding: 0 78rpx;
  border-bottom: 1rpx solid #d9d9d9;
  color: #0f172a;
  font-size: 27rpx;
  font-weight: 600;
}
 
.calendar-icon {
  width: 30rpx;
  height: 30rpx;
  margin-left: 10rpx;
}
 
.rating-list {
  flex: 1;
  min-height: 0;
  background: #ffffff;
}
 
.review-row {
  margin-left: 78rpx;
  padding: 42rpx 24rpx 32rpx 0;
  border-bottom: 1rpx solid #d9d9d9;
}
 
.review-row.with-images {
  padding-bottom: 40rpx;
}
 
.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
 
.review-date {
  color: #0f172a;
  font-size: 27rpx;
  font-weight: 600;
}
 
.review-stars {
  color: #ffbf00;
  font-size: 31rpx;
  letter-spacing: 5rpx;
  line-height: 1;
}
 
.review-comment {
  margin-top: 24rpx;
  color: #0f172a;
  font-size: 27rpx;
  line-height: 1.3;
}
 
.image-list {
  display: flex;
  gap: 32rpx;
  margin-top: 32rpx;
}
 
.review-image-wrap {
  width: 170rpx;
  height: 126rpx;
  overflow: hidden;
  background: #e6e6e6;
}
 
.review-image {
  width: 100%;
  height: 100%;
}
 
.empty-state {
  padding: 96rpx 32rpx;
  color: #94a3b8;
  font-size: 27rpx;
  text-align: center;
}
</style>