优化首页、访客可视滚动布局

This commit is contained in:
zhouyanli
2026-05-20 17:30:16 +08:00
parent b7d1037b35
commit 40c9e75b2e
6 changed files with 642 additions and 586 deletions

View File

@@ -1,160 +1,168 @@
<template>
<view class="content-class">
<!-- 顶部渐变背景层仅视觉不参与文档流 -->
<view class="nar-top"></view>
<!-- 这里是状态栏占位 -->
<view class="status_bar" :style="{ height: statusBarHeight + 'px' }"></view>
<!-- 导航栏 -->
<view class="nav-bar">
<text class="nav-title">首页</text>
</view>
<!-- 小区选择 -->
<view class="header-container" @click="navigateToPage">
<!-- 左侧小区选择区域 -->
<view class="location-area">
<!-- 定位图标 -->
<view class="location-icon">
<image src="https://wuyeadmin.bugtc.com/images/home/adress.png" style="height: 100%;width: 100%;"></image>
<!-- 固定头部 -->
<view class="header-fixed">
<view class="nar-top"></view>
<view class="header-content">
<!-- 状态栏占位 -->
<view class="status_bar" :style="{ height: statusBarHeight + 'px' }"></view>
<!-- 导航栏 -->
<view class="nav-bar">
<text class="nav-title">首页</text>
</view>
<!-- 小区名称和下拉箭头 -->
<view class="community-selector">
<text class="community-name">{{ currentCommunity }}</text>
<u-icon
name="arrow-down-fill"
size="16"
:color="isDropdownOpen ? '#2979ff' : '#222222'"
:class="['dropdown-arrow', { 'rotate': isDropdownOpen }]"
></u-icon>
<!-- 小区选择 -->
<view class="header-container" @click="navigateToPage">
<!-- 左侧小区选择区域 -->
<view class="location-area">
<!-- 定位图标 -->
<view class="location-icon">
<image src="https://wuyeadmin.bugtc.com/images/home/adress.png" style="height: 100%;width: 100%;"></image>
</view>
<!-- 小区名称和下拉箭头 -->
<view class="community-selector">
<text class="community-name">{{ currentCommunity }}</text>
<u-icon
name="arrow-down-fill"
size="16"
:color="isDropdownOpen ? '#2979ff' : '#222222'"
:class="['dropdown-arrow', { 'rotate': isDropdownOpen }]"
></u-icon>
</view>
</view>
</view>
</view>
</view>
<!-- banner -->
<view class="bannarClass">
<up-swiper :list="bannerList" indicator indicatorMode="dot" ></up-swiper>
</view>
<view class="noticeClass" @click="getNoticeMore">
<uni-notice-bar show-icon :text="noticeText" type="line"
show-get-more scrollable color="#000" background-color="#fff" moreColor="#000">
<template #noticebarIcon>
<image src="https://wuyeadmin.bugtc.com/images/home/notice.png" style="width: 38px;height: 38px;"></image>
</template>
</uni-notice-bar>
</view>
<!-- 一键开门 -->
<view class="u-demo-block__content bg-card-open">
<up-row justify="space-between" gutter="10">
<up-col span="3">
<view class="demo-layout bg-purple openClass" @click="openDoorClick">
<!-- 滚动内容区 -->
<scroll-view class="main-scroll" scroll-y>
<!-- banner -->
<view class="bannarClass">
<up-swiper :list="bannerList" indicator indicatorMode="dot" ></up-swiper>
</view>
<!-- 公告 -->
<view class="noticeClass" @click="getNoticeMore">
<uni-notice-bar show-icon :text="noticeText" type="line"
show-get-more scrollable color="#000" background-color="#fff" moreColor="#000">
<template #noticebarIcon>
<image src="https://wuyeadmin.bugtc.com/images/home/notice.png" style="width: 38px;height: 38px;"></image>
</template>
</uni-notice-bar>
</view>
<!-- 一键开门 -->
<view class="u-demo-block__content bg-card-open">
<up-row justify="space-between" gutter="10">
<up-col span="3">
<view class="demo-layout bg-purple openClass" @click="openDoorClick">
<view class="iconClass">
<image src="https://wuyeadmin.bugtc.com/images/home/openDoor.png" class="iconClass-img"></image>
<image src="https://wuyeadmin.bugtc.com/images/home/openDoor.png" class="iconClass-img"></image>
</view>
<view class="title-dome-calss">一键开门</view>
</view>
</up-col>
<up-col span="3">
<view class="demo-layout bg-purple-light openClass" @click="payMentClick">
</up-col>
<up-col span="3">
<view class="demo-layout bg-purple-light openClass" @click="payMentClick">
<view class="iconClass">
<image src="https://wuyeadmin.bugtc.com/images/home/lifePay.png" class="iconClass-img"></image>
<image src="https://wuyeadmin.bugtc.com/images/home/lifePay.png" class="iconClass-img"></image>
</view>
<view class="title-dome-calss">生活缴费</view>
<view class="title-dome-calss">生活缴费</view>
</view>
</up-col>
<up-col span="3">
<view class="demo-layout bg-purple openClass" @click="onlineRepairClick">
</up-col>
<up-col span="3">
<view class="demo-layout bg-purple openClass" @click="onlineRepairClick">
<view class="iconClass">
<image src="https://wuyeadmin.bugtc.com/images/home/repair.png" class="iconClass-img"></image>
<image src="https://wuyeadmin.bugtc.com/images/home/repair.png" class="iconClass-img"></image>
</view>
<view class="title-dome-calss">在线报修</view>
<view class="title-dome-calss">在线报修</view>
</view>
</up-col>
<up-col span="3">
<view class="demo-layout bg-purple-light openClass" @click="visitorClick">
</up-col>
<up-col span="3">
<view class="demo-layout bg-purple-light openClass" @click="visitorClick">
<view class="iconClass">
<image src="https://wuyeadmin.bugtc.com/images/home/visitorInvite.png" class="iconClass-img"></image>
<image src="https://wuyeadmin.bugtc.com/images/home/visitorInvite.png" class="iconClass-img"></image>
</view>
<view class="title-dome-calss">访客邀请</view>
<view class="title-dome-calss">访客邀请</view>
</view>
</up-col>
</up-row>
</view>
<!-- 广告卡片 -->
<view class="adCardClass">
<!-- <uni-card :is-shadow="false" > -->
<view class="u-demo-block__content">
<up-row justify="space-between" customStyle="margin-bottom: 10px">
<up-col span="3">
<view class="demo-layout bg-purple iconRightClass">
<image src="https://wuyeadmin.bugtc.com/images/home/ad1.png" mode="" style="width: 100%;height: 100%;"></image>
</view>
</up-col>
<up-col span="8">
<view class="demo-layout bg-purple-light titleLeft">
<text style="color: #fff;font-size: 40rpx;font-weight: 700;">便民服务</text>
<view style="color: #fff;font-size: 28rpx;">邻里便民服务 全新上线</view>
</view>
</up-col>
</up-row>
</view>
<!-- </uni-card> -->
</view>
<!-- 活动列表 -->
<uni-card class="activity-card">
<view class="eventListClass">
<view>
<text class="activity-name">活动列表</text>
<!-- <u-title>活动列表</u-title> -->
</view>
<view class="nav-more">
<!-- <up-button type="primary" shape="circle" size="small" text="查看更多" @click="moreClick"></up-button> -->
<text class="look-more-title" @click="moreClick">查看更多</text>
</view>
</view>
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y">
<view class="eventListCard" v-for="(activity, index) in activityList" :key="activity.id">
<!-- 状态标签 -->
<view class="status-tag" :class="{}">
{{ activity.statusText }}
<!-- 进行中 -->
</view>
<view class="u-demo-block__content ">
</up-col>
</up-row>
</view>
<!-- 广告卡片 -->
<view class="adCardClass">
<!-- <uni-card :is-shadow="false" > -->
<view class="u-demo-block__content">
<up-row justify="space-between" customStyle="margin-bottom: 10px">
<up-col span="4">
<view class="demo-layout bg-purple-light activity-img">
<image :src="activity.coverImage" style="width: 100%;height: 100%;"></image>
<up-col span="3">
<view class="demo-layout bg-purple iconRightClass">
<image src="https://wuyeadmin.bugtc.com/images/home/ad1.png" mode="" style="width: 100%;height: 100%;"></image>
</view>
</up-col>
</up-col>
<up-col span="8">
<view class="demo-layout bg-purple activity-info">
<view class="activity-title">{{activity.title}}</view>
<view class="activity-time">{{formatDate(activity.startTime)}}-{{formatDate(activity.endTime)}}</view>
<view class="activity-organizer">
<text>{{activity.createName}}</text>
</view>
<view class="activity-enrollment">
<text>活动名额{{activity.quota}}已报名{{activity.appliedCount}}</text>
</view>
<view class="demo-layout bg-purple-light titleLeft">
<text style="color: #fff;font-size: 40rpx;font-weight: 700;">便民服务</text>
<view style="color: #fff;font-size: 28rpx;">邻里便民服务 全新上线</view>
</view>
</up-col>
</up-row>
</view>
</view>
</scroll-view>
<!-- 空状态 -->
<view v-if="activityList.length === 0" class="empty-state">
<uni-icons type="info" size="30" color="#ccc"></uni-icons>
<text class="empty-text">暂无数据</text>
</view>
</uni-card>
<!-- </uni-card> -->
</view>
<!-- 活动列表 -->
<uni-card class="activity-card">
<view class="eventListClass">
<view>
<text class="activity-name">活动列表</text>
<!-- <u-title>活动列表</u-title> -->
</view>
<view class="nav-more">
<!-- <up-button type="primary" shape="circle" size="small" text="查看更多" @click="moreClick"></up-button> -->
<text class="look-more-title" @click="moreClick">查看更多</text>
</view>
</view>
<!-- 活动列表内容去掉内层 scroll-view由外层统一滚动 -->
<view class="activity-list">
<view class="eventListCard" v-for="(activity, index) in activityList" :key="activity.id">
<!-- 状态标签 -->
<view class="status-tag" :class="{}">
{{ activity.statusText }}
<!-- 进行中 -->
</view>
<view class="u-demo-block__content ">
<up-row justify="space-between" customStyle="margin-bottom: 10px">
<up-col span="4">
<view class="demo-layout bg-purple-light activity-img">
<image :src="activity.coverImage" style="width: 100%;height: 100%;"></image>
</view>
</up-col>
<up-col span="8">
<view class="demo-layout bg-purple activity-info">
<view class="activity-title">{{activity.title}}</view>
<view class="activity-time">{{formatDate(activity.startTime)}}-{{formatDate(activity.endTime)}}</view>
<view class="activity-organizer">
<text>{{activity.createName}}</text>
</view>
<view class="activity-enrollment">
<text>活动名额{{activity.quota}}已报名{{activity.appliedCount}}</text>
</view>
</view>
</up-col>
</up-row>
</view>
</view>
</view>
<!-- 空状态 -->
<view v-if="activityList.length === 0" class="empty-state">
<uni-icons type="info" size="30" color="#ccc"></uni-icons>
<text class="empty-text">暂无数据</text>
</view>
</uni-card>
<!-- 底部占位 -->
<view class="scroll-bottom-space"></view>
</scroll-view>
</view>
</template>
@@ -172,12 +180,12 @@ const scrollTop = ref(0)
const activityList = ref([]) // 活动列表数据
const currentCommunity = ref('请认证小区')
const currentVillageId = ref('')
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
const statusBarHeight = ref(0)
const bannerList = ref([
// 'http://47.104.199.163:9090/images/home/banner.png',
// "http://47.104.199.163:9090/images/propertyImgs/serviceImg2.png"
])
])
const noticeText = ref('暂无公告')
const noticeId = ref('')
@@ -212,11 +220,11 @@ const getbannarData = async () =>{
const slelctHomeData = (data) =>{
// console.log('收到B页面返回的数据', data)
if(data.name){
currentCommunity.value = data.name
currentCommunity.value = data.name
}
if(data.villageId){
currentVillageId.value = data.villageId
}
currentVillageId.value = data.villageId
}
getCurrentCommunityData()
getNoticeData()
getNewActivityList()
@@ -239,7 +247,7 @@ const getCurrentCommunityData = () => {
});
})
}
// 获取首页最新小区公告
const getNoticeData = async() =>{
@@ -253,7 +261,7 @@ const getNoticeData = async() =>{
noticeText.value = '暂无公告'
noticeId.value = ''
}
} else {
uni.showToast({
title: res.msg || '获取通知失败',
@@ -274,19 +282,22 @@ const getNoticeData = async() =>{
onShow(() =>{
})
onLoad(() => {
// 绑定全局事件监听
const info = uni.getSystemInfoSync()
statusBarHeight.value = info.statusBarHeight || 0
// 绑定全局事件监听
uni.$on('confirm', slelctHomeData)
// 页面加载时先判断是否有token有则获取认证小区
const token = uni.getStorageSync('token') || '';
const currentVillageId = uni.getStorageSync('currentVillageId');
if (token && currentVillageId && currentVillageId !== '0' && currentVillageId !== 0) {
getCurrentCommunityData(); // 加载时获取认证小区
}
getNoticeData()
getNoticeData()
getNewActivityList()
getbannarData()
})
@@ -334,7 +345,7 @@ const navigateToPage = () => {
url: `/pageSubPack/notice-list/selectHome?villageId=${cachedVillageId}`
});
}
};
};
// 获取首页最新活动
const getNewActivityList = async() =>{
try{
@@ -391,248 +402,270 @@ const moreClick = () =>{
<style lang="scss" scoped>
.content-class{
background-color: #f9f9f9;
padding-bottom: 40rpx;
box-sizing: border-box; /* 保证padding不会撑大容器 */
min-height: 100vh;
overflow-y: auto;
position: relative;
.nar-top{
height: 400rpx;
width: 100%;
background: repeating-linear-gradient(to right, #EDF4FA , #C0E4FB);
position: absolute;
top: 0;
left: 0;
z-index: 0;
}
.status_bar {
width: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
/* 固定头部 */
.header-fixed {
position: relative;
flex-shrink: 0;
position: relative;
z-index: 1;
}
/* 导航栏 */
.nav-bar {
height: 44px;
line-height: 44px;
text-align: center;
position: relative;
z-index: 1;
}
.nav-title {
font-size: 32rpx;
font-weight: 500;
}
.header-container{
display: flex;
align-items: center;
justify-content: space-between;
padding: 4rpx 30rpx;
box-sizing: border-box;
// border-bottom: 1rpx solid #f0f0f0;
position: relative;
z-index: 10;
}
// 左侧区域
.location-area {
display: flex;
align-items: center;
position: relative;
flex: 1;
min-width: 0;
.location-icon {
width: 45rpx;
height: 45rpx;
margin-right: 12rpx;
flex-shrink: 0;
}
.community-selector {
display: flex;
align-items: center;
max-width: 300rpx;
cursor: pointer;
.community-name {
font-size: 26rpx;
font-weight: 500;
color: #000;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 200rpx;
}
}
}
.bannarClass{
position: relative;
padding: 20rpx 40rpx;
// margin-bottom: 20rpx;
height: 300rpx;
::v-deep .u-swiper{
height: 300rpx !important;
}
::v-deep .u-swiper__wrapper{
height: 300rpx !important;
}
::v-deep .u-swiper__wrapper__item__wrapper__image{
height: 300rpx !important;
}
}
.noticeClass{
padding: 0rpx 36rpx;
margin-bottom: 20rpx;
}
// 修改通知栏样式
::v-deep .uni-noticebar__content-wrapper--scrollable{
margin-right: 20px;
}
::v-deep .uni-noticebar{
padding: 4px 12px;
}
.notice-bar::after {
color: #3E8EFF;
}
.bg-card-open{
padding: 20rpx;
background-color: #fff;
border-radius: 8rpx;
margin: 0 18px 20rpx;
}
.openClass{
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20rpx;
.iconClass{
width: 88rpx;
height: 88rpx;
border-radius: 10rpx;
// opacity: 0.4;
}
.iconClass-img{
.nar-top{
height: 400rpx;
width: 100%;
height: 100%;
border-radius: 8px
background: repeating-linear-gradient(to right, #EDF4FA , #C0E4FB);
position: absolute;
top: 0;
left: 0;
z-index: 0;
}
.title-dome-calss{
margin-top: 10rpx;
font-size: 28rpx;
color: #000;
.header-content {
position: relative;
z-index: 1;
}
}
.adCardClass{
// width: 100%;
height: 200rpx;
margin: 0 30rpx 20rpx;
background-color: #3E8EFF;
// margin-top: 30rpx;
border-radius: 28rpx;
.titleLeft{
text-align: left;
line-height: 2;
// margin-top: 32rpx;
// margin-left: 30rpx;
}
.iconRightClass{
width: 120rpx;
height: 120rpx;
border-radius: 50%;
// margin-top: 20rpx;
margin: 36rpx;
}
/* 滚动区域 */
.main-scroll {
flex: 1;
min-height: 0;
overflow: hidden;
position: relative;
z-index: 1;
}
.activity-card{
}
.uni-card{
margin: 0 18px 20rpx !important;
.scroll-bottom-space {
height: 40rpx;
}
.eventListClass{
margin: 10rpx 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.activity-name{
font-size: 32rpx;
font-weight: 600;
color: #222;
}
.eventListCard{
// min-height:200rpx ;
position: relative;
margin: 30rpx 0rpx;
// overflow: hidden;
.status-tag {
position: absolute;
top: 0;
left: 0;
// padding: 6px 18px;
padding: 0px 7px 10px 11px;
border-radius: 10px 0px 10px 0px;
font-size: 12px;
color: #fff;
font-weight: 500;
width: 80rpx;
height: 20rpx;
// background-color: #FD7373 ;
background: repeating-linear-gradient(to right, #FD7373 , #FB3F3F);
}
.activity-img{
width: 170rpx;
height: 230rpx;
// background-color: #333333;
}
.activity-title{
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 12px;
line-height: 1.4;
}
.activity-time{
display: flex;
align-items: center;
font-size: 22rpx;
color: #999999;
margin-bottom: 8px;
}
.activity-organizer{
font-size: 28rpx;
display: flex;
align-items: center;
color: #999999;
margin-bottom: 8px;
}
.activity-enrollment{
display: flex;
align-items: center;
font-size: 28rpx;
margin-top: 20rpx;
color: #666666;
}
}
.empty-state {
.status_bar {
width: 100%;
flex-shrink: 0;
position: relative;
z-index: 1;
}
/* 导航栏 */
.nav-bar {
height: 44px;
line-height: 44px;
text-align: center;
position: relative;
z-index: 1;
}
.nav-title {
font-size: 32rpx;
font-weight: 500;
}
.header-container{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 0;
justify-content: space-between;
padding: 4rpx 30rpx;
box-sizing: border-box;
// border-bottom: 1rpx solid #f0f0f0;
position: relative;
z-index: 10;
}
// 左侧区域
.location-area {
display: flex;
align-items: center;
position: relative;
flex: 1;
min-width: 0;
.location-icon {
width: 45rpx;
height: 45rpx;
margin-right: 12rpx;
flex-shrink: 0;
}
.community-selector {
display: flex;
align-items: center;
max-width: 300rpx;
cursor: pointer;
.community-name {
font-size: 26rpx;
font-weight: 500;
color: #000;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 200rpx;
}
}
}
.bannarClass{
position: relative;
padding: 20rpx 40rpx;
// margin-bottom: 20rpx;
height: 300rpx;
::v-deep .u-swiper{
height: 300rpx !important;
}
.empty-text {
font-size: 32rpx;
color: #999;
margin-top: 20rpx;
margin-bottom: 10rpx;
::v-deep .u-swiper__wrapper{
height: 300rpx !important;
}
.look-more-title{
color: #3E8EFF;
::v-deep .u-swiper__wrapper__item__wrapper__image{
height: 300rpx !important;
}
}
.noticeClass{
padding: 0rpx 36rpx;
margin-bottom: 20rpx;
}
// 修改通知栏样式
::v-deep .uni-noticebar__content-wrapper--scrollable{
margin-right: 20px;
}
::v-deep .uni-noticebar{
padding: 4px 12px;
}
.notice-bar::after {
color: #3E8EFF;
}
.bg-card-open{
padding: 20rpx;
background-color: #fff;
border-radius: 8rpx;
margin: 0 18px 20rpx;
}
.openClass{
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20rpx;
.iconClass{
width: 88rpx;
height: 88rpx;
border-radius: 10rpx;
// opacity: 0.4;
}
.iconClass-img{
width: 100%;
height: 100%;
border-radius: 8px
}
.title-dome-calss{
margin-top: 10rpx;
font-size: 28rpx;
color: #000;
}
}
.adCardClass{
// width: 100%;
height: 200rpx;
margin: 0 30rpx 20rpx;
background-color: #3E8EFF;
// margin-top: 30rpx;
border-radius: 28rpx;
.titleLeft{
text-align: left;
line-height: 2;
// margin-top: 32rpx;
// margin-left: 30rpx;
}
.iconRightClass{
width: 120rpx;
height: 120rpx;
border-radius: 50%;
// margin-top: 20rpx;
margin: 36rpx;
}
}
.activity-card{
}
.uni-card{
margin: 0 18px 20rpx !important;
}
.eventListClass{
margin: 10rpx 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.activity-name{
font-size: 32rpx;
font-weight: 600;
color: #222;
}
.eventListCard{
// min-height:200rpx ;
position: relative;
margin: 30rpx 0rpx;
// overflow: hidden;
.status-tag {
position: absolute;
top: 0;
left: 0;
// padding: 6px 18px;
padding: 0px 7px 10px 11px;
border-radius: 10px 0px 10px 0px;
font-size: 12px;
color: #fff;
font-weight: 500;
width: 80rpx;
height: 20rpx;
// background-color: #FD7373 ;
background: repeating-linear-gradient(to right, #FD7373 , #FB3F3F);
}
.activity-img{
width: 170rpx;
height: 230rpx;
// background-color: #333333;
}
.activity-title{
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 12px;
line-height: 1.4;
}
.activity-time{
display: flex;
align-items: center;
font-size: 22rpx;
color: #999999;
margin-bottom: 8px;
}
.activity-organizer{
font-size: 28rpx;
display: flex;
align-items: center;
color: #999999;
margin-bottom: 8px;
}
.activity-enrollment{
display: flex;
align-items: center;
font-size: 28rpx;
margin-top: 20rpx;
color: #666666;
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 0;
}
.empty-text {
font-size: 32rpx;
color: #999;
margin-top: 20rpx;
margin-bottom: 10rpx;
}
.look-more-title{
color: #3E8EFF;
font-size: 28rpx;
}
}
</style>