From d9a780fa538cb7a83aefa04e75cb53185d690d7d Mon Sep 17 00:00:00 2001
From: tj <1378534974@qq.com>
Date: 星期五, 30 五月 2025 16:39:07 +0800
Subject: [PATCH] 微封装

---
 pages/home/home.vue |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/pages/home/home.vue b/pages/home/home.vue
index 012b8ac..a4f2ad9 100644
--- a/pages/home/home.vue
+++ b/pages/home/home.vue
@@ -62,7 +62,6 @@
 import Community from './community.vue'
 import { SwiperChangeEvent } from '@dcloudio/uni-app'
 import { useGlobal } from '@/composables/useGlobal'
-import { number } from 'uview-plus/libs/function/test'
 const { $http, $message, $store } = useGlobal()
 import { FilmWorks } from '@/types/index'
 import { formatRelativeTime } from '@/utils/time'
@@ -86,14 +85,18 @@
 // 分页后的数组,每页3条
 const pagedTripCards = computed(() => {
   const pages: FilmWorks[][] = []
-  for (let i = 0; i < tripCardList.value.length; i += pageSize) {
-    pages.push(tripCardList.value.slice(i, i + pageSize))
+  const list = tripCardList.value || [] // 安全兜底
+  for (let i = 0; i < list.length; i += pageSize) {
+    pages.push(list.slice(i, i + pageSize))
   }
   return pages
 })
 
 // 总页数
-const totalPages = computed(() => Math.ceil(tripCardList.value.length / pageSize))
+const totalPages = computed(() => {
+  const list = tripCardList.value || [] // 安全兜底
+  return Math.ceil(list.length / pageSize)
+})
 
 // 场景博物馆卡片数据
 const cardList = ref([
@@ -160,8 +163,6 @@
 const communityPage = ref(1)
 const communitySize = 10
 const communityStatus = ref('loading')
-
-
 const getCommunitys = async () => {
   if (communityStatus.value === 'nomore') return
 
@@ -186,9 +187,6 @@
     communityStatus.value = 'noMore'
   }
 }
-const getCommunitys_bak = async () => {
-  communitys.value = await getFilmWorks(FilmWorksCategory.COMMUNITY, 10, 1);
-}
 // 内容精选
 const getFilmWorks = async (type: String, pageSize: Number, currentPage: Number) => {
   const {
@@ -206,7 +204,6 @@
     $message.showToast('系统异常,无法获取数据')
     return null;
   }
-
 }
 
 // 下一页

--
Gitblit v1.9.3