<template name="apps">
	<view>
		<cu-custom bgColor="bg-blue">
			<block slot="content">首页</block>
		</cu-custom>

		<swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="3000" :duration="800">
			<swiper-item>
				<image src="../../static/img/banner.png" class="swiper-item"></image>
			</swiper-item>
		</swiper>


		<view class="line-box">
			<view class="btn-box-1 mart-t" v-if="stype != 3">
				<navigator class="h-200" hover-class="none" url="/pages/buildList/buildList">
				</navigator>
			</view>
			<view class="btn-box-2 mart-t">
				<navigator class="h-200" hover-class="none" url="/pages/comList/comList">

				</navigator>
			</view>
			<view class="btn-box-3 mart-t">
				<navigator class="h-200" hover-class="none" url="/pages/revenue/RevenueList">
				</navigator>
			</view>
			<view class="btn-box-4 mart-t">
				<navigator class="h-200" hover-class="none" url="/pages/map/mapVisualization-th">

				</navigator>
			</view>
			<view class="btn-box-5 mart-t">
				<navigator class="h-200" hover-class="none" url="/pages/analysis/analysis">
				</navigator>
			</view>
			<view class="btn-box-6 mart-t" @click="outlogin">

			</view>
		</view>


	</view>
</template>

<script>
	import loginService from "@/api/auth/loginService"
	export default {
		name: "apps",
		data() {
			return {
				stype: "", // 企业 => 3  楼宇 => 2  园区 => 1  zfadmin => 4  admin=> 5
			};
		},
		onShow() {
			
		},
		
		created() {
			this.$auth.checkLogin()
			this.getRole()
		},


		methods: {

			getRole() {
				let userInfo = uni.getStorageSync('WMS-userinfo')
				var officeId = userInfo.officeDTO.id;
				var roleIds = userInfo.roleIds;
				if (roleIds.indexOf("17bac1f980264e3e8193bc965538e2c6") != -1) {
					//// 管理员
					this.stype = 5
					uni.setStorageSync('stype', this.stype);
				} else if (roleIds.indexOf("ade960e8f02544998b07397304c059c1") != -1) {
					// 政府管理员
					this.stype = 4
					uni.setStorageSync('stype', this.stype);
				} else {
					console.log('==================>这里走了么','================>存一个stape')
					loginService
						.getOtherIdByOffceid({
							officeid: officeId,
						})
						.then(({
							data
						}) => {
							console.log(data, "====================>getOtherIdByOffceid");
							this.stype = data.stype;
							uni.setStorageSync('stype', this.stype);
						});
				}
				
			},


			outlogin() {
				uni.showModal({
					title: '您确认退出么？',
					showCancel: true,
					success: (res) => {
						if (res.confirm) {
							uni.showLoading()
							loginService.logout().then(({
								data
							}) => {
								this.$store.commit('logout');
								uni.clearStorage();
								uni.reLaunch({
									url: '/pages/login/login'
								})
							})
						}
					}
				});
			}
		}
	}
</script>

<style>
	.page {
		height: 100vh;
	}

	.line-box {
		display: flex;
		padding-left: 20rpx;
		padding-right: 20rpx;
		justify-content: space-between;
		margin-top: 20rpx;
		flex-wrap: wrap;
	}

	.mart-t {
		margin-top: 30rpx;
	}

	.btn-box-1 {
		width: 337rpx;
		height: 200rpx;
		background-image: url('../../static/img/btn1.png');
		background-size: 100% 100%;
	}

	.btn-box-2 {
		width: 337rpx;
		height: 200rpx;
		background-image: url('../../static/img/btn4.png');
		background-size: 100% 100%;
	}

	.btn-box-3 {
		width: 337rpx;
		height: 200rpx;
		background-image: url('../../static/img/btn2.png');
		background-size: 100% 100%;
	}

	.btn-box-4 {
		width: 337rpx;
		height: 200rpx;
		background-image: url('../../static/img/btn5.png');
		background-size: 100% 100%;
	}

	.btn-box-5 {
		width: 337rpx;
		height: 200rpx;
		background-image: url('../../static/img/btn3.png');
		background-size: 100% 100%;
	}

	.btn-box-6 {
		width: 337rpx;
		height: 200rpx;
		background-image: url('../../static/img/btn6.png');
		background-size: 100% 100%;
	}

	.h-200 {
		height: 200rpx;
	}

	.swiper {
		width: 750rpx;
		height: 360rpx;
	}

	.swiper-item {
		width: 750rpx;
		height: 360rpx;
		background-color: aliceblue;
	}

	.font-size-35 {
		font-size: 35px !important;
	}

	.img-size {
		width: 80rpx;
		height: 80rpx;
	}

	.content-box {
		width: 337rpx;
		height: 200rpx;
	}

	.my-app .padding-sm {
		padding: 6px;
	}

	.grid .padding-sm .bg-white {
		box-shadow: 0 1px 4px #f9f9f9, 1px 1px 40px rgba(0, 0, 0, .06);
	}

	.bg-blue {
		background: #fff;
		color: #0081ff !important;
	}

	.text-white,
	.line-white,
	.lines-white {
		color: #0081ff !important;
	}
</style>