<template>
	<view class="page">
		<!-- 顶部导航 -->
		<u-navbar title-width='300' title='' :is-back="false" :border-bottom="false"
			:background="{background:'rgba(0,0,0,0)'}" :isFixed="true"></u-navbar>
		<view class="index-navbar">
			<view class="" style="position: relative;;">
				<view class="back"></view>
			</view>
		</view>
		<view class="pad">
			<view v-if="login" class="unlogin">
				{{mine.username}}
			</view>
			<view v-else class="unlogin" @click="tologin">
				登录/注册
			</view>
			<view class="order u-flex u-row-between" @click="toorder">
				<view class="">
					<u-icon name="order"></u-icon>
					<text style="margin-left: 26rpx;">我的订单</text>
				</view>
				<u-icon name="arrow-right" color="rgba(0,0,0,0.3)"></u-icon>
			</view>
			<view class="box">
				<view class=" u-flex u-row-between" @click="tocard">
					<view class="">
						<u-icon name="coupon"></u-icon>
						<text style="margin-left: 26rpx;">我的体验卡</text>
					</view>
					<u-icon name="arrow-right" color="rgba(0,0,0,0.3)"></u-icon>
				</view>
				<view class=" u-flex u-row-between " style="margin-top: 64rpx;" @click="tosetting">
					<view class="">
						<u-icon name="setting"></u-icon>
						<text style="margin-left: 26rpx;">设置</text>
					</view>
					<u-icon name="arrow-right" color="rgba(0,0,0,0.3)"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				login: '',
				mine: {  
					username:''
				}
			};
		},
		methods: {
			getUserinfo() {
				this.$u.post('api/user/getUserinfo').then(res => {
					this.mine = res
				})
			},
			toorder() {
				uni.navigateTo({
					url: '/pages/mine/myorder'
				})
			},
			tocard() {
				uni.navigateTo({
					url: '/pages/mine/card'
				})
			},
			tosetting() {
				uni.navigateTo({
					url: '/pages/mine/setting'
				})
			},
			tologin() {
				uni.reLaunch({
					url: "/pages/login/login"
				})
			}
		},
		onLoad() {
			if (uni.getStorageSync('token')) {
				this.login = true
				this.getUserinfo()
			}
		}
	}
</script>

<style lang="scss">
	.page {
		height: 95vh;
		position: relative;
		z-index: 1;
		background: #F4F5F7;
	}

	.pad {
		padding: 0 28rpx;
		height: 95vh;
		z-index: 1;
	}

	.box {
		width: 694rpx;
		height: 220rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 42rpx 28rpx 0 32rpx;
		margin-top: 20rpx;

	}

	.unlogin {
		font-size: 44rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		color: #222222;
		margin-left: 20rpx;
	}

	.order {
		width: 694rpx;
		height: 96rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 30rpx 28rpx 30rpx 34rpx;
		margin-top: 66rpx;
	}

	.index-navbar {
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		z-index: -1;

		// overflow: hidden;
		.back {
			position: absolute;
			top: 0;
			left: 0;
			z-index: -1;
			width: 100vw;
			height: 394rpx;
			background: linear-gradient(180deg, #D7F5EB 0%, #FFFFFF 100%);
		}
	}
</style>