维修,意见反馈页面完善

This commit is contained in:
zjf committed 2025-06-30 19:59:50 +08:00
1 parent bc43f88e52
commit 2b22a30f85
4 files changed
+190 -121

No files matched your search

+75 -25
View File
@@ -72,8 +72,9 @@
</template>
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { ref, onMounted, computed, watch, nextTick } from 'vue'
import meetingRoomApi from '@/sheep/api/meetingRoom'
import { onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
const typeOptions = ref<{ value: string; label: string }[]>([])
const typeIndex = ref(0)
@@ -82,6 +83,10 @@ const description = ref('')
const contact = ref('')
const feedbackList = ref<any[]>([])
const activeTab = ref(0)
const page = ref(1)
const pageSize = 5
const hasMore = ref(true)
const loading = ref(false)
const canSubmit = computed(() => {
return title.value.trim() && description.value.trim()
@@ -92,7 +97,7 @@ async function loadTypeOptions() {
const res: any = await meetingRoomApi.getFeedbackType()
if (res.data && Array.isArray(res.data.data)) {
typeOptions.value = res.data.data.map(item => ({
value: item.id,
value: item.value,
label: item.label
}))
}
@@ -120,24 +125,16 @@ function getTypeClass(type: string) {
return classMap[type] || 'type-other'
}
function getStatusText(status: string) {
const statusMap: Record<string, string> = {
'1': '待处理',
'2': '处理中',
'3': '已处理',
'4': '已关闭'
}
return statusMap[status] || '未知'
function getStatusText(status: string | number) {
if (status === 1 || status === '1') return '已处理'
// 只要不是1都显示未处理
return '未处理'
}
function getStatusClass(status: string) {
const classMap: Record<string, string> = {
'1': 'status-pending',
'2': 'status-processing',
'3': 'status-completed',
'4': 'status-closed'
}
return classMap[status] || 'status-pending'
function getStatusClass(status: string | number) {
if (status === 1 || status === '1') return 'status-completed'
// 只要不是1都用未处理样式
return 'status-pending'
}
function formatTime(time: string) {
@@ -185,23 +182,76 @@ function viewDetail(item: any) {
})
}
async function loadFeedbackList() {
async function loadFeedbackList(isLoadMore = false, autoFill = false) {
if (loading.value || (!hasMore.value && isLoadMore)) return
loading.value = true
try {
const response: any = await meetingRoomApi.getFeedbackList({
current: 1,
size: 20
current: page.value,
size: pageSize
})
if (response.code === 0 && response.data) {
feedbackList.value = response.data.records || []
const records = response.data.records || []
if (isLoadMore) {
feedbackList.value = feedbackList.value.concat(records)
} else {
feedbackList.value = records
}
hasMore.value = records.length === pageSize
if (hasMore.value) page.value += 1
}
} finally {
loading.value = false
// H5端自动补齐:只有 autoFill=true 时才自动补齐
if (autoFill) {
await nextTick()
if (hasMore.value) {
const listDom = document.querySelector('.feedback-list')
if (listDom && listDom.scrollHeight <= window.innerHeight) {
await loadFeedbackList(true, true)
}
}
}
} catch (error) {
console.error('加载反馈列表失败:', error)
}
}
function refreshList() {
page.value = 1
hasMore.value = true
loadFeedbackList(false, true)
}
// 监听页面触底事件,下拉加载更多
onReachBottom(() => {
if (activeTab.value === 1) {
loadFeedbackList(true, false)
}
})
// 切换tab时重置分页并刷新
watch(activeTab, (val) => {
if (val === 1) {
refreshList()
}
})
onPullDownRefresh(() => {
if (activeTab.value === 1) {
page.value = 1
hasMore.value = true
loadFeedbackList(false, true).then(() => {
uni.stopPullDownRefresh()
})
} else {
uni.stopPullDownRefresh()
}
})
onMounted(() => {
loadTypeOptions().then(() => {
loadFeedbackList()
if (activeTab.value === 1) {
refreshList()
}
})
})
</script>