<template>
	<view>
		<image src="/static/icon/backgroundgz.png" mode="" class="background"></image>
		<image src="https://zdsz.obs.cn-south-1.myhuaweicloud.com/file/0e1e285e104144caa274659b3429284c.png" mode="" class="gongzuobj"></image>
		<view class="justify-content" v-if="visable">
			<view class="align-items" style="position: absolute; top: 110rpx; left: 50rpx;">
				<u-icon name="arrow-left" @click="backview()" style="color: #fff; font-size: 36rpx;margin: 0 40rpx 0 0;"></u-icon>
				<image src="/static/icon/sgglpt.png" mode="" class="header-title" style="width: 300rpx;height: 36rpx;"></image>
			</view>
			<view class="align-items" style="position: absolute;top: 100px;left: 150px;font-size: 36rpx;color: #fff;">
				{{name}} !欢迎你登录本应用
			</view>
		</view>
		<view style="padding-top: 170rpx;" v-if="!visable">
			<view style="display: flex;align-items: flex-end;width: 100%;text-align:right;position: fixed;">
				<!-- <u-search placeholder="请输入搜索内容" v-model="nameValue"  :show-action="false" :action-style="{'font-size':'40rpx'}" @search="getProjectList()"></u-search> -->
				<!-- <view style="width: 100%;" @click="getProjectList()">历史</view>
				<u-icon name="arrow-right"></u-icon> -->
			</view>
		</view>
		<view style="padding-top: 300rpx;">
			<view v-for="(item,index) in list" :key="index" class="qxwxbox" v-if="power.includes(item.dictValue)&&item.visable">
				<view class="font-forty-eight qxwx-nav" 
					@click="topage(item)">
					<image :src="item.image" mode="" style="height: 100rpx;width: 100rpx;"></image>
					<span class="qxwx-navtitle" >{{item.dictLabel}}</span>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
		</view>

		<!-- <view class="name">
			姓名：{{name}}
		</view> -->
		<view class="align-items position" @click="back('/pages/login/login')" v-if="visable">
			<view class="background-color1 arrow">
				<u-icon name="arrow-rightward" size="50rpx" color="#ffffff"></u-icon>
			</view>
			<view class="font-forty-eight black">
				跳转登录页
			</view>
			
		</view>
	</view>
</template>

<script>
	import service from '@/api/index.js'
	export default {
		data() {
			return {
				list: [],
				name: '',
				power: '',
				visable: false,
				nameValue: ''
			}
		},
		onLoad() {
			this.getProjectType();
			this.getUserName();

		},
		onShow() {
			this.getProjectType();
			if (this.visable) {
				console.log(this.visable)
				uni.hideTabBar()
			} else {
				console.log(this.visable)
				uni.showTabBar()
			}
		},
		methods: {
			getProjectList() {
				// if ('' == this.nameValue) {
				// 	this.$UTILS.showPrompt('请输入搜索内容!')
				// 	return
				// }
				uni.navigateTo({
					url: `/pages/noLogin/listProject?nameValue=${this.nameValue}`
				})


				// service.getProjectList({engineType:this.value,name:this.nameValue}).then(res=>{
				// 	console.log('getProjectType', res)
				// 	if(res.length == 0){
				// 		this.$UTILS.showPrompt('暂无项目!')
				// 	}
				// 	this.list = res;
				// })
			},
			topage(url) {
				if (url.dictValue == '1') {
					this.list1 = []
					this.list.forEach(item => {
						if (item.dictValue == '1'||item.dictValue == '0'||item.dictValue == '6') {
							item.visable = false
						} else {
							item.visable = true
						}
						this.list1.push(item)
					})
					this.list = this.list1
					console.log(this.list)
					this.visable = true
					uni.hideTabBar()
				} else {
					if (url.dictValue == '4') {
						uni.navigateTo({
							url: `/pages/noLogin/WarningPileList`
						})
					} else if(url.dictValue == '0') 
					{
						uni.navigateTo({
							url: `/pages/noLogin/emergencyRepairOrder/emergencyRepairOrder`
						})
						
					}
					else if(url.dictValue=='6')
					{
						this.list1 = []
						this.list.forEach(item => {
							if (item.dictValue == '1'||item.dictValue == '0') {
								item.visable = true
							} else {
								item.visable = false
							}
						
							this.list1.push(item)
						})
						this.list = this.list1
						console.log(this.list)
						this.visable = true
						uni.hideTabBar()
					}
					else 
					{
						
						uni.navigateTo({
							url: `/pages/noLogin/communitylist?value=${url.dictValue}`
						})
					}


				}
			},
			backview()
			{
				this.getProjectType()
				
				this.visable=false
				uni.showTabBar()
			},
			back(url) {
				this.visable = false
				this.list1 = []
				this.list.forEach(item => {
					if (item.dictValue == '1' || item.dictValue == '2') {
						item.visable = true
					} else {
						item.visable = false
					}
					this.list1.push(item)
				})
				this.visable=false
				this.list = this.list1
				uni.navigateTo({
					url
				})
			},
			getProjectType() {
				service.getDictInfo({
					type: 'engine_type'
				}).then(res => {
					this.list = res;
					this.list1 = []
					this.list.forEach(item => {
						item.visable = true
						if(item.dictValue==0)
						{
							item.image='../../static/icon/qxwx.png'
						}else if(item.dictValue==1){
							item.image='../../static/icon/xxdy.png'
						}else{
							item.image='../../static/icon/kggs.png'
						}
						this.list1.push(item)
					})
					this.list1.push({
						dictLabel: '调压箱管理',
						dictValue: '2',
						visable: false,
						image:'../../static/icon/xxdy.png'
					})
					this.list1.push({
						dictLabel: '庭院网管',
						dictValue: '3',
						visable: false,
						image:'../../static/icon/tywg.png'
					})
					this.list1.push({
						dictLabel: '警示桩管理',
						dictValue: '4',
						visable: false,
						image:'../../static/icon/jsz.png'
					})
					this.list = this.list1
					console.log(this.list)
				})
			},
			getUserName() {
				service.getUserName().then(res => {
					this.name = res.name;
					this.power = res.power + '2,3,4';
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	.background {
		z-index: -1;
		position: fixed;
		width: 100%;
		height: 100%;
		background-size: 100% 100%;
	}
	.qxwxbox{
		width: 90%;
		margin: 30rpx auto;
		background: #fff;
		border: solid 20rpx #ddeafe;
		border-radius: 20rpx;
		box-shadow: 0rpx 0rpx 20rpx #6da5f9;
		padding: 40rpx 30rpx;
	}
	.qxwx-nav{
		display: flex;
		justify-content:space-between;
		align-items:center;
	}
	.gongzuobj{
		position: fixed;
		width: 90%;
		height: 630rpx;
		z-index: -1;
		left: 5%;
	}
	.qxwx-navtitle{
		width: 62%;
		font-size: 44rpx;
	}
	.name {
		font-size: 40rpx;
		margin-left: 36rpx;
	}

	.position {
		position: absolute;
		bottom: 100rpx;
		right: 50rpx;
		width: 330rpx;
		height: 100rpx;
		background: #fff;
		border-radius: 56rpx;
		break-after: avoid;
		break-after: avoid;
		box-shadow: 0rpx 7rpx 10rpx #9ec7fb;
		-webkit-font-smoothing: subpixel-antialiased;

		.arrow {
			width: 70rpx;
			height: 70rpx;
			border-radius: 50%;
			padding: 10rpx;
			margin-left: 20rpx;
		}
		.black {
		    color: #333333;
		    font-size: 36rpx;
		    margin: 0 0 0 20rpx;
		}
	}

	.btn {
		margin: 90rpx 30rpx;
		background: #3857F3;
		border-radius: 72rpx;
	}
</style>