<template>
	<view class="app-container" style="background-color: #f7f7f7;">

		<view class="page-bg">
			<view class="withdrawal-management">
				<navigator hover-class="none" url="/pages/withdrawal-management/withdrawal-management">
					<button class="withdrawal-button">提现管理</button>
				</navigator>
			</view>
			<view class="withdrawal-limit">
				<view class="limit-symbol">￥</view>
				<view class="withdrawal-volume">{{accountInfo.wallet_balance}}</view>
			</view>
			<view class="Withdrawable-text">可提现</view>
			<view class="withdrawal-content">
				<image class="withdrawal-line"
					src="https://common-1257637852.cos.ap-guangzhou.myqcloud.com/paidui-pay/withdrawal-line.png" />
			</view>
			<view class="to-be-credited">待入账：￥{{accountInfo.waiting_amount}}</view>
			<view class="divider-style"></view>

			<view class="information-id-content">
				<view class="content-id-item">
					<view class="id-text">
						用户ID：
					</view>
					<view class="id-value">
						{{accountInfo.id}}
					</view>
				</view>
			</view>


			<view class="queuing-information-content">
				<view class="recent-orders-title">
					<image class="title-stlye"
						src="https://common-1257637852.cos.ap-guangzhou.myqcloud.com/paidui-pay/title-stlye.png" />
					<view class="title-text">最近排队信息</view>
				</view>
				<view class="information-item">
				<view class="item-content" v-if="!queueList.length">
					<view class="item-content-text">暂无排队</view>
				</view>
					<view class="item-content" v-for="item in queueList" :key="item.id">
						<view class="item-content-titie">{{item.merchant.name}}：</view>
						<view class="item-content-text">购买时排队<span class="style-text">{{item.buy_queue_index}}</span>，当前<span
								class="style-text">{{item.now_queue_index}}</span>
						</view>
					</view>
					<navigator hover-class="none" url="/pages/queuing-information/queuing-information">
						<view class="see-more-content">
							<view class="see-more-text">查看更多</view>
							<view class="see-more-icon"></view>
						</view>
					</navigator>
				</view>
			</view>
			<view class="ordering-information">
				<view class="ordering-information-item" v-if="!orderList.length">
					<view class="order-number">暂无订单</view>
				</view>
				<view class="ordering-information-item" v-for="order in orderList" :key="order.out_trade_no">
					<view class="order-number">订单编号 {{order.out_trade_no}}</view>
					<view class="ordering-item-content">
						<view class="ordering-pic">
							<image class="order-chart" :src="order.merchant.logo" />
						</view>
						<view class="ordering-text">
							<view class="ordering-text-title">{{order.merchant.name}}</view>
							<view class="amount-of-money">金额：<span class="price-style">￥{{order.amount}}</span></view>
							<view class="order-time">订单时间：{{order.paid_at}}</view>
						</view>
					</view>
				</view>
			</view>
			
			<view class="load-more" @click="getOrderList">{{ hasMore ? '加载更多数据...' : '已加载完毕' }}</view>
		</view>
	</view>

</template>

<script>
	import {
		userAccountInfo,
		userQueueRebateList,
		userOrderList
	} from '../../common/api.js'

	export default {
		data() {
			return {
				accountInfo: {},
				queueList: [],
				orderList: [],
				hasMore: true,
				page: 0,
			}
		},
		onLoad() {
			this.getAccountInfo();
			this.getQueueList();
			this.getOrderList();
		},
		onReachBottom() {
			this.getOrderList()
		},
		methods: {
			getAccountInfo() {
				userAccountInfo().then(data => this.accountInfo = data)
			},
			getQueueList() {
				userQueueRebateList({
					page: 1,
					page_size: 2,
					status: 0,
					sort_type: 1
				}).then(data => this.queueList = data.list)
			},
			getOrderList() {
				if (!this.hasMore) {
					return
				}
				this.page++
				userOrderList({
					page: this.page,
					page_size: 15
				}).then(data => {
					this.orderList = [...this.orderList, ...data.list]
					this.hasMore = data.has_more
				})
			},
		}
	}
</script>

<style>
	.uni-page-body {
		background: #f7f7f7;
	}

	.page-bg {
		height: 525rpx;
		background: url("https://common-1257637852.cos.ap-guangzhou.myqcloud.com/paidui-pay/withdrawal-bg.png") no-repeat center center;
		background-size: cover;
		padding: 0 30rpx;
	}

	.withdrawal-management {
		position: absolute;
		top: 0;
		right: 0;
	}

	button.withdrawal-button {
		width: 160rpx;
		height: 60rpx;
		line-height: 60rpx;
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #fff;
		background: #FCC565;
		margin: 0;
		border-top-left-radius: 0;
		border-top-right-radius: 0;
		border-bottom-right-radius: 0;
		border-bottom-left-radius: 30rpx;
	}

	button::after {
		border: none;
	}

	.withdrawal-limit {
		display: flex;
		justify-content: center;
		align-items: baseline;
		padding-top: 30rpx;
		text-align: center;
	}

	.limit-symbol {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 30rpx;
		color: #fff;
	}

	.withdrawal-volume {
		font-family: "Din";
		font-size: 60rpx;
		color: #fff;
		font-weight: bold;
		margin-left: 10rpx;
	}

	.Withdrawable-text {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 30rpx;
		color: #fff;
		text-align: center;
		margin-top: 10rpx;
	}

	.withdrawal-content {
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 15rpx 0;
	}

	image.withdrawal-line {
		text-align: center;
		width: 200rpx;
		height: 1rpx;
		background-size: cover;
	}

	.to-be-credited {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 30rpx;
		color: #fff;
		text-align: center;
	}

	.divider-style {
		width: 690rpx;
		height: 1rpx;
		background: #F8A0A6;
		margin: 20rpx 0;
	}

	.information-id-content {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.content-id-item {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.id-text {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #fff;
	}

	.id-value {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #fff;
	}



	.queuing-information-content {
		background: #fff;
		border-radius: 20rpx;
		padding: 30rpx 0;
		margin-top: 30rpx;
	}

	.recent-orders-title {
		display: flex;
		justify-content: left;
		align-items: center;
		padding: 0 30rpx;
		border-bottom: 1rpx solid #eeeeee;
		padding-bottom: 30rpx;
	}

	image.title-stlye {
		width: 15rpx;
		height: 19rpx;
		background-size: cover;
		margin-right: 20rpx;
	}

	.title-text {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 30rpx;
		color: #454545;
		font-weight: bold;
	}

	.information-item {
		padding: 0 30rpx;
	}

	.item-content {
		display: flex;
		justify-content: left;
		align-items: center;
		margin-top: 30rpx;
	}

	.item-content-titie {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #454545;
		font-weight: bold;
	}

	.item-content-text {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #666;
	}

	span.style-text {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #F52F3E;
		font-weight: bold;
		padding: 0 15rpx;
	}

	.see-more-content {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 30rpx;
	}

	.see-more-text {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #F52F3E;
	}

	.see-more-icon {
		width: 0;
		height: 0;
		border-left: 14rpx solid #FDD5D8;
		border-top: 14rpx solid transparent;
		border-bottom: 14rpx solid transparent;
		margin-left: 10rpx;
		border-radius: 10rpx;
	}

	.ordering-information {
		padding: 30rpx;
		background: #fff;
		margin-top: 20rpx;
		border-radius: 20rpx;
		padding-top: 0;
	}

	.order-number {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 26rpx;
		color: #454545;
		padding: 30rpx 0;
	}

	.ordering-pic {
		width: 120rpx;
		height: 120rpx;
		background-size: cover;
		border-radius: 15rpx;
	}

	image.order-chart {
		width: 120rpx;
		height: 120rpx;
		background-size: cover;
		border-radius: 15rpx;
	}

	.ordering-text {
		margin-left: 30rpx;
	}

	.ordering-text-title {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 30rpx;
		color: #454545;
	}

	.amount-of-money {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #999;
		padding: 10rpx 0;
	}

	span.price-style {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #F52F3E;
	}

	.order-time {
		font-family: PingFangSC-Regular, sans-serif;
		font-size: 24rpx;
		color: #999;
	}

	.ordering-item-content {
		display: flex;
		justify-content: left;
		align-items: center;
		border-bottom: 1rpx solid #eee;
		padding-bottom: 30rpx;
	}
	
	.load-more {
		text-align: center;
		font-size: 14px;
	}
</style>