更换banner组件,添加用户隐私协议链接

This commit is contained in:
zhouyanli
2026-06-26 10:07:44 +08:00
parent d0e80824d8
commit f19fb0d9d9
591 changed files with 79931 additions and 83 deletions

View File

@@ -39,30 +39,11 @@
<view class="scroll-content">
<!-- banner -->
<view class="bannarClass" v-if="bannerList && bannerList.length > 0">
<uni-swiper-dot
class="uni-swiper-dot-box"
@clickItem="clickItem"
:info="bannerList"
:current="current"
mode="default"
>
<swiper
class="swiper-box"
:key="bannerKey"
:current="current"
@change="onSwiperChange"
autoplay
circular
:interval="5000"
:duration="500"
>
<swiper-item v-for="(item, index) in bannerList" :key="item.id || item.url || index">
<view class="swiper-item">
<image :src="item.url" style="width: 100%; height: 100%"></image>
</view>
</swiper-item>
</swiper>
</uni-swiper-dot>
<up-swiper :list="bannerList" indicator indicatorMode="dot" radius="15" height="180" keyName="url">
<template #default="{ item, index }">
<image :src="item.url || item" mode="aspectFill" class="banner-img"></image>
</template>
</up-swiper>
</view>
<!-- 巡检 -->
@@ -164,7 +145,7 @@
</template>
<script setup>
import { ref, computed, watch } from 'vue'
import { ref } from 'vue'
import { onLoad, onUnload, onShow } from '@dcloudio/uni-app'
import {
getCurrentVillage,
@@ -174,7 +155,6 @@ import {
} from '../../api/api.js'
// 列表数据状态
const current = ref(0)
const currentCommunity = ref('请先绑定房屋')
const bannerList = ref([])
const noticeText = ref('暂无公告')
@@ -183,21 +163,6 @@ const pendingCount = ref(0) //待巡检
const InspectedCount = ref(0) //已巡检
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
// 用于强制重新创建 swiper,避免列表变化时内部节点复用导致 getBoundingClientRect 空指针
const bannerKey = computed(() => bannerList.value.map(item => item.id || item.url).join('_'))
// banner 数据变化时重置当前索引,防止 current 越界
watch(
() => bannerList.value,
newVal => {
if (!newVal || newVal.length === 0) {
current.value = 0
} else if (current.value >= newVal.length) {
current.value = 0
}
},
{ deep: true }
)
// =======方法=======
// 跳转小区
@@ -318,16 +283,13 @@ function getbannarData() {
const newData = res.data
const oldData = bannerList.value
if (JSON.stringify(newData) !== JSON.stringify(oldData)) {
current.value = 0
bannerList.value = newData
}
} else {
current.value = 0
bannerList.value = []
}
})
.catch(() => {
current.value = 0
bannerList.value = []
})
}
@@ -357,19 +319,6 @@ onUnload(() => {
uni.$off('confirm', slelctHomeData)
})
const clickItem = e => {
const idx = e.index !== undefined ? e.index : e
if (bannerList.value && idx >= 0 && idx < bannerList.value.length) {
current.value = idx
}
}
const onSwiperChange = e => {
const idx = e.detail.current
if (bannerList.value && idx >= 0 && idx < bannerList.value.length) {
current.value = idx
}
}
</script>
<style lang="scss" scoped>
@@ -483,20 +432,12 @@ const onSwiperChange = e => {
padding: 20rpx 0;
}
.swiper-box {
height: 300rpx;
border-radius: 16rpx !important;
overflow: hidden !important;
.banner-img {
width: 100%;
height: 100%;
border-radius: 15rpx;
}
.swiper-item {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 300rpx;
color: #fff;
}
.inspectionClass {
background: linear-gradient(to right, #7b87fa, #4d5dfa);