<template>
	<view class="contentStyle" style="">
		<view class="status-bar"></view>
		<uni-nav-bar title="服务" backgroundColor="transparent" :border="false">
		</uni-nav-bar>
		<!-- 表单区域 -->
		<scroll-view class="page" scroll-y>
			<view class="container">
				<!-- 顶部 Banner 轮播 -->
				<view class="banner-box" style="overflow-y: hidden;">
					<image class="banner-img" src="https://wuye.ckdzkj.com/images/propertyImgs/serviceImg2.png" @tap="bannnerClick"/>
				</view>

				<!-- 常用功能区 -->
				<view class="func-section">
					<view class="section-title">
						<text class="title-text">常用功能</text>
					</view>
					<view class="func-grid">
						<view class="func-item" v-for="(item, index) in commonFuncList" :key="index"
							@click="handleFuncClick(item)">
							<view class="func-icon"
								:style="{'background-image': 'url(' + (item.icon) + ')', 'background-repeat': 'no-repeat','background-size': '100% 100%','background-position': 'center',}">
								<!-- <image :src="item.icon" mode="aspectFit"></image> -->
							</view>
							<text class="func-name">{{ item.name }}</text>
						</view>
					</view>
				</view>

				<!-- 智慧社区功能区 -->
				<view class="func-section" style="margin-bottom: 0px;">
					<view class="section-title">
						<text class="title-text">智慧社区</text>
					</view>
					<view class="func-grid community-grid">
						<view class="func-item" v-for="(item, index) in communityFuncList" :key="index"
							@click="handleFuncClick(item)">
							<view class="func-icon">
								<image :src="item.icon" mode="aspectFit"></image>
							</view>
							<text class="func-name">{{ item.name }}</text>
						</view>
					</view>
				</view>
			</view>
			<view style="width: 100%;height: 20rpx;"></view>
		</scroll-view>

	</view>



</template>
<script setup>
	import {
		ref
	} from 'vue';


	const commonFuncList = ref([{
			name: "一键开门",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-door.png",
			path: "/pageSubPack/notice-list/oneClickOpen"
		},
		{
			name: "生活缴费",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-pay.png",
			path: "/pageSubPack/payment-list/paymentIndex"
		},
		{
			name: "在线报修",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-repair.png",
			path: "/pageSubPack/online-repair/onlineRepair"
		},
		{
			name: "访客邀请",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-visitor.png",
			path: "/pageSubPack/visitor/visitor-list"
		}
	])
	const communityFuncList = ref([{
			name: "一键开门",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-door.png",
			path: "/pageSubPack/notice-list/oneClickOpen"
		},
		{
			name: "生活缴费",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-pay.png",
			path: "/pageSubPack/payment-list/paymentIndex"
		},
		{
			name: "在线报修",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-repair.png",
			path: "/pageSubPack/online-repair/onlineRepair"
		},
		{
			name: "访客邀请",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-visitor.png",
			path: "/pageSubPack/visitor/visitor-list"
		},
		{
			name: "投诉意见",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-complaint.png",
			path: "/pageSubPack/service-list/complaintsSuggestionsIndex"
		},
		{
			name: "问卷调查",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-survey.png",
			path: "/pageSubPack/service-list/questionnaireSurveyIndex"
		},
		{
			name: "社区活动",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-activity.png",
			path: "/pageSubPack/activity-list/activityList"
		},
		{
			name: "公告公示",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-notice.png",
			path: "/pageSubPack/notice-list/noticeList"
		},
		{
			name: "联系物业",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-contact.png",
			path: "/pageSubPack/service-list/contactProperty"
		},
		{
			name: "巡检记录",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-inspection.png",
			path: "/pageSubPack/inspection-revenue/inspection"
		},
		{
			name: "公区收益",
			icon: "https://wuye.ckdzkj.com/images/propertyImgs/icon-revenue.png",
			path: "/pageSubPack/inspection-revenue/public-revenue"
		}
	])
	const loginName = ref("wangh")
	const phoneNum = ref('156*****1212')

	// --方法----

	const handleFuncClick = (item) => {
		
		uni.setStorageSync('sourcePage', 'serviceIndex')
		uni.redirectTo({
			url: item.path,
			success: res => {},
			fail: () => {},
			complete: () => {}
		});
	}
	
	// banner跳转
	function bannnerClick(){
		uni.navigateTo({ url: '/pageSubPack/online-repair/onlineRepair'})
	}
</script>



<style lang="scss">
	page {
		background: #f2f1f6;
	}
</style>
<style scoped>
	.status-bar {
		width: 100vw;
		height: 46px;
	}

	.contentStyle {
		display: flex;
		flex-direction: column;
		height: 100vh;
		/* 关键：占满屏幕高度 */
		background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%);
	}

	.page {
		flex: 1;
		overflow-y: auto;
		padding: 0px 40rpx;
		box-sizing: border-box;
		/* background-color: #fff; */
	}



	.container {
		/* padding: 40rpx; */
	}

	/* Banner 轮播 */
	.banner-box {
		width: 100%;
		border-radius: 20rpx;
		overflow: hidden;
		margin-bottom: 40rpx;
		height: 300rpx;
	}

	.banner-img {
		width: 100%;
		height: 300rpx;

	}


	/* 功能区通用样式 */
	.func-section {
		width: 100%;
		background-color: #ffffff;
		border-radius: 20rpx;
		padding: 30rpx 30rpx 0rpx;
		box-sizing: border-box;
		margin-bottom: 30rpx;
	}

	.section-title {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.title-line {
		width: 12rpx;
		height: 48rpx;
		background-color: #007aff;
		border-radius: 6rpx;
		margin-right: 20rpx;
	}

	.title-text {
		font-size: 32rpx;
		font-weight: 600;
		color: #000000;
	}

	/* 功能网格 */
	.func-grid {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
	}

	.func-item {
		width: 22%;
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-bottom: 30rpx;
	}

	.func-icon {
		width: 84rpx;
		height: 84rpx;
		border-radius: 50%;
		background-color: #f0f5ff;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-bottom: 20rpx;
		position: relative;
	}


	.func-icon image {
		max-height: 100%;
		/* 限制最大高度不超出 */
		object-fit: cover;
		/* 保持比例 */
		/* width: 200px; */
		/* height: 200px; */
	}

	.func-name {
		font-size: 28rpx;
		color: #000000;
		font-weight: 400;
		text-align: center;
		line-height: 1.4;
	}

	/* 智慧社区网格 */
	.community-grid {
		justify-content: flex-start;
	}

	.community-grid .func-item {
		width: 22%;
		margin-right: calc((100% - 22% * 4) / 3);
	}

	.community-grid .func-item:nth-child(4n) {
		margin-right: 0;
	}
</style>