<template>
	<view>
		<u-navbar title="我的应用" title-color="#101010" :is-back="false" ></u-navbar>
		<!-- 用电管理 -->
		<view class="apps-content">
			<view class="title">
				用电管理
			</view>
			<view class="apps-groups">
				<view class="item" v-if="false"
				 @click="gotoUrl('/pages/equipmentDataMonitoring/dataMonitoring-list')"
					>
					<view class="item-icon">
						<image class="img" src="@/assets/img/riLine-file-chart-2-line.svg" mode=""></image>
					</view>
					<view class="item-name">
						设备数据监测
					</view>
				</view>
				
				<view class="item" @click="gotoUrl('/pages/equipmentInformation/equipmentConditionMonitoring')"
					>
					<view class="item-icon item-icon2">
						<image class="img" src="@/assets/img/iconPark-network-tree.svg" mode=""></image>
					</view>
					<view class="item-name">
						设备状态监测
					</view>
				</view>
				
				<view class="item" v-if="false" >
					<view class="item-icon item-icon3">
						<image class="img" src="@/assets/img/iconPark-ranking-list.svg" mode=""></image>
					</view>
					<view class="item-name">
						异常设备排名
					</view>
				</view>
				<view class="item" @click="gotoUrl('/pages/abnormal/abnormalAlarmRecord')"
					>
					<view class="item-icon item-icon4">
						<image class="img" src="@/assets/img/iconPark-caution.svg" mode=""></image>
					</view>
					<view class="item-name">
						异常告警记录
					</view>
				</view>
				<view class="item"  @click="gotoUrl('/pages/equipmentInformation/equipmentInformation')"
					>
					<view class="item-icon item-icon5">
						<image class="img" src="@/assets/img/iconPark-all-application.svg" mode=""></image>
					</view>
					<view class="item-name">
						设备管理
					</view>
				</view>
				<view class="item" @click="gotoUrl('/pages/equipmentDataMonitoring/equipmentElectricity')"
					>
					<view class="item-icon item-icon6">
						<image class="img" src="@/assets/img/iconPark-order.svg" mode=""></image>
					</view>
					<view class="item-name">
						设备用电量
					</view>
				</view>
				
				
				<view class="item"   v-if="codes&&codes.indexOf('energyAdmin')!=-1"
				@click="gotoUrl('/pages/managementList/managementList?isback=1')"
					>
					<view class="item-icon item-icon10">
						<image class="img" src="@/assets/img/riLine-account-box-line.svg" mode=""></image>
					</view>
					<view class="item-name">
						授权管理
					</view>
				</view>
				
				<view class="item"  
				@click="gotoUrl('/pages/equipmentDataMonitoring/equipmentElectricityWater')"
					>
					<view class="item-icon  item-icon7">
						<image class="img" src="@/assets/img/mine/iconPark-water-level.svg" mode=""></image>
					</view>
					<view class="item-name">
						设备用水量
				
					</view>
				</view>
				
				<view class="item"   v-if="companyInfo.type==2"
				@click="gotoUrl('/pages/platformRevenueStatistics/platformRevenueStatistics?isback=1')"
					>
					<view class="item-icon item-icon5">
						<image class="img" src="@/assets/img/riLine-money-cny-box-line.svg" mode=""></image>
					</view>
					<view class="item-name">
						收入统计				
					</view>
				</view>
				
				<view class="item"   v-if="companyInfo.type==2"
				@click="gotoUrl('/pages/platformRevenueStatistics/electricityConsumptionAnalysis?isback=1')"
					>
					<view class="item-icon item-icon8">
						<image class="img" src="@/assets/img/iconPark-chart-histogram-two.svg" mode=""></image>
					</view>
					<view class="item-name">
						能耗分析
				
					</view>
				</view>
				
			</view>
		</view>
		<!-- 租户管理 -->
		<view class="apps-content" v-if="codes&&codes.indexOf('property')!=-1" >
			<view class="title">
				租户管理
			</view>
			<view class="apps-groups">
				<view class="item"  @click="gotoUrl('/pages/tenantList/contractList')" >
					<view class="item-icon item-icon9">
						<image class="img" src="@/assets/img/riLine-folder-user-line.svg" mode=""></image>
					</view>
					<view class="item-name">
						租户管理预警
					</view>
				</view>
				<view class="item"  @click="gotoUrl('/pages/tenantList/tenantList')" >
					<view class="item-icon item-icon7">
						<image class="img" src="@/assets/img/iconPark-order.svg" mode=""></image>
					</view>
					<view class="item-name">
						扣费记录
					</view>
				</view>
				<view class="item"  @click="gotoUrl('/pages/deductionRecord/billingRules')"  >
					<view class="item-icon item-icon8">
						<image class="img" src="@/assets/img/riLine-file-text-line.svg" mode=""></image>
					</view>
					<view class="item-name">
						计费规则
					</view>
				</view>
				<view class="item"  @click="gotoUrl('/pages/tenantList/remoteControl')" >
					<view class="item-icon item-icon9">
						<image class="img" src="@/assets/img/riLine-remote-control-line.svg" mode=""></image>
					</view>
					<view class="item-name">
						远程控制
					</view>
				</view>
				<view class="item"  @click="gotoUrl('/pages/tenantList/rechargeRecord')" >
					<view class="item-icon item-icon3">
						 <u-icon name="clock" color="#fff" size="48" ></u-icon>
					</view>
					<view class="item-name">
						充值记录
					</view>
				</view>
				
			</view>
		</view>
		
		<energyCenterTabbar :current="1"></energyCenterTabbar>
	</view>
</template>

<script>
	import energyCenterTabbar from '@/components/energyCenterTabbar.vue'
	import * as API from '@/apis/pagejs/index.js'
	
	import * as API_managementList from '@/apis/pagejs/managementList.js'
	
	export default {
		components: {
			energyCenterTabbar
		},
		data() {
			return {
				codes: '',
				abnormalRecordsList: [],
				informationList:[],
				companyInfo:{}
			}
		},
		onReady() {
			var date = new Date();
			var year = date.getFullYear();
			var month = date.getMonth()+1 >= 10 ? date.getMonth()+1 : '0'+(date.getMonth()+1);
			this.queryDate = year + '-' + month;
			
			this.getfindByOpenId();
			//this.getAbnormalAlarmRecord();
			//this.getInformationList()
		},
		methods: {
			//授权二维码
			getInformationList() {
			
				API_managementList.informationList().then((response) => {
					
					this.informationList = response.data.informationList;
				}).catch(error => {
					uni.showToast({
						title: error,
						icon: "none"
					})
				})
			},
			// 异常告警记录
			getAbnormalAlarmRecord() {
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				API.alarmRecord({
					queryDate: this.queryDate,
					configId: '',
					pageIndex: 1,
					pageSize: 3,
					companyId: this.companyId
				}).then((response) => {
					uni.hideLoading();
					this.abnormalRecordsList = response.data.data;
				}).catch(error => {
					uni.showToast({
						title: error,
						icon: "none"
					})
				})
			},
			// 商户ID
			getfindByOpenId() {
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				API.findByOpenId({
					openId: this.carhelp.getOpenId()
				}).then((response) => {
					uni.hideLoading();
					this.codes = response.data.regUser.codes;
					this.companyInfo=response.data.companyInfo
					
				}).catch(error => {
					uni.showToast({
						title: error,
						icon: "none"
					})
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.apps-content{
		background-color: #fff;
		margin-bottom: 24rpx;
		.title{
			padding: 32rpx;
			color: rgb(51,51,51);
			font-size: 36rpx;
			font-weight: bold;
			border-bottom: 1px solid #f2f4f6;
		}
		
		.apps-groups{
			display: flex;
			flex-wrap: wrap;
			.item{
				width: 50%;
				display: flex;
				padding: 32rpx 24rpx;
				align-items: center;
				border-right: 1px solid #f2f4f6;
				.item-icon{
					border-radius: 8px;
					background: linear-gradient(180deg, rgba(93,155,255,1) 0%,rgba(0,97,255,1) 100%);
                    width: 72rpx;
					height: 72rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					.img{
						width: 48rpx;
						height: 48rpx;
						
					}
				}
				.item-icon2{
                  background: linear-gradient(179.2deg, rgba(168,178,238,1) 6.28%,rgba(123,123,240,1) 96.94%);
				}
				.item-icon3{
					background: linear-gradient(181.79deg, rgba(117,213,224,1) -1.13%,rgba(53,153,203,1) 94.2%);
				}
				.item-icon4{
background: linear-gradient(180.29deg, rgba(255,124,112,1) 0.9%,rgba(255,79,63,1) 100.4%);
				}
				.item-icon5{
background: linear-gradient(180deg, rgba(93,155,255,1) 0%,rgba(0,97,255,1) 100%);
				}
				.item-icon6{
background: linear-gradient(178.44deg, rgba(122,232,227,1) 3.96%,rgba(57,182,182,1) 100.6%);
				}
				.item-icon7{
background: linear-gradient(179.2deg, rgba(96,213,124,1) -0.62%,rgba(0,161,39,1) 97.92%);
				}
				.item-icon8{
					background: linear-gradient(179.2deg, rgba(168,178,238,1) 6.28%,rgba(123,123,240,1) 96.94%);

				}
				.item-icon9{
					background: linear-gradient(180deg, rgba(93,155,255,1) 0%,rgba(0,97,255,1) 100%);
				}
				.item-icon10{
					background:linear-gradient(181.79deg, rgba(117,213,224,1) -1.13%,rgba(53,153,203,1) 94.2%)
				
				}
				.item-name{
					color: rgba(51,51,51,1);
					font-size: 36rpx;
					margin-left: 16rpx;
					font-weight: bold;
					
				}
			}
		}
	}

</style>
