This commit is contained in:
zjf committed 2025-09-13 00:43:44 +08:00
1 parent 335eb0d77a
commit d44a48d42b
1 file changed
+89 -7
+89 -7
View File
@@ -12,8 +12,25 @@
<text class="date-arrow">▼</text>
</view>
<!-- 加载状态 -->
<view v-if="loading" class="loading-container">
<text class="loading-text">加载中...</text>
</view>
<!-- 错误状态 -->
<view v-else-if="error" class="error-container">
<text class="error-text">{{ error }}</text>
<view class="retry-btn" @tap="fetchMeetingRooms">重试</view>
</view>
<!-- 空状态 -->
<view v-else-if="meetingRooms.length === 0" class="empty-container">
<text class="empty-text">暂无会议室</text>
</view>
<!-- 会议室列表 -->
<view v-for="room in meetingRooms" :key="room.id" class="room-card" @tap="goDetail(room)">
<view v-else>
<view v-for="room in meetingRooms" :key="room.id" class="room-card" @tap="goDetail(room)">
<view class="room-info">
<view class="room-main">
<view class="room-title">
@@ -26,7 +43,7 @@
</text>
</view>
</view>
<image :src="room.picUrl || '/static/meeting/default.jpg'" class="room-img" mode="aspectFill"></image>
<image :src="room.picUrl || '/static/icon/service_4.png'" class="room-img" mode="aspectFill"></image>
</view>
<!-- 时间条 -->
<view class="timeline-bar">
@@ -36,6 +53,7 @@
<text v-for="h in 17" :key="h" class="timeline-label">{{ h + 7 }}</text>
</view>
</view>
</view>
</view>
<MeetingTabbar activeTab="home" />
</template>
@@ -51,6 +69,8 @@ const goBack = () => {
const todayText = ref("")
const meetingRooms = ref<any[]>([])
const loading = ref(false)
const error = ref("")
onMounted(() => {
todayText.value = getTodayText()
@@ -63,12 +83,26 @@ function getTodayText() {
return `${d.getMonth() + 1}月${d.getDate()}日 周${week[d.getDay()]}`
}
function fetchMeetingRooms() {
meetingRoomApi.getMeetingRoomList({ current: 1, size: 10 }).then((res: any) => {
async function fetchMeetingRooms() {
loading.value = true
error.value = ""
try {
console.log('开始获取会议室列表...')
const res: any = await meetingRoomApi.getMeetingRoomList({ current: 1, size: 10 })
console.log('会议室列表API响应:', res)
if (res.code === 0) {
meetingRooms.value = res.data.records
meetingRooms.value = res.data.records || []
console.log('会议室列表数据:', meetingRooms.value)
} else {
error.value = res.msg || '获取会议室列表失败'
console.error('获取会议室列表失败:', res.msg)
}
})
} catch (err) {
error.value = '网络请求失败'
console.error('获取会议室列表异常:', err)
} finally {
loading.value = false
}
}
function goDetail(room) {
@@ -86,7 +120,7 @@ function goDetail(room) {
</script>
<style lang="less" scoped>
@import url("//at.alicdn.com/t/font_1234567_lingdang.css"); /* 替换为你的iconfont地址 */
/* 移除外部CSS引用,使用本地图标或内联样式 */
.container {
min-height: 100vh;
background: #f5f6fa;
@@ -231,4 +265,52 @@ function goDetail(room) {
color: #bbb;
font-size: 20rpx;
}
/* 加载状态样式 */
.loading-container {
display: flex;
justify-content: center;
align-items: center;
padding: 80rpx 0;
}
.loading-text {
color: #666;
font-size: 28rpx;
}
/* 错误状态样式 */
.error-container {
display: flex;
flex-direction: column;
align-items: center;
padding: 80rpx 32rpx;
}
.error-text {
color: #f44336;
font-size: 28rpx;
margin-bottom: 24rpx;
}
.retry-btn {
background: #1976d2;
color: #fff;
padding: 16rpx 32rpx;
border-radius: 8rpx;
font-size: 26rpx;
}
/* 空状态样式 */
.empty-container {
display: flex;
justify-content: center;
align-items: center;
padding: 80rpx 0;
}
.empty-text {
color: #999;
font-size: 28rpx;
}
</style>