<template>
	<view class="container">
		<!-- list -->
		<view style="padding: 20rpx;">
			<view class="popular" v-for="item in accountOrderData" :key="item.id">
				<view class="gameitem">
					<view class="g_img">
						<image :src="publicURL + item.accountinfo.img"></image>
					</view>
					<view class="g_rig">
						<view class="g_top">
							<view class="g_name">
								{{ item.accountinfo.type_cn }}
							</view>
							<view class="g_btn">
								交易成功
							</view>
						</view>
						<view class="g_bottom">
							<view class="ga_cont">
								{{ timeOptions(item.paytime * 1000) }}
							</view>
							<view class="ga_money">
								{{ item.usdt }}
							</view>
						</view>
					</view>
				</view>
				<view class="link">
					<view class="">
						下載鏈接：{{ item.accountinfo.reflink }}
					</view>
					<image @tap="copyAdress(item.accountinfo.reflink)" src="/static/fuzhi.png"
						style="width: 30rpx;height: 30rpx;margin-left: 10px;"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {BASE_URL} from '@/request/config.js'
	import {_getaccountorder} from '@/request/api.js'
	export default {
		data() {
			return {
				publicURL:"",
				accountOrderData:[],
				searchObj:{
					page: 1,
					listrow:99999
				},
			};
		},
		mounted() {
			this.publicURL = BASE_URL;
			this.getAccountRecordsList();
		},
		methods: {
			timeOptions(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 = date.getHours();
				const moinutes = String(date.getMinutes()).padStart(2, '0'); // 月份从0开始，所以要加1
				const seconds = String(date.getSeconds()).padStart(2, '0');
				return `${year}-${month}-${day} ${hours}:${moinutes}:${seconds}`;
			},
			async getAccountRecordsList(){
				let res = await _getaccountorder(this.searchObj);
				if(res.code === 1){
					this.accountOrderData = res.data.data;
				}
			},
			copyAdress(adress) {
				uni.setClipboardData({
					data: adress,
					success: () => {
						uni.showToast({
							title: '複製成功',
							icon: 'success'
						})
					}
				})
			},
			userMoneyAdressOptions(data) {
				let start = data.substring(0, 20);
				let end = data.substring(data.length - 4);
				let middle = "…";
				let finalString = start + middle + end;
				return finalString
			},
		}
	}
</script>

<style lang="scss">
	.container {
		border-top: 1px solid dimgrey;
		width: 100vw;
		min-height: 100vh;
		padding: 10px;
		box-sizing: border-box;
		background-color: #020235;

		image {
			width: 100%;
			height: 100%;
		}

		.link {
			font-size: 24rpx;
			color: #D7D8E6;
			display: flex;
			align-items: center;
		}
	}

	.popular {
		background-color: #383d84;
		padding: 30rpx;
		border-radius: 20rpx;
		color: #fff;
		width: 100%;
		box-sizing: border-box;
		position: relative;
		margin-bottom: 30rpx;

		.p_top {
			display: flex;
			align-items: center;
			justify-content: space-between;
			background-color: #fdf7f2;
			width: 100%;
			height: 60rpx;
			font-size: 28rpx;
			border-radius: 20rpx;
			margin-bottom: 30rpx;
			padding: 0 20rpx;
			box-sizing: border-box;

			.tit {
				color: #EAA97D;
				font-size: 24rpx;
			}
		}

		.gameitem {
			width: 100%;
			height: 160rpx;
			display: flex;
			padding: 1rpx;
			align-items: center;
			margin-bottom: 20rpx;
			border-bottom: 1rpx solid #3c4087;

			.g_img {
				width: 120rpx;
				height: 120rpx;
				background-color: #51599b;
				border-radius: 20rpx;
			}

			.g_rig {
				flex: 1;
				padding: 1rpx;
				margin-left: 20rpx;
				display: flex;
				justify-content: space-between;
				flex-direction: column;

				.g_top {
					display: flex;
					justify-content: space-between;
					margin-bottom: 20rpx;

					.g_name {
						font-size: 26rpx;
						color: #fff;
					}

					.g_btn {
						font-size: 22rpx;
						color: #1ABA84;
						position: absolute;
						right: 4%;
						top: 15%;
					}
				}

				.g_bottom {
					display: flex;
					justify-content: space-between;
					align-items: center;
				}

				.ga_cont {
					font-size: 22rpx;
					color: #D7D8E6;
					display: -webkit-box;
					/* 将对象作为弹性伸缩盒子模型显示 */
					-webkit-box-orient: vertical;
					/* 从上到下垂直排列子元素 */
					-webkit-line-clamp: 2;
					/* 限制显示的行数为2行 */
					overflow: hidden;
					/* 溢出隐藏 */
					text-overflow: ellipsis;
				}
			}
		}
	}
</style>