<template>
	<view class="container">
		<view class="centerBox ">
			<view class="itemList border-linear-gradient">
				<view class="list">
					<view class="item" v-for="(item,index) in listAll">
						<view class="leftItem">
							<view class="itemName flex">
								<view class="itemType">
									<view class="num text-linear-gradient">
										{{item.num}}
									</view>
									<view class="type">
										{{$t('home.认购数1')}}
									</view>
								</view>
								<view class="jg"></view>
								<view class="itemType">
									<view class="num text-linear-gradient">
										{{item.award_num}}
									</view>
									<view class="">
										{{$t('home.总量')}}
									</view>
								</view>
								<view class="jg"></view>
								<view class="itemType">
									<view class="num text-linear-gradient">
										{{item.wait_num}}
									</view>
									<view class="">
										{{$t('home.待释放')}}
									</view>
								</view>
							</view>
							<view class="itemTime margin-t-10">
								{{item.createtime|dateFormat}}
							</view>
						</view>
					</view>
				</view>
			</view>
			<u-loadmore :status="loading" line :loadmoreText="$t('base.加载更多')" :loadingText="$t('base.正在加载')"
				:nomoreText="$t('base.没有更多了')" />
		</view>
	</view>
</template>

<script>
	import {
		mapMutations
	} from "vuex";
	import {
		orderList
	} from '@/api/index.js';
	import dayjs from '@/libs/dayjs/dayjs.min.js';
	export default {
		data() {
			return {
				listAll: [],
				loading: 'loadmore', //'上拉加載更多','加載中','沒有更多'
				page: 1,
				limit: 10,
				shareNum: 0,
				itemNum: 0,
			}
		},
		filters: {
			dateFormat: function(value) {
				return dayjs(value * 1000).format('YYYY/MM/DD hh:mm:ss');
			},
		},
		onLoad(option) {
			this.getList();
		},
		onReachBottom() {
			this.getList()
		},
		methods: {
			...mapMutations('user', ['setUserInfo']),
			// 获取列表
			getList() {
				const that = this;
				if (that.loading == 'nomore' || that.loding == "loading") {
					return
				}
				that.loading = 'loading';
				orderList({
					page: that.page,
					limit: that.limit,
				}).then((res) => {
					const list = res.data.list.map((rs) => {
						rs.num = +rs.num;
						rs.award_num = +rs.award_num;
						rs.wait_num = +rs.wait_num;
						return rs
					})
					that.listAll = that.listAll.concat(list);
					if (list.length != that.limit) {
						that.loading = 'nomore'
					} else {
						that.page++
						that.loading = 'loadmore'
					}
				}).catch((res) => {
					console.log(res);
				})

			},
		},
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		line-height: 1;
		background-color: rgb(12, 8, 21);
		min-height: 100vh;
	}

	.centerBox {
		padding: 30rpx;
		color: #FFF;

		.itemList {
			border-radius: 20rpx;
			padding: 20rpx 30rpx 40rpx;

			.list {
				min-height: 700rpx;

				.item {
					border-bottom: 1px solid rgba(240, 240, 240, .3);
					padding: 20rpx 0;
				}

				.leftItem {
					.itemName {
						font-size: 24rpx;

						.itemType {

							.num {
								padding-bottom: 10rpx;
								font-weight: bold;
								font-size: 32rpx;
							}
						}
					}

					.itemTime {
						font-weight: 500;
						font-size: 22rpx;
						color: #FFFFFF;
						opacity: 0.5;
					}

					.itemType {
						text-align: center;
						flex-grow: 1;
					}

					.jg {
						height: 80rpx;
						width: 1px;
						background: linear-gradient(0deg, rgba(255, 255, 255, 0), #FFFFFF, rgba(255, 255, 255, 0));
					}
				}
			}
		}
	}
</style>