<template>
	<view class="">
		<uni-nav-bar dark :fixed="true" background-color="#00aaff" :border="false" status-bar title="个人中心" />
		<view class="content">
			<view class="topBox">
				<view class="users">
					<view class="u-top" v-if="userInfo.account">
						<image class="img"
							src="https://tennis-oss.xzaiyp.top/2024-09-03/05f052bb-2c66-4886-8ad0-09703269690d.jpg"
							mode="widthFix"></image>
						<view class="tit">
							{{ userInfo.name }}
						</view>
					</view>
					<view class="u-top" v-else>
						<image class="img"
							src="https://tennis-oss.xzaiyp.top/2024-09-03/05f052bb-2c66-4886-8ad0-09703269690d.jpg"
							mode="widthFix"></image>
						<view class="tit">
							登录 / 注册
						</view>
					</view>
				</view>
			</view>

			<view class="lists">
				<uni-list>
					<uni-list-item v-if="userInfo.isDai == '0'" :show-extra-icon="true" :extra-icon="extraIcon1"
						showArrow title="我的报修" clickable @click="clickList" />
					<uni-list-item v-if="userInfo.isDai == '1'" :show-extra-icon="true" :extra-icon="extraIcon2" showArrow title="指派给我的维修单" clickable
						@click="toOrder" />
					<uni-list-item :show-extra-icon="true" :extra-icon="extraIcon3" showArrow title="退出登录" clickable
						@click="logout" />
				</uni-list>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
	} from 'vuex'
	export default {
		name: 'Center',
		computed: {
			...mapState(['userInfo']),
		},
		data() {
			return {
				queryParams: {
					pageNo: 1,
					pageSize: 10
				},
				orderList: [],
				extraIcon1: {
					color: '#666666',
					size: '22',
					type: 'auth'
				},
				extraIcon2: {
					color: '#666666',
					size: '22',
					type: 'chatbubble-filled'
				},
				extraIcon3: {
					color: '#666666',
					size: '22',
					type: 'closeempty'
				}
			}
		},
		onShow() {
			//用户没有登录
			if (!this.userInfo.id) {
				this.logout()
			}
		},
		methods: {

			clickList() {
				uni.navigateTo({
					url: '/pages/repairList/repairList'
				})
			},

			//退出登录
			logout() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
				uni.removeStorageSync('token');
				uni.removeStorageSync('userInfo');
				this.$store.commit('setUserInfo', {})
			},

			//跳转指派给我的维修单
			toOrder() {
				uni.navigateTo({
					url: '/pages/order/order'
				})
			}

		}
	}
</script>

<style scoped>
	.content {
		background: #F1F5F8;
		min-height: 100vh;
	}

	/* 弧形背景 */
	.topBox {
		width: 100%;
		position: relative;
		z-index: 1;
		overflow: hidden;
		padding: 20rpx 20rpx 20rpx;
		box-sizing: border-box;
	}

	.topBox::after {
		content: "";
		width: 140%;
		height: 100px;
		position: absolute;
		left: -20%;
		top: 0;
		z-index: -1;
		border-radius: 0 0 30% 50%;
		/* background: #00aaff; */
	}

	.txt {
		color: #fff;
		font-size: 30rpx;
	}

	.set-right .uni-icons {
		margin-right: 10rpx;
	}

	.users {
		display: flex;
		align-items: center;
		margin-top: 0rpx;
		padding: 0rpx 30rpx;
		box-sizing: border-box;
		height: 200rpx;
		background-color: #fff;
		box-shadow: 1px 10rpx 20rpx #ececec;
		border-radius: 12rpx;
	}

	.u-top {
		display: flex;
		justify-content: flex-start;
		align-items: center;
	}

	.users .u-top .img {
		width: 130rpx;
		height: 130rpx;
		border-radius: 50%;
		margin-right: 20rpx;
	}

	.u-top .tit {
		font-size: 30rpx;
		font-weight: 700;
		color: #333;
	}

	.u-item {
		text-align: center;
	}

	.u-item .u-tit {
		color: #757575;
		font-size: 26rpx;
		margin-top: 10rpx;
	}

	.u-item .num {
		color: #000000;
		font-size: 33rpx;
		font-weight: 700;
	}

	.bottomBox {
		padding: 20rpx;
		box-sizing: border-box;
	}

	.listBox {
		margin: -10rpx auto 0;
		padding: 20rpx;
		box-sizing: border-box;
		border-radius: 20rpx;
	}
</style>