<template>
	<view class="container">
		<view class="status_bar"><!-- 这里是状态栏 --></view>
		<view class="content-money">
			<view class="body-title">
				<view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
				<view class="header">服务器兑换</view>
			</view>
			<view class="content-bg"><image src="../../static/img/fwq-bg.png" mode=""></image></view>
			<view class="money">
				<view class="num">{{ djjf }}</view>
				<view class="font">我的拼团冻结积分</view>
				<view class="all" @click="nav('/pages/money/frozen')">查看明细</view>
			</view>
		</view>
		<view class="main">
			<view class="main-title">
				<image src="../../static/icon/f-l.png" mode=""></image>
				<view class="title-font">热门兑换</view>
				<image src="../../static/icon/f-r.png" mode=""></image>
			</view>
			<view class="main-box">
				<view class="main-item" v-for="(item, index) in list" :key="index">
					<view class="item-bg"><image :src="item.logo" mode=""></image></view>
					<view class="item-info">
						<view class="item-name">{{ item.name }}</view>
						<view class="item-tip">合约周期：{{ item.first_step_time + item.second_step_time }}天 + {{ item.third_step_time }}天</view>
						<view class="item-tip">有效空间：{{ item.step }}T</view>
						<view class="price">
							{{ item.cost_money*1 }}
							<text>{{ item.cost_money_type}}</text>
						</view>
						<view class="btn" @click="go(item)">立即兑换</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
import { mining } from '@/api/market.js';
import { wallet } from '@/api/finance.js';
export default {
	data() {
		return {
			tabCurrent: '全部',
			tabType: 1,
			list: [],
			buyId: '',
			password: '',
			num: '',
			djjf:'',
		};
	},
	onLoad(option) {
		wallet({}).then(({ data }) => {
			const obj = this
			const arr = Object.keys(data.back);
			arr.forEach(e => {
				if(e == 'USDL'){
					obj.djjf = (data.back[e].money.money*1)
				}
			});
		});
		this.loadData();
	},
	onShow() {},
	//下拉刷新
	onPullDownRefresh() {
	},
	methods: {
		nav(url) {
			uni.navigateTo({
				url
			});
		},
		go() {
			uni.navigateTo({
				url:'/pages/market/details'
			})
		},
		// 点击返回 我的页面
		toBack() {
			uni.navigateBack({
				
			})
		},
		// 请求载入数据
		async loadData() {
			let obj = this;
			uni.showLoading({
				title: '加载中...'
			});
			mining({
				page: 1,
				limit: 1000
			}).then(({ data }) => {
				uni.hideLoading();
				console.log(data.data, '9999999999999999999999999999999999');
				obj.list = data.data.map(e => {
					e.step = +e.step;
					e._cost_money = +e._cost_money.replace(e.cost_money_type, '') + e.cost_money_type;
					return e;
				});
				console.log(obj.list, 'obj.list++++++++++++');
			});
		},
		go(ls) {
			uni.navigateTo({
				url: '/pages/market/details?id=' + ls.id + '&type=' + ls.type
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background: #ffffff;
	height: 100%;
}
.status_bar {
	height: var(--status-bar-height);
	width: 100%;
}
.content-money {
	padding-bottom: 30rpx;
	position: relative;
	height: 448rpx;
	.content-bg {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		width: 750rpx;
		height: 448rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
	.body-title {
		height: 80rpx;
		text-align: center;
		font-size: 35rpx;
		position: relative;
		.header {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #fffeff;
			height: 80rpx;
			font-size: 36rpx;
			font-weight: 700;
			z-index: 9;
			display: flex;
			justify-content: center;
			align-items: center;
		}
		.goback-box {
			position: absolute;
			left: 18rpx;
			top: 0;
			height: 80rpx;
			display: flex;
			align-items: center;
		}

		.goback {
			z-index: 100;
			width: 34rpx;
			height: 34rpx;
		}
	}
}
.money {
	position: relative;
	z-index: 10;
	padding-top: 64rpx;
	display: flex;
	flex-direction: column;
	align-items: center;
	.num {
		font-size: 84rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #ffffff;
	}
	.font {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #ffffff;
	}
	.all {
		margin-top: 20rpx;
		width: 194rpx;
		height: 60rpx;
		line-height: 60rpx;
		border: 1px solid #ffffff;
		border-radius: 30rpx;
		font-size: 26rpx;
		font-family: SourceHanSansCN;
		font-weight: 500;
		color: #ffffff;
		text-align: center;
	}
}
.main {
	margin-top: 26rpx;
	.main-title {
		display: flex;
		justify-content: center;
		align-items: center;
		image {
			width: 24rpx;
			height: 24rpx;
		}
		.title-font {
			width: 170rpx;
			font-size: 34rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #2E58FF;
			text-align: center;
		}
	}
	.main-box {
		padding: 16rpx 20rpx 70rpx;
		.main-item {
			margin-top: 20rpx;
			background: #FFFFFF;
			box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
			border-radius: 10rpx;
			padding: 14rpx;
			display: flex;
			justify-content: flex-start;
			.item-bg {
				width: 260rpx;
				height: 260rpx;
				flex-shrink: 0;
				image {
					width: 100%;
					height: 100%;
				}
			}
			.item-info {
				position: relative;
				margin-left: 30rpx;
				padding-top: 20rpx;
				width: 100%;
				.item-name {
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333333;
				}
				.item-tip {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #666666;
				}
				.price {
					margin-top: 70rpx;
					font-size: 40rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #E83F30;
					text {
						font-size: 22rpx;
					}
				}
			}
			.btn {
				position: absolute;
				right: 24rpx;
				bottom: 34rpx;
				width: 141rpx;
				height: 50rpx;
				background: linear-gradient(0deg, #2E58FF, #32C6FF);
				border-radius: 25rpx;
				text-align: center;
				line-height: 50rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
			}
		}
	}
}
</style>
