<template>
	<view class="mine-container" :style="{height: `${windowHeight}px`}">
		<!--顶部个人信息栏-->
		<view class="header-section ">
			<view class="flex  justify-between">
				<view class="flex align-center">
					<view v-if="!avatar" class="cu-avatar xl round bg-white">
						<view class="iconfont icon-people text-gray icon"></view>
					</view>
					<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round"
						mode="widthFix">
					</image>
					<view v-if="!name" @click="handleToLogin" class="login-tip">
						点击登录
					</view>
					<view v-if="name" @click="handleToInfo" class="user-info">
						<view class="u_title">
							{{ name }}
						</view>
					</view>
				</view>
				<view @click="handleToInfo" class="flex align-center peopleMes">
					<text>个人信息</text>
					<view class="iconfont icon-right" style="font-size: 12px;"></view>
				</view>
			</view>
		</view>

		<view class="content-section">
			<view class="mine-actions ">
				<view class="action-item" @click="handleBuilding">
					<text class="text">{{warehouseinfo}}</text>
				</view>
				<view class="house">
					<image src="/static/images/house.png" mode=""></image>
				</view>
			</view>

			<view class="mainbox">
				<view class="menu-item-box" @click="handleHelp">
					<view class="leftbox">
						<image src="/static/images/icon1.png" class="icon" mode=""></image>
						<view>常见问题</view>
					</view>
					<image src="/static/images/right.png" class="right" mode=""></image>
				</view>
				<view class="menu-item-box" @click="handleAbout">
					<view class="leftbox">
						<image src="/static/images/icon2.png" class="icon" mode=""></image>
						<view>关于我们</view>
					</view>
					<image src="/static/images/right.png" class="right" mode=""></image>
				</view>
				<view class="menu-item-box" @click="handleToSetting">
					<view class="leftbox">
						<image src="/static/images/icon3.png" class="icon" mode=""></image>
						<view>应用设置</view>
					</view>
					<image src="/static/images/right.png" class="right" mode=""></image>
				</view>
			</view>
			<view class="bottombtn" @click="handleLogout">
				<view class="btn">
					退出登录
				</view>

			</view>


		</view>
	</view>
</template>

<script>
	import storage from '@/utils/storage'

	export default {
		data() {
			return {
				name: this.$store.state.user.name,
				version: getApp().globalData.config.appInfo.version,
				warehouse: this.$store.state.user.warehouse,
			}
		},
		computed: {
			avatar() {
				return this.$store.state.user.avatar
			},
			windowHeight() {
				return uni.getSystemInfoSync().windowHeight - 50
			},
			warehouseinfo() {
				if (Array.isArray(this.warehouse) && this.warehouse.length > 0) {
					return '【' + this.warehouse[0].warehouseCode + '】' + this.warehouse[0].warehouseName
				}
			}
		},
		methods: {
			handleToInfo() {
				this.$tab.navigateTo('/pages/mine/info/index')
			},
			handleToEditInfo() {
				this.$tab.navigateTo('/pages/mine/info/edit')
			},
			handleToSetting() {
				this.$tab.navigateTo('/pages/mine/setting/index')
			},
			handleToLogin() {
				this.$tab.reLaunch('/pages/login')
			},
			handleToAvatar() {
				this.$tab.navigateTo('/pages/mine/avatar/index')
			},
			handleLogout() {
				this.$modal.confirm('确定注销并退出系统吗？').then(() => {
					this.$store.dispatch('LogOut').then(() => {
						this.$tab.reLaunch('/pages/index')
					})
				})
			},
			handleHelp() {
				this.$tab.navigateTo('/pages/mine/help/index')
			},
			handleAbout() {
				this.$tab.navigateTo('/pages/mine/about/index')
			},
			handleJiaoLiuQun() {
				// this.$modal.showToast('模块建设中~')
			},
			handleBuilding() {
				// this.$modal.showToast('模块建设中~')
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f5f6f7;
	}

	.mine-container {
		background: linear-gradient(180.00deg, rgb(181, 202, 245) 0%, rgb(184, 204, 245) 40.449%, rgba(213, 227, 249, 0) 87.96%);
		width: 100%;
		height: 90vh;
		overflow: hidden;
		.bottombtn {
			position: fixed;
			width: 100%;
			bottom: 140rpx;

			.btn {
				margin: 0 auto;
				width: 686rpx;
				height: 90rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				border: 2rpx solid rgb(22, 93, 255);
				border-radius: 24rpx;
				background: rgb(22, 93, 255);
				color: rgb(255, 255, 255);
				font-size: 32rpx;
				font-weight: 400;
			}

		}

		.header-section {
			padding: 40rpx 32rpx;
			color: white;
			position: relative;

			.peopleMes {
				/* 矩形 668 */
				position: absolute;
				width: 186rpx;
				height: 56rpx;
				right: 0;
				top: 54rpx;
				box-sizing: border-box;
				background: linear-gradient(137.70deg, rgb(73, 137, 255) 8.068%, rgba(98, 150, 246, 0.7) 100%);
				border-radius: 28rpx 0 0 28rpx;
				padding-left: 24rpx;
				display: flex;
				align-items: center;
			}

			.login-tip {
				font-size: 18px;
				margin-left: 10px;
			}

			.cu-avatar {
				width: 80rpx;
				height: 80rpx;
				border: 2px solid #eaeaea;
				border-radius: 24rpx;

				.icon {
					font-size: 40px;
				}
			}

			.user-info {
				margin-left: 36rpx;

				.u_title {

					color: rgb(255, 255, 255);
					font-family: 苹方-简;
					font-size: 42rpx;
					font-weight: 500;
					line-height: 59rpx;
					letter-spacing: 0%;
					text-align: left;
				}

				.s_text {
					color: rgb(255, 255, 255);
					font-family: 苹方-简;
					font-size: 24rpx;
					font-weight: 400;
					line-height: 34rpx;
					letter-spacing: 0%;
					text-align: left;
					margin-top: 10rpx;
				}
			}
		}

		.mainbox {
			border-radius: 24rpx;
			background-color: #fff;
			width: 686rpx;
			margin: 16rpx auto;
			padding: 0 24rpx;

			.menu-item-box {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 24rpx 0;
				border-bottom: 1rpx solid #C4C4C4;
			}

			.menu-item-box:last-child {
				border: none;
			}

			.leftbox {
				display: flex;
				align-items: center;

				.icon {
					width: 44rpx;
					height: 44rpx;
					margin-right: 24rpx;
				}
			}

			.right {
				width: 28rpx;
				height: 28rpx;
			}

		}

		.content-section {
			position: relative;

			.mine-actions {
				width: 686rpx;
				height: 194rpx;
				margin: 24rpx auto;
				box-sizing: border-box;
				border: 2rpx solid rgb(255, 255, 255);
				border-radius: 24rpx;
				backdrop-filter: blur(23rpx);
				background: linear-gradient(127.75deg, rgb(243, 248, 255) 5.474%, rgba(231, 239, 254, 0.78) 97.238%);
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 40rpx;
				margin-top: 0;
				.house {
					width: 152rpx;
					height: 152rpx;

					image {
						width: 152rpx;
						height: 152rpx;
					}
				}

				.action-item {

					.text {
						color: rgb(85, 105, 141);
						font-size: 28rpx;
						font-weight: 400;
					}
				}
			}
		}
	}
</style>