<template>
	<view class="center">
		<view class="logo" >
			<image class="logo-img" src="https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"></image>
			<view class="flex  margin-top-30" style="padding-left: 30rpx;">
				<view class="user-name">超级管理员</view>
			</view>
		</view>
		<view style="margin: 10rpx;" >
			<u-cell-group :border="false">
				<u-cell-item :border-top="false" @click="toService(item)" v-for="(item,index) in menuList1" :key="index"  :title="item.name"></u-cell-item>
				<u-cell-item  :border-bottom="false" @click="toSetting" v-for="(item,index) of menuList2" :key="index" :title="item"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuList1:	[],
				menuList2: ["系统设置"]
			}
		},
		onLoad() {
			this.getMenu();
		},
		onPullDownRefresh(){
			this.getMenu();
		},
		methods: {
			toSetting(){
				uni.navigateTo({
					url: "../setting/setting"
				})
			},
			getMenu(){
				this.$api.permissions.menuList().then(res=>{
					console.log(res);
					for(let item of res.list){
						if(item.name=="物业管理"){
							this.menuList1= item.subList;
						}
					}
				});
			},
			toService(item){
				switch(item.name){
					case "服务人员管理": 
						// uni.navigateTo({
						// 	url: "../fwry/fwry"
						// })
						this.$u.toast('即将开放');
						break;
					case "车辆管理":
						uni.navigateTo({
							url: "../car-manage/car-manage"
						})
						break;
					case "门禁管理":
						this.$u.toast('即将开放');
						break;
					default :
						let list= [];
						for(let element of item.subList){
							list.splice(list.length,0,element.name);
						}
						uni.navigateTo({
							url: "../service/service?list="+JSON.stringify(list)
						})
				}
			}
		}
	}
</script>

<style>
	page{
		background-color: #FFFFFF;
	}
	
	.cu-btn.sm {
		padding: 0 20upx;
		font-size: 20upx;
		height: 42upx;
	}
	
	.logo {
		display: flex;
		padding:0 20rpx 40rpx;
		background-color: #7dc7ae;
		
	}
	.logo-img {
		width: 120upx;
		height: 120upx;
		border-radius: 150upx;
	}
	.user-name {
		font-size: 38upx;
		color: #FFFFFF;
	}
</style>