<template>
	<view>
		<image src="/static/icon/background.png" mode="" class="background"></image>
		<view class="" style="padding-top: 90rpx;">
			<back></back>
		</view>
		<view style="padding-top: 60rpx;">
			<view style="margin: 20rpx;">
				<u-search placeholder="请输入搜索内容" v-model="nameValue" :action-style="{'font-size':'40rpx'}" @custom="getProjectList()"></u-search>
			</view>
			<view v-for="(item,index) in list" :key="index" >
				<view class="project-content"  @click="gotoindex(item)">
					<view>
						<view class="font-forty-eight blue">
							项目类型：{{item.typeValue}}
						</view>
						<view class="font-forty-eight blue">
							项目名称：{{item.name}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import service from '@/api/index.js'
	export default {
		data() {
			return {
				list:[],
				value:'',
				nameValue:'',
				civilPower:''
			}
		},
		onLoad(e) {
			console.log(e)
			this.nameValue = e.nameValue
			this.getProjectList();
			this.getUserName();
		},
		methods: {
			gotoindex(item){
				console.log(item)
				if(item.type==1)
				{//调压箱
				console.log(item)
					uni.navigateTo({
						url: `/pages/noLogin/PressureRegulatingBox/PressureRegulatingBox?type=1&id=${item.id}`
					})
				}else if(item.type==2)
				{//庭院管理
					uni.navigateTo({
						url: `/pages/noLogin/CourtyardNetworkManagement/CourtyardNetworkManagement?type=1&id=${item.id}`
					})
				}else if(item.type==3)
				{//抢险维修
					uni.navigateTo({
						url: `/pages/noLogin/emergencyRepairOrder/emergencyRepairOrder?type=1&id=${item.id}`
					})
				}else if(item.type==4)
				{//警示桩
				console.log(item)
				let url1= `/pages/noLogin/WarningPileForm/WarningPileForm?type=1&id=${item.id}`
					uni.navigateTo({
						url: url1
					})
				}
				// uni.switchTab({
				// 	url:'/pages/index/index'
				// })
			},
			topage(url){
				uni.navigateTo({
					url
				})
			},
			getProjectList() {
				service.getSearch({value:this.nameValue}).then(res=>{
					console.log('getProjectType', res)
					if(res.length == 0){
						this.$UTILS.showPrompt('暂无历史记录!')
						return
					}
					let list1=[]
					list1=res
					list1.forEach(item=>{
						 if(item.type==1)
						{
							item.typeValue='调压箱'
						}else if(item.type==2)
						{
							item.typeValue='庭院管网'
						}
						else if(item.type==3)
						{
							item.typeValue='抢险维修'
						}else if(item.type==4)
						{
							item.typeValue='警示桩'
						}
						this.list.push(item)
					})
		
					//this.list = res;
				})
			},
			getUserName(){
				service.getUserName().then(res=>{
					this.civilPower = res.civilPower;
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	.background {
		z-index: -1;
		position: fixed;
		width: 100%;
		height: 100%;
		background-size: 100% 100%;
	}

	.project {
		border-radius: 72rpx;
		padding: 25rpx 0;
		text-align: center;
		margin: 170rpx 55rpx 0;
	}

	.project-content {
		border: 4rpx solid #3857F3;
		margin: 40rpx 55rpx 0;
		padding: 30rpx 20rpx;
		border-radius: 48rpx;
	}
	.position{
		position: absolute;
		bottom: 100rpx;
		right: 50rpx;
		.arrow{
			width: 152rpx;
			height: 152rpx;
			border-radius: 50%;
			padding: 25rpx;
			margin-left: 20rpx;
		}
	}
	
</style>
