<template>
	<view class="personal_record">
		<view class="p_e_top">
			<view class="p_top_item">
				<view class="">投入金额</view>
				<view class="color-green">{{ item.money + " " + item.investCoin  }}</view>
			</view>
			<view class="p_top_item">
				<view class="">个人收益</view>
				<view class="color-green">{{ recordMoney() + " " + item.settleAsset }}</view>
			</view>
		</view>
		<view class="p_e_end">
			<view class="p_end_item">
				<view class="">时间</view>
				<view class="color-black">{{ timeOptin(item.settletime * 1000) }}</view>
			</view>
			<view class="p_end_item">
				<view class="">总收益</view>
				<view class="color-black">{{ item.settlefee + " " + item.settleAsset  }}</view>
			</view>
			<view class="p_end_item">
				<view class="">手续费</view>
				<view class="color-black">{{ item.serivcefee + " " + item.settleAsset  }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		props:{
			item:{
				type: Object,
				default: () => {
				    return {}
				}
			}
		},
		methods:{
			recordMoney(){
				let num = 0;
				let a = Number(this.item.settlefee);
				let b = Number(this.item.serivcefee);
				num = (a - b).toFixed(8);
				return num
			},
			timeOptin(timestamp){
				const date = new Date(timestamp);
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份從0開始，所以要加1
				const day = String(date.getDate()).padStart(2, '0');
				const hours = String(date.getHours()).padStart(2, '0');
				const minutes = String(date.getMinutes()).padStart(2, '0');
				const seconds = String(date.getSeconds()).padStart(2, '0');
				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
			},
		}
	}
</script>

<style scoped lang="scss">
	.personal_record{
		color: #A4A4A4;
		padding: 0 20rpx;
		box-sizing: border-box;
		.p_e_top{
			.color-green{
				color: #1ABA84;
				font-weight: 700;
				margin: 10rpx 0;
			}
			.p_top_item{
				display: flex;
				justify-content: space-between;
				align-items: center;
			}
		}
		.p_e_end{
			margin-top: 20rpx;
			background-color: #F4F6F8;
			padding: 10rpx 20rpx 20rpx 20rpx;
			box-sizing: border-box;
			border-radius: 20rpx;
			.p_end_item{
				display: flex;
				justify-content: space-between;
				margin-top: 20rpx;
				.color-black{
					color: #000;
				}
			}
		}
	}
</style>