修改bug

This commit is contained in:
zhouyanli
2026-08-04 11:56:12 +08:00
parent 5c8671a91e
commit 57756f016e
5 changed files with 45 additions and 20 deletions

View File

@@ -235,15 +235,19 @@
const getbannarData = async () => {
try {
const res = await getBannarList({ villageId: uni.getStorageSync('currentVillageId') })
if (res.code === 200) {
bannerRawData.value = res.data || []
const newList = (res.data || []).map(item => item.url)
if (res.code === 200 && Array.isArray(res.data)) {
bannerRawData.value = res.data
const newList = res.data.map(item => item.url).filter(url => typeof url === 'string' && url)
if (JSON.stringify(newList) !== JSON.stringify(bannerList.value)) {
bannerList.value = newList
await nextTick()
bannerSwiperKey.value++
saveHomeCache()
}
} else if (res.code === 200) {
bannerRawData.value = []
bannerList.value = []
bannerSwiperKey.value++
}
} catch (err) {
// 静默失败
@@ -260,18 +264,19 @@
const slelctHomeData = (data) => {
if (data.name) currentCommunity.value = data.name
if (data.villageId) currentVillageId.value = data.villageId
getCurrentCommunityData()
getNoticeData()
noticeKey.value++
getNewActivityList()
if (data.villageId) {
currentVillageId.value = data.villageId
uni.setStorageSync('currentVillageId', data.villageId)
}
// 标记需要刷新,回到首页后 onShow 会触发 refreshAllData
dataLoaded.value = false
}
const getCurrentCommunityData = () => {
getCurrentVillage().then(res => {
if (res.code === 200 && res.data && res.data.villageId) {
currentCommunity.value = res.data.villageName || '未命名小区'
saveHomeCache()
saveHomeCache()
currentVillageId.value = res.data.villageId
uni.setStorageSync('currentVillageId', res.data.villageId)
} else {
@@ -289,11 +294,11 @@
const getNoticeData = async () => {
try {
const res = await getNoticeLatest()
const res = await getNoticeLatest({ villageId: uni.getStorageSync('currentVillageId') })
if (res.code === 200) {
if (res.data) {
noticeText.value = res.data.noticeTitle || ''
noticeId.value = res.data.noticeId || ''; saveHomeCache()
noticeId.value = res.data.noticeId || ''
} else {
noticeText.value = '暂无公告'
noticeId.value = ''
@@ -303,6 +308,9 @@
noticeText.value = '暂无公告'
noticeId.value = ''
}
saveHomeCache()
await nextTick()
noticeKey.value++
}
const refreshAllData = async () => {
@@ -323,7 +331,6 @@
}
getCurrentCommunityData()
getNoticeData()
noticeKey.value++
getNewActivityList()
getbannarData()
pageReady.value = true