<template>
	<view class="container">
		<view>
			<text class="phoneText global-font">Hello,{{lrInfo.lrXm}}</text>
		</view>

		<view class="bannerBox">
			<swiper class="swiper-box" :interval="interval" autoplay indicator-dots indicator-color="#C7C7C7"
				indicator-active-color="#1aad19">
				<swiper-item v-for="(item, index) in bannerList" :key="index">
					<image src="../../static/images/banner2.png" class="imgItem" @click="bannerItemClick(item)"></image>
				</swiper-item>
			</swiper>
		</view>

		<view class="btnBox">
			<image class="btnImg" src="../../static/images/lr.png" @click="btnClick(0)" />
			<image class="btnImg img2" src="../../static/images/shqt.png" @click="btnClick(1)" />
		</view>

	</view>
</template>

<script>
	import {
		getToken
	} from '@/common/auth.js'
	import {
		getUser
	} from '@/common/auth.js'
	import {
		decryptRowData_ECB,
		decryptData_ECB
	} from '@/common/sm4.js'
	import {
		updateKhjbxx,
		infoKhjbxx
	} from '@/api/kh.js'
	export default {
		data() {
			return {
				interval: 3000,
				bannerList: [{
					image: '../../static/image/banner2.png'
				}],
				lrInfo: {},
				// 人员信息
				userInfo: {},
			}
		},
		mounted() {
			// 老人07、员工04、监管06
			if (!getToken()) {
				uni.navigateTo({
					url: '/pages/login/index'
				})
			}
			this.userInfo = getUser()
			if (this.userInfo.userType == '07') {
				this.info(this.userInfo.userId)
			}
		},
		methods: {
			info(id) {
				infoKhjbxx(id).then(res => {
					if (res.code == 200) {
						this.lrInfo = decryptData_ECB(res.data, ["lrZjhm", "lrXm", "lrHjbcxx", "lrXjdzBcxx",
							"lrCydh", "lrPoxm", "lrPoZjmh", "jhrXm", "jhrSjhm", "zlrXm", "zlrDh", "cjzh",
							"yhzh", "khmc"
						], [2, 1, 4, 4, 3, 1, 2, 1, 2, 1, 3, 5, 5, 5]);
					}
				})
			},
			btnClick(index) {
				let baseUrl = this.userInfo.userType == '07' ? '/pages/lr/base?info=' + JSON.stringify(this.lrInfo) : '/pages/lr/base'
				let url = index == 0 ? baseUrl : '/pages/test/index'
				// let url = index == 0 ? '/pages/lr/base' : '/pages/lr/test'
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style scoped>
	/* 轮播图 */
	.bannerBox {
		position: absolute;
		margin-top: 14vh;
		width: 100vw;
	}

	.swiper-box {
		width: 90%;
		height: 300rpx;
		margin: 50rpx 5vw;
		margin-top: -15%;
		margin-bottom: 20rpx;
	}

	.swiper-adsense-box {
		width: 90%;
		height: 150rpx;
		margin: 30rpx auto;
	}

	.imgItem {
		width: 100%;
		height: 100%;
	}

	.swiper-box swiper-item {
		height: 280rpx !important;
		border-radius: 15px;
		overflow: hidden;
	}

	.wx-swiper-dots .wx-swiper-dot {
		width: 45rpx;
		height: 8rpx;
		border-radius: 5rpx;
	}

	.wx-swiper-dots .wx-swiper-dot:nth-of-type(n+2) {
		margin-left: 30rpx;
	}

	.wx-swiper-dots.wx-swiper-dots-horizontal {
		position: absolute;
		bottom: 0rpx;
	}

	.phoneText {
		position: absolute;
		margin-top: 2vh;
		margin-left: 5vw;
		width: 80vw;
		height: 2vh;
		font-size: 14px;
		color: white;
		font-weight: 700;
		line-height: 2vh;
		text-align: left;
		vertical-align: top;
	}

	.container {
		height: 100vh;
		width: 100vw;
		background: linear-gradient(to bottom, #07bf61 0%, #fff 30%, #F8FCFF 100%);
	}

	/* 按钮 */
	.btnBox {
		position: absolute;
		width: 90%;
		display: flex;
		margin: 30vh 5vw;
		margin-bottom: 10rem;
	}

	.btnImg {
		width: 45vw;
		height: 33vw;
		display: block;
	}

	.img2 {
		margin-left: 5vw;
	}
</style>