<template>
	<view class="container">
		<!-- 顶部用户信息区域 -->
		<view class="header">
			<img src="../../static/my/headerImg.png" />
			<!-- 页面标题 -->
			<view class="title">我的</view>
			<!-- 头像区域 -->
			<img class="img" src="../../static/my/portrait.png" />

			<!-- 姓名区域 -->
			<view class="name" v-if="flag">张三</view>
			<!-- 用户id区域 -->
			<view class="number" v-if="flag">ID：1925689</view>
			<!-- 是否实名认证区域 -->
			<view class="real" v-if="real">
				<img src="../../static/my/true.png" />
				已实名认证
			</view>
			<view class="real2" v-if="flag" v-else @click="goPageCommon">
				去认证
				<img src="../../static/my/right2.png" />
			</view>

			<view class="login" v-if="!flag" @click="goPageLogin">去登录</view>
		</view>

		<!-- 内容区域 -->
		<view class="body">
			<!-- 订单管理区域 -->
			<view class="body_item" @click="goPageOrder">
				<img class="img" src="../../static/my/order.png" />
				订单管理
			</view>

			<!-- 常用旅客区域 -->
			<view class="body_item" @click="goPageCommon">
				<img class="img2" src="../../static/my/people.png" />
				常用旅客
			</view>

			<!-- 我是商户区域 -->
			<view class="body_item" @click="goPageShop">
				<img class="img2" src="../../static/my/shop.png" />
				我是商户
			</view>

			<!-- 设置区域 -->
			<view class="body_item" @click="goPageSet">
				<img class="img3" src="../../static/my/set.png" />
				设置
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			// 是否实名认证
			real: false,
			// 是否登录标识
			flag: false
		}
	},
	onLoad() {
		this.flag = false
	},
	onShow() {
		// console.log(121)
	},
	methods: {
		// 我是商户点击按钮回调
		goPageShop() {
			uni.navigateTo({
				url: '/pages/shop/shop'
			})
		},
		// 去登录文字回调
		goPageLogin() {
			uni.navigateTo({
				url: '/pages/login/login'
			})
		},
		// 点击订单管理按钮回调
		goPageOrder() {
			if (this.isLogin()) {
				uni.navigateTo({
					url: '/pages/orderManage/orderManage'
				})
			}
		},
		// 点击常用旅客按钮回调
		goPageCommon() {
			if (this.isLogin()) {
				uni.navigateTo({
					url: '/pages/common/common'
				})
			}
		},
		// 点击设置按钮回调
		goPageSet() {
			if (this.isLogin()) {
				uni.navigateTo({
					url: '/pages/set/set'
				})
			}
		},
		isLogin() {
			if (this.flag) {
				return true
			} else {
				uni.showToast({
					title: '请先登录',
					icon: 'none',
					mask: true
				})
				setTimeout(() => {
					uni.navigateTo({
						url: '/pages/login/login'
					})
				}, 1500)
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	position: relative;
	min-height: 100vh;
	background-color: #ebeced;

	.header {
		position: relative;
		height: 480rpx;
		color: #fff;
		overflow: hidden;

		img {
			width: 100%;
		}

		.title {
			position: absolute;
			top: 65rpx;
			left: 342rpx;
			font-size: 28rpx;
			color: #fff;
		}

		.img {
			position: absolute;
			top: 190rpx;
			left: 32rpx;
			width: 140rpx;
			height: 140rpx;
		}

		.name {
			position: absolute;
			top: 178rpx;
			left: 202rpx;
			font-size: 40rpx;
			font-weight: bold;
		}

		.number {
			position: absolute;
			top: 240rpx;
			left: 202rpx;
			font-size: 24rpx;
			opacity: 0.5;
		}

		.real {
			position: absolute;
			top: 285rpx;
			left: 202rpx;
			display: flex;
			align-items: center;
			box-sizing: border-box;
			padding-left: 13rpx;
			width: 179rpx;
			height: 42rpx;
			font-size: 24rpx;
			border-radius: 113rpx;
			background-color: rgba(255, 255, 255, 0.2);

			img {
				margin-right: 7rpx;
				width: 24rpx;
				height: 24rpx;
			}
		}

		.real2 {
			position: absolute;
			top: 285rpx;
			left: 202rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			box-sizing: border-box;
			padding-left: 13rpx;
			width: 179rpx;
			height: 42rpx;
			font-size: 24rpx;
			border-radius: 113rpx;
			background-color: rgba(255, 255, 255, 0.2);

			img {
				margin-left: 12rpx;
				width: 24rpx;
				height: 24rpx;
			}
		}

		.login {
			position: absolute;
			top: 235rpx;
			left: 202rpx;
			font-size: 40rpx;
			font-weight: bold;
		}
	}

	.body {
		position: absolute;
		top: 360rpx;
		box-sizing: border-box;
		padding: 0 30rpx;
		width: 100%;
		height: calc(100vh - 360rpx);
		border-radius: 20rpx 20rpx 0 0;
		background-color: #fff;

		.body_item {
			display: flex;
			align-items: center;
			height: 121rpx;
			font-size: 28rpx;
			border-bottom: 1rpx solid #e6e6e6;

			.img {
				margin-right: 17rpx;
				width: 53rpx;
				height: 53rpx;
			}

			.img2 {
				margin-right: 22rpx;
				width: 42rpx;
				height: 42rpx;
			}

			.img3 {
				margin-right: 18rpx;
				width: 50rpx;
				height: 50rpx;
			}
		}
	}
}
</style>
