<template>
	<view class="center">
		<view style="background: linear-gradient( 180deg, #1FCA7C 0%, #F2F2F2 100%);">
			<view class="h-300 flex flex-row-between mt-200" style="position: relative;">
				<image class="w-344 h-266" style="position: absolute;right: 0;
				top: 20rpx;" src="/static/icon_my_bg.png"></image>
				<view class="flex ml-25 mt-70 v-center h-95" @click="onClick(3)">
					<image class="w-95 h-95 br-50" :src="userInfo.avatar"></image>
					<view class="flex-column ml-10" style="color: #FFFFFF;text-align: left;">
						<text class="fs-32 fw-700">{{userInfo.nickName}}</text>
						<text class="fs-24 mt-10">{{userInfo.mobile}}</text>
					</view>
				</view>

			</view>

		</view>
		<view class="mlr-25 br-12" style="background: white;margin-top: -60rpx;z-index: 1;">
			<view class="flex-column mar-25" @click="onClick(4)">
				<text class="fs-32 fw-700 mb-30" style="text-align: left;">房屋信息</text>
				<view class="flex-column br-12 pad-25" style="background: #F3FEF9;">
					<view class="flex">
						<image class="h-42 w-42" src="/static/icon_my_fw.png"></image>
						<text class="fs-28">{{$wskj.isNullStr(userInfo.communityName)||'暂无'}}</text>
					</view>
					<text class="fs-24 h-54 lh-54 mt-30"
						style="background: linear-gradient( 90deg, #CAF6E2 0%, #FFFFFF 100%);">
						{{$wskj.isNullStr(userInfo.room)||'暂无'}}
					</text>
				</view>
			</view>
		</view>
		<view class="mlr-25 br-12 mt-30" style="background: white;">
			<view class="flex-column mar-25">
				<text class="fs-32 fw-700 mb-30" style="text-align: left;">常用功能</text>
				<view class="flex mtb-50">
					<view @click="onClick(0)" class="flex-column vh-center  fs-24" style="flex: 1;">
						<image class="h-68 w-64 mtb-10" src="/static/icon_my_wdfw.png"></image>
						<text>我的房屋</text>
					</view>
					<view @click="onClick(1)" class="flex-column vh-center fs-24" style="flex: 1;">
						<image class="h-68 w-64 mtb-10" src="/static/icon_my_wdgd.png"></image>
						<text>我的工单</text>
					</view>
					<view @click="onClick(2)" class="flex-column vh-center  fs-24" style="flex: 1;">
						<image class="h-68 w-64  mtb-10" src="/static/icon_my_ygrk.png"></image>
						<text>员工入口</text>
					</view>
				</view>
			</view>
		</view>
		<view class="mlr-25 mt-30">
			<u-swiper :list="bannerList" radius="6"></u-swiper>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: '',
				bannerList: [],
			};
		},
		onShow() {
			this.getUserInfo()
			this.getBannerList()
		},
		methods: {
			//轮播图列表
			getBannerList() {
				const than = this;
				const params = {
					url: '/api/slideshow/list?type=1',
					method: 'GET',
					data: {}
				}
				this.$request(params).then(res => {
					than.bannerList = [];
					res.data.forEach(function(item, index) {
						than.bannerList.push(item.url)
					});
				})
			},
			getUserInfo() {
				const params = {
					url: '/api/login/userInfo',
					method: 'GET',
					data: {}
				}
				this.$request(params).then(res => {
					uni.setStorageSync('userInfo', res.data)
					this.userInfo = res.data

				})
			},
			yg_login() {
				const params = {
					url: '/api/login/accountLogin',
					method: 'GET',
				}
				this.$request(params).then(res => {
					//uni.setStorageSync('userInfo_yg', res.data)
					this.$wskj.to("/pagesMine/pages/ygzy")
				})
			},
			onClick(index) {
				if (index == 3 && parseInt(this.userInfo.userPermission) > 1) {
					return
				}
				if (index == 2) { //员工入口
					this.yg_login()
					//维修人员类型（1保洁 2保安 3维修人员）
					// if (this.userInfo.accountType != null) {
					// 	this.$wskj.to("/pagesMine/pages/ygzy")
					// } else {
					// 	this.$wskj.showModal('提示', '只有物业员工可使用该功能', false, null);
					// }
					return
				}
				if (parseInt(this.userInfo.userPermission) > 1) {
					this.$wskj.showModal('提示', '只有业主以及其家人可使用该功能', false, null);
					return
				}
				if (index == 3) { //编辑资料
					this.$wskj.to("/pagesMine/pages/zlbj")
					return
				}
				if (index == 4) { //房屋信息
					this.$wskj.to("/pagesMine/pages/fwxx")
					return
				}
				if (parseInt(this.userInfo.userPermission) < 2 && this.$wskj.isNull(uni.getStorageSync("fwInfo"))) {
					this.$wskj.showModal('提示', '请先选择房屋信息', true, (confirmed) => {
						if (confirmed) {
							this.$wskj.to("/pagesMine/pages/fwxx?type=1")
						}
					});
					return
				}
				if (index == 0) { //我的房屋
					this.$wskj.to("/pagesMine/pages/wdfw")
					return
				}
				if (index == 1) { //我的工单
					this.$wskj.to("/pagesMain/pages/bxbs_lsgd")
					return
				}

			}
		}
	};
</script>

<style>
	.center {
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: #F2F2F2;
	}

	.item {
		width: 100%;
		height: 200rpx;
		margin-top: 20rpx;
	}
</style>