index.vue
7.72 KB
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<!--
* @Date: 2026-02-03
* @Description: 意见反馈列表页面
-->
<template>
<view class="min-h-screen bg-gray-50">
<NavHeader title="我的反馈" />
<scroll-view
scroll-y
class="feedback-scroll"
:style="{ height: scrollHeight + 'px' }"
@scrolltolower="onScrollToLower"
>
<view class="p-[32rpx] pb-[250rpx]">
<!-- Feedback List -->
<view v-if="loading" class="flex justify-center items-center py-[100rpx]">
<view class="loading-spinner"></view>
</view>
<view v-else-if="feedbackList.length === 0" class="flex flex-col items-center py-[100rpx]">
<text class="text-gray-400 text-[28rpx]">暂无反馈记录</text>
</view>
<view v-else class="space-y-[24rpx]">
<view
v-for="item in feedbackList"
:key="item.id"
class="bg-white rounded-[24rpx] p-[32rpx] shadow-sm"
>
<!-- Header: Type & Status -->
<view class="flex justify-between items-center mb-[20rpx]">
<view
class="px-[20rpx] py-[8rpx] rounded-full text-[24rpx]"
:class="getTypeClass(item.category)"
>
{{ getTypeLabel(item.category) }}
</view>
<view
class="px-[20rpx] py-[8rpx] rounded-full text-[24rpx]"
:class="item.status === 5 ? 'bg-green-100 text-green-600' : 'bg-orange-100 text-orange-600'"
>
{{ item.status === 5 ? '已处理' : '待处理' }}
</view>
</view>
<!-- Content -->
<view class="text-[28rpx] text-gray-900 mb-[20rpx] leading-relaxed">
{{ item.note }}
</view>
<!-- Images -->
<view v-if="item.images && item.images.length > 0" class="flex gap-[16rpx] mb-[20rpx]">
<image
v-for="(img, index) in item.images"
:key="index"
:src="img"
mode="aspectFill"
class="w-[120rpx] h-[120rpx] rounded-[12rpx]"
@tap="previewImage(item.images, index)"
/>
</view>
<!-- Contact -->
<view v-if="item.contact" class="text-[24rpx] text-gray-500 mb-[20rpx]">
联系方式:{{ item.contact }}
</view>
<!-- Reply Section -->
<view v-if="item.reply" class="bg-blue-50 rounded-[16rpx] p-[24rpx]">
<view class="text-[24rpx] text-gray-500 mb-[8rpx]">
客服回复:{{ item.reply_time || '' }}
</view>
<view class="text-[28rpx] text-gray-900 leading-relaxed">
{{ item.reply }}
</view>
</view>
</view>
</view>
<!-- Load More -->
<view v-if="hasMore && !loading" class="flex justify-center mt-[40rpx]">
<nut-button type="default" size="small" @click="loadMore">
加载更多
</nut-button>
</view>
</view>
</scroll-view>
<!-- Fixed Bottom Button -->
<view class="fixed bottom-0 left-0 right-0 p-[32rpx] bg-white border-t border-gray-200">
<nut-button type="primary" block class="!h-[88rpx] !rounded-[44rpx] !text-[32rpx]" @click="goToFeedback">
反馈意见
</nut-button>
</view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { useGo } from '@/hooks/useGo'
import NavHeader from '@/components/NavHeader.vue'
import Taro, { useDidShow } from '@tarojs/taro'
import { listAPI } from '@/api/feedback'
const go = useGo()
/** @type {import('vue').Ref<number>} 系统信息(用于计算滚动高度) */
const systemInfo = ref(null)
/** @type {import('vue').Ref<boolean>} 加载状态 */
const loading = ref(false)
/** @type {import('vue').Ref<Array>} 反馈列表 */
const feedbackList = ref([])
/** @type {import('vue').Ref<number>} 当前页码 */
const currentPage = ref(0)
/** @type {import('vue').Ref<number>} 每页数量 */
const pageSize = ref(10)
/** @type {import('vue').Ref<boolean>} 是否有更多数据 */
const hasMore = ref(true)
/** @type {import('vue').ComputedRef<number>} 滚动区域高度 */
const scrollHeight = computed(() => {
if (!systemInfo.value) return 500
// 导航栏高度 + 状态栏高度 + 底部按钮高度 + padding
const navBarHeight = 44 // 导航栏默认高度
const statusBarHeight = systemInfo.value.statusBarHeight || 0
const bottomHeight = 88 + 32 // 按钮高度 + padding
return systemInfo.value.windowHeight - bottomHeight
})
/**
* @description 获取反馈类型标签
* @param {string} category 类别值:1=功能建议, 3=问题反馈, 7=其他问题
* @returns {string} 类别标签
*/
const getTypeLabel = (category) => {
const map = {
'1': '功能建议',
'3': '问题反馈',
'7': '其他问题'
}
return map[category] || '其他'
}
/**
* @description 获取反馈类型样式类
* @param {string} category 类别值
* @returns {string} 样式类名
*/
const getTypeClass = (category) => {
const map = {
'1': 'bg-blue-100 text-blue-600',
'3': 'bg-red-100 text-red-600',
'7': 'bg-gray-100 text-gray-600'
}
return map[category] || 'bg-gray-100 text-gray-600'
}
/**
* @description 预览图片
* @param {Array<string>} urls 图片 URL 列表
* @param {number} current 当前图片索引
*/
const previewImage = (urls, current) => {
Taro.previewImage({
current: urls[current],
urls: urls
})
}
/**
* @description 加载反馈列表
* @param {boolean} isLoadMore 是否为加载更多
*/
const loadFeedbackList = async (isLoadMore = false) => {
if (loading.value) return
loading.value = true
try {
const res = await listAPI({
page: currentPage.value,
limit: pageSize.value
})
if (res.code === 1) {
const newList = res.data.list || []
if (isLoadMore) {
feedbackList.value.push(...newList)
} else {
feedbackList.value = newList
}
// 判断是否还有更多数据
hasMore.value = newList.length >= pageSize.value
} else {
Taro.showToast({ title: res.msg || '加载失败', icon: 'none' })
}
} catch (err) {
console.error('加载反馈列表失败:', err)
Taro.showToast({ title: '网络异常,请重试', icon: 'none' })
} finally {
loading.value = false
}
}
/**
* @description 加载更多
*/
const loadMore = () => {
if (!hasMore.value || loading.value) return
currentPage.value++
loadFeedbackList(true)
}
/**
* @description 滚动到底部时自动加载
*/
const onScrollToLower = () => {
if (hasMore.value && !loading.value) {
loadMore()
}
}
/**
* @description 跳转到反馈提交页面
*/
const goToFeedback = () => {
go('/pages/feedback/index')
}
/**
* @description 页面首次加载时获取系统信息
*/
onMounted(() => {
// 获取系统信息
Taro.getSystemInfo({
success: (res) => {
systemInfo.value = res
},
fail: () => {
// 使用默认值
systemInfo.value = {
windowHeight: 667,
statusBarHeight: 44
}
}
})
})
/**
* @description 页面显示时刷新列表(从提交页返回时也会触发)
*/
useDidShow(() => {
// 重置为第一页
currentPage.value = 0
feedbackList.value = []
// 加载反馈列表
loadFeedbackList()
})
</script>
<style lang="less">
.feedback-scroll {
box-sizing: border-box;
}
.space-y-\[24rpx\] > * + * {
margin-top: 24rpx;
}
.loading-spinner {
width: 40rpx;
height: 40rpx;
border: 4rpx solid #f3f3f3;
border-top: 4rpx solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>