<template>
	<!-- <div style="padding: 40rpx 0px;">
		<scroll-view scroll-x="true" style="width: 340px;">
			<view style="width: 500px;">
				<table class="table">
				  <thead>
				    <tr>
				        <th class="color1" style="width: 100rpx;">{{ $t("common.d8") }}</th>
				        <th class="color1">{{ $t("common.amout") }}</th>
				        <th class="color1" style="width: 150rpx;">{{ $t("common.d9") }}</th>
				        <th class="color1" style="width: 100rpx;">{{ $t("common.d10") }}</th>
				        <th class="color1" style="text-align: center;width: 200rpx;">{{ $t("common.d13") }}</th>
				        <th class="color1" style="text-align: right;width: 200rpx;">{{ $t("common.d11") }}</th>
				    </tr>
				  </thead>
				  <tbody>
					  <tr v-for="(item,index) in recordsList" :key="index" style="border-bottom: 1px  solid #ccc;height: 140rpx;">
					  	<td style="text-align: center;">{{item.currency}}</td>
					  	<td style="margin-right: 20rpx;">{{item.amount}}</td>
					  	<td style="text-align: center;">{{item.rate}}%</td>
					  	<td v-if="item.type==1" style="text-align: center;">{{$t('common.d17')}}</td>
					  	<td v-if="item.type==2" style="text-align: center;">{{item.day}}{{$t('exchange.f0')}}</td>
					  	<td style="text-align: center;">{{item.financial_time}}</td>
					  	<td style="text-align: right;">
					  		<div class="jump_btn" v-if="item.type==1" data-toggle="modal" data-target="#editAddress" @click="Subscription(item)">{{$t('common.d14')}}</div>
					  		<div class="jump_btn1" v-if="item.type==2">{{$t('common.d14')}}</div>
					  	</td>
					  </tr>
				  </tbody>
				</table>
			</view>
		</scroll-view>
		
		<van-popup :show="stopsubscription" @close="stopsubscription = false" closeable custom-style="height:auto;width:90%;overflow:auto;padding-bottom:20px;border-radius:5px">
			<view>
				<view style="padding: 30rpx;border-bottom: 1px solid #ccc;">{{$t("common.d18")}}</view>
				<view style="border-bottom: 1px solid #bcbcbc;">
					<view style="margin: 0px 30rpx;">
						<view class="currency_box">
						  <view>
							  <view style="font-weight: bold;">{{subscriptionobj.currency}}</view>
							  <view style="display: flex;align-items: center;margin-top: 20rpx;" v-if="subscriptionobj.day">
								<img src="@/assets/img/hint.png" width="15" style="margin-right: 10rpx;" />
								{{$t('common.d20')}}
							  </view>
						  </view>
						  <view>
							  <view style="font-weight: bold;">
								<view v-if="subscriptionobj.day">{{subscriptionobj.day}}{{$t('exchange.f0')}}</view>
								<view v-else>
									{{$t('common.d17')}}
								</view>
							  </view>
						  </view>
						</view>
						<view style="display: flex;justify-content: space-between;padding: 40rpx 0px;">
							<view style="color: #B4B4B4;font-weight: bold;">{{$t('common.d9')}}</view>
							<view style="display: flex;align-items: center;">
								<view>{{subscriptionobj.rate}}%</view>
								<view style="display: flex;align-items: center;margin-left: 10px;"><img src="@/assets/img/rise.png" width="18" /></view>
							</view>
						</view>
						<view class="d-flex justify-between">
							<view>{{$t('assets.c0')}}</view>
							<view>{{subscriptionobj.amount}} USDT</view>
						</view>
						<view class="d-flex justify-between" style="margin: 40rpx 0px;font-size:36rpx">
							<view>{{$t('common.d21')}}</view>
							<view>
								<span style="color: #7458A8;margin-right: 10rpx;">{{subscriptionobj.interest}}</span>
								<span> USDT</span>
							</view>
						</view>
					</view>
				</view>
				<view class="d-flex justify-around">
					<v-button class="m-t-md rounded-lg" style="width: 40%;" type="red" block @click="stopsubscription = false" ref="strateBtn">
					    {{ $t("common.cancel") }}
					</v-button>
				    <v-button class="m-t-md rounded-lg" style="width: 40%;" type="green" block @click="handleUserAddress" ref="strateBtn">
				        {{ $t("common.confirm") }}
				    </v-button>
				</view>
			</view>
		</van-popup>
	</div> -->
	<view>
		<v-header class="nav-head" :title="$t('common.d14')"></v-header>
		<view style="padding: 40rpx;color: #666;">
			<view class="d-flex">
				<view @click="bool1=1" :class="bool1==1?'col-border':''">{{$t('common.d17')}}</view>
				<view @click="bool1=2" :class="bool1==2?'col-border':''" style="margin-left: 100rpx;">{{$t('common.d45')}}</view>
			</view>
			<view style="margin-top: 30rpx;font-size: 26rpx;">{{$t('common.d46')}}</view>
			<scroll-view scroll-y="true" style="height: 75vh;">
				<view v-for="(item,index) in recordsList" :key="index" class="recordsList_box" v-if="bool1==1">
					<view style="width: 160rpx;">
						<view>{{ $t("common.d8") }}</view>
						<view>{{item.currency}}</view>
					</view>
					<view style="width: 160rpx;text-align: center;">
						<view>{{ $t("common.amout") }}</view>
						<view>{{item.amount}}</view>
					</view>
					<view style="width: 200rpx;text-align: right;">
						<view>{{ $t("common.d9") }}</view>
						<view>{{item.rate}}%</view>
					</view>
					<view style="width: 160rpx;margin-top: 30rpx;">
						<view>{{ $t("option.a4") }}</view>
						<view>{{item.yield_rate}}%</view>
					</view>
					<view style="width: 160rpx;margin-top: 30rpx;text-align: center;">
						<view>{{ $t('common.d21') }}</view>
						<view>{{item.interest}}</view>
					</view>
					<view style="width: 200rpx;text-align: right;margin-top: 30rpx;">
						<view>{{ $t("common.d13") }}</view>
						<view>{{item.financial_time}}</view>
					</view>
					<view style="width: 100%;text-align: right;margin-top: 30rpx;">
						<view></view>
						<view>
							<div class="jump_btn" data-toggle="modal" data-target="#editAddress" @click="Subscription(item)">{{$t('common.d14')}}</div>
						</view>
					</view>
				</view>
				<view v-for="(item,index) in recordsList1" :key="index" class="recordsList_box" v-if="bool1==2">
					<view style="width: 160rpx;">
						<view>{{ $t("common.d8") }}</view>
						<view>{{item.currency}}</view>
					</view>
					<view style="width: 160rpx;text-align: center;">
						<view>{{ $t("common.amout") }}</view>
						<view>{{item.amount}}</view>
					</view>
					<view style="width: 200rpx;text-align: right;">
						<view>{{ $t("common.d9") }}</view>
						<view>{{item.rate}}%</view>
					</view>
					<view style="width: 160rpx;margin-top: 30rpx;">
						<view>{{$t('common.d21')}}</view>
						<view>
							<span style="color: #7458A8;margin-right: 10rpx;">{{item.interest}}</span>
							<!-- <span> USDT</span> -->
						</view>
					</view>
					<view style="width: 160rpx;margin-top: 30rpx;text-align: center;">
						<view>{{ $t("common.d10") }}</view>
						<view v-if="item.type==1" style="text-align: center;">{{$t('common.d17')}}</view>
						<view v-if="item.type==2" style="text-align: center;">{{item.day}}{{$t('exchange.f0')}}</view>
					</view>
					<view style="width: 200rpx;text-align: right;margin-top: 30rpx;">
						<view>{{ $t("common.d13") }}</view>
						<view>{{item.financial_time}}</view>
					</view>
					<view style="width: 100%;text-align: right;margin-top: 30rpx;">
						<view></view>
						<view>
							<div class="jump_btn" data-toggle="modal" data-target="#editAddress" @click="Subscription(item)">{{$t('common.d14')}}</div>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
import Wallet from "@/api/wallet";
export default {
  name: "finances-product",
  props: {
    
  },
  components: {
	
  },
  watch: {
	
  },
  created() {
    this.init()
	this.getBalance()
  },
  data() {
    return {
      recordsList:[],
      recordsList1:[],
	  subscriptionobj:{},
	  coin_name:"USDT",
	  activeCoin:{},
	  amount:0,
	  bool1:1,
	  stopsubscription:false
    };
  },
  methods: {
    init(){
		Wallet.financial_records({status:0}).then(res => {
			this.recordsList = res.data.data.filter(item => item.type === 1);
			this.recordsList1 = res.data.data.filter(item => item.type === 2);
		})
	},
	Subscription(data){
		this.subscriptionobj = data;
		this.handleUserAddress()
		// console.log(this.subscriptionobj);
	},
	handleUserAddress() {
		const data = {
			id: this.subscriptionobj.id
		}
		Wallet.financial_redemption(data).then(res => {
		  // console.log(res);
		  if(res.code==200){
		  	this.$toast(this.$t("common.success"));
		  	this.stopsubscription = false;
			this.init()
		  	this.getBalance();
		  }
		});
	},
	getBalance(){
		let data = {
		  account: 4,
		  coin_name: this.coin_name
		};
		Wallet.getBalance(data).then(res => {
		  this.activeCoin = res;
		  // console.log(res);
		});
	}
  }
};
</script>

<style scoped lang="scss">
	.color1{
		color: #908F94;
	}
	tbody tr:hover{
		background: #e9e9e9;
	}
	.jump_btn{
	  display: inline-block;
	  // min-width: 160rpx;
	  min-width: 100%;
	  height: 60rpx;
	  line-height: 56rpx;
	  text-align: center;
	  border: 1px solid #67e2da;
	  border-radius: 100rpx;
	  font-size: 30rpx;
	  padding: 0px 40rpx;
	  font-weight: 400;
	  color: #67e2da;
	  margin-top: 20rpx;
	  box-sizing: border-box;
	}
	.jump_btn1{
	  display: inline-block;
	  min-width: 160rpx;
	  height: 60rpx;
	  line-height: 56rpx;
	  text-align: center;
	  color: #999999;
	  border: 1px solid #999999;
	  border-radius: 100rpx;
	  font-size: 30rpx;
	  padding: 0px 40rpx;
	  font-weight: 400;
	  margin-top: 20rpx;
	  box-sizing: border-box;
	}
	.tr_box{
		display: flex;
		margin: 0px 20rpx;
		line-height: 100rpx;
	}
	.collapse_box{
		width: 100%;
		display: flex;
		font-size: 30rpx;
		font-weight: bold;
	}
	.collapse_box1{
		display: flex;
		font-size: 30rpx;
		font-weight: bold;
		line-height: 100rpx;
		align-items: center;
		justify-content: space-between;
	}
	.collapse_box2{
		display: flex;
		font-size: 30rpx;
		line-height: 100rpx;
		font-weight: bold;
		align-items: center;
		justify-content: space-between;
	}
	.currency_box{
		display: flex;
		align-items: center;
		padding:40rpx 0rpx 40rpx;
		justify-content: space-between;
		border-bottom: 1px solid #bcbcbc;
	}
	.box1{
		width: 26%;
		padding-left: 5px;
	}
	.box2{
		width: 25%;
	}
	.box4{
		width: 20%;
		text-align: right;
	}
	.col-border{
		color: #4097f4;
		border-bottom: 2px solid #4097f4;
	}
	.recordsList_box{
		display: flex;
		flex-wrap: wrap;
		margin:40rpx 0px;
		padding: 30rpx;
		border-radius: 20rpx;
		background-color: #f9f9f9;
		justify-content: space-between;
	}
</style>