<template>
	<view class="page" :style="{'height':h+'px'}">
		<view class="left">
			<view class="item" :class="[(index===nIndex)?'active':'',index===(nIndex+1)?'rtb':'']" 
			v-for="(item,index) in navList" :key="index" @click="changeType(index,item.name)">
				{{item.name}}
			</view>
		</view>
		<view class="right">
			<block v-if="solutionList.length">
				<u-list class="ulist" @scrolltolower="scrolltolower">
					<u-list-item class="item" :class="index===0?'item1':''" v-for="(item, index) in solutionList" :key="index">
						<view @click="toDetails(item)">
							<view class="top">
								<image :src="item.img"></image>
							</view>
							<view class="text">
								{{item.name}}
							</view>
						</view>
					</u-list-item>
				</u-list>
			</block>
			<block v-else></block>
		</view>
		<tabbar :tabbarIndex="1"></tabbar>
	</view>
</template>

<script>
	import { data } from '../plan/data.js'
	export default {
		data(){
			return {
				navList:[
					{name:'全部'},
					{name:'智能仓储'},
					{name:'能耗管理'},
					{name:'产业园区'},
					{name:'工业园区'},
					{name:'智慧校园'},
					{name:'智慧场馆'},
					{name:'公共交通'},
					{name:'智慧文旅'},
					{name:'城市服务'},
					{name:'住宅社区'},
					{name:'3D可视化'},
					{name:'智慧运维'},
					{name:'智慧安防'},
					{name:'楼宇自控'},
					{name:'能耗管理'},
					{name:'智能照明'},
					{name:'智慧通行'},
					{name:'智能环卫'},
					{name:'智慧电梯'},
					{name:'应急指挥'},
					{name:'资产管理'}
				],
				nIndex:0,
				solutionList:[],
				isOver:false
			}
		},
		onLoad() {
			this.getList('全部');
		},
		methods:{
			changeType(index,key){
				this.nIndex = index;
				this.getList(key);
			},
			scrolltolower() {
				if (this.isOver) return;
				this.getList(this.nIndex);
			},
			getList(key){
				if(key=='全部'){
					this.solutionList = [];
					for (let d in data) {
						this.solutionList = [...this.solutionList,...data[d]];
					};
				}else{
					this.solutionList = data[key] || [];
				}
			},
			toDetails(item){
				if(!item.details) return
				uni.navigateTo({
					url:`/pages/plan/details?id=${item.id}&key=${item.parent}`
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page{
		background: #FFFFFF;
		box-sizing: border-box;
		display: flex;
		
		.left{
			width: 168rpx;
			height: 100%;
			overflow-y: auto;
			.item{
				width: 100%;
				height: 98rpx;
				background: #F3F4F8;
				display: flex;
				align-items: center;
				justify-content: center;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #9D9DA0;
				line-height: 37rpx;
				&.active{
					background: #FFFFFF;
					font-weight: bold;
					color: #1460CA;
				}
				&.rtb{
					border-top-right-radius: 16rpx;
				}
			}
		}
		
		.right{
			width: calc(100% - 168rpx);
			padding: 0 30rpx 20rpx;
			box-sizing: border-box;
			
			.ulist{
				height: 100% !important;
				.item{
					width: 100%;
					margin-top: 44rpx;
					border-radius: 12rpx 12rpx 0rpx 0rpx;
					background: #FFFFFF;
					
					&.item1{
						margin-top: 20rpx;
					}
					
					.top{
						width: 100%;
						height: 262rpx;
						background: #D8D8D8;
						border-radius: 12rpx 12rpx 0rpx 0rpx;
						image{
							width: 100%;
							height: 100%;
							border-radius: 12rpx 12rpx 0rpx 0rpx;
						}
					}
					.text{
						box-sizing: border-box;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						font-family: PingFang-SC, PingFang-SC;
						font-weight: bold;
						font-size: 28rpx;
						color: #111111;
						line-height: 28rpx;
						margin-top: 20rpx;
					}
				}
			}
		}
	}
</style>