<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.appletOpenid">
						<image class="img" :src="userInfo.headImage" mode="widthFix"></image>
						<view class="tit">
							{{ userInfo.nickName }}
						</view>
					</view>
					<view class="u-top" 
					v-else
					@click="$utils.navigateTo('/login/login')">
						<image class="img"
							src="https://img2.baidu.com/it/u=2953585264,744730101&fm=253&fmt=auto&app=138&f=JPEG?w=360&h=360"
							mode="widthFix"></image>
						<view class="tit">
							登录 / 注册
						</view>
					</view>
				</view>
			</view>

			<view class="listBox">
				<view class="lists">
					<uni-section title="我的订单" type="line" titleFontSize="34rpx"
						style="border-radius: 10rpx;"></uni-section>
					<view class="order-list">
						<view v-for="(item,index) in orderList" :key="item.id" class="order-item">
							<view class="order-item-top">
								<view class="order-id">{{ item.id }}</view>
								<view class="time">{{ item.createTime }}</view>
							</view>
							<div class="order-item-main">
								<div class="title">付款金额</div>
								<view class="money-detail">
									<view class="unie">￥</view>
									<view class="number">{{ item.price }}</view>
								</view>
							</div>
						</view>
					</view>
					<view v-if="false" class="no-data">
						<image src="@/static/empty/noData.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		name: 'Center',
		computed: {
			...mapState(['userInfo']),
		},
		data() {
			return {
				queryParams: {
					pageNo: 1,
					pageSize: 10
				},
				orderList: [],
				total : 0
			}
		},
		onShow() {
			if (uni.getStorageSync('token')) {
				this.$store.commit('getUserInfo')
				this.getOrderList()
			}
		},
		//滚动到屏幕底部
		onReachBottom() {
			if(this.queryParams.pageSize < this.total){
				this.queryParams.pageSize += 10
				this.getOrderList()
			}
		},
		methods: {
			//获取订单列表
			getOrderList() {
				this.$api('getPayOrderPage', this.queryParams, res => {
					this.orderList = res.result.records
					this.total = res.result.total
				})
			},
		}
	}
</script>

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

	/* 弧形背景 */
	.topBox {
		width: 100%;
		position: relative;
		z-index: 1;
		overflow: hidden;
		padding: 60rpx 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; */
		background: #000;
	}

	.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;
	}

	.order-list {
		padding-top: 20rpx;
	}

	.order-item {
		width: 100%;
		background: white;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
	}

	.order-item .order-item-top {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 80rpx;
		font-size: 24rpx;
		box-sizing: border-box;
		padding: 0rpx 20rpx;
	}

	.order-item .order-item-main {
		padding: 60rpx 0rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.order-item-main .title {
		color: #5a5a5a;
	}

	.order-item-main .money-detail {
		display: flex;
		align-items: center;
		margin-top: 20rpx;
	}

	.money-detail .unit {
		font-size: 34rpx;
	}

	.money-detail .number {
		font-size: 60rpx;
	}

	.no-data {
		padding: 30rpx;
		box-sizing: border-box;
		background-color: #fff;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

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