<template>
	<view class="container">
		<view class="centerBox ">
			<view class="itemList border-linear-gradient">
				<view class="list">
					<view class="item flex" v-for="(item,index) in listAll">
						<view class="leftItem">
							<view class="itemName">
								{{item.title}}
							</view>
							<view class="itemTime margin-t-20">
								{{item.createtime|dateFormat}}
							</view>
						</view>
						<view class="rightItem">
							<view class="on text-linear-gradient">
								+{{item.money}}
							</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 {
		moneyLog
	} 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';
				moneyLog({
					page: that.page,
					limit: that.limit,
					type:"point_day_send"
				}).then((res) => {
					const list = res.data.list.map((rs) => {
						rs.money = +rs.money;
						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-weight: bold;
						font-size: 29rpx;
					}

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

				.rightItem {
					font-weight: 500;
					font-size: 30rpx;
				}
			}
		}
	}
</style>