<template>
	<!-- <div>
		<table class="w-max">
		  <thead>
		    <tr class="tr_box">
		        <div class="color1" style="width: 25%;">{{ $t("common.d8") }}</div>
		        <div class="color1" style="width: 25%;">{{ $t("common.d9") }}</div>
		        <div class="color1" style="width: 25%;text-align: center;">{{ $t("common.d10") }}</div>
		        <div class="color1" style="width: 25%;text-align: right;">{{ $t("common.d11") }}</div>
		    </tr>
		  </thead>
		  <tbody>
			<el-collapse accordion>
				<el-collapse-item v-for="(item,index) in userAdressList" :key="index">
					<div slot="title" class="collapse_box">
						<div class="box1">{{item.coin_name}}</div>
						<div class="box2">{{item.rate}}%</div>
						<div style="width: 27%;">{{$t('common.d16')}}</div>
						<div class="box4"></div>
					</div>
					<div class="collapse_box1">
						<div class="box1"></div>
						<div class="box2">{{item.rate}}%</div>
						<div style="width: 31%;">{{$t('common.d17')}}</div>
						<div class="box4">
							<div class="jump_btn" data-toggle="modal" data-target="#editAddress"
							@click="Subscription({rate:item.rate,coin_name:item.coin_name,index:1,coin_id:item.coin_id})">{{$t('common.d12')}}</div>
						</div>
					</div>
					<div v-for="(items,indexs) in item.params" :key="indexs" class="collapse_box2">
						<div class="box1"> </div>
						<div class="box2">{{items.fixed_rate}}%</div>
						<div style="width: 31%;">{{items.day}}{{$t('exchange.f0')}}</div>
						<div class="box4">
							<div class="jump_btn" data-toggle="modal" data-target="#editAddress"
							@click="Subscription1({...items,coin_name:item.coin_name,coin_id:item.coin_id})">{{$t('common.d12')}}</div>
						</div>
					</div>
				</el-collapse-item>
			</el-collapse>
		  </tbody>
		</table>
		
		<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 style="display: flex;align-items: center;justify-content: space-between;border-bottom: 1px solid #bcbcbc;padding:40rpx 0rpx 40rpx;">
						  <view>
							  <view style="font-weight: bold;">{{subscriptionobj.coin_name}}</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>
							<view>{{$t('assets.c0')}}</view>
							<view style="margin-top: 20rpx;">
								<v-input v-model="amount" class="h-50 p-x-sm p-y-xxs color-light bg-form-panel-3" :placeholder="$t('exchange.c5')">
								  <template #right>
								    <view class="color-default color-light">USDT</view>
								  </template>
								</v-input>
							</view>
						</view>
						<view style="margin: 40rpx 0px;">
							<span style="margin-right: 20rpx;">{{$t('common.d22')}}</span>
							<span>{{activeCoin.usable_balance}} USDT</span>
						</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="define" ref="strateBtn">
				        {{ $t("common.confirm") }}
				    </v-button>
				</view>
			</view>
		</van-popup>
	</div> -->
	<view>
		<v-header class="nav-head" :title="$t('common.d12')"></v-header>
		<view style="padding: 40rpx 40rpx;">
			<view class="d-flex" style="flex-wrap: wrap;" v-for="(item,index) in userAdressList" :key="index">
				<view class="ratebox" :class="Subscriptionindex==null?'Subscriptionbox':''" @click="Subscriptiontab({index:1,coin_id:item.coin_id,fixed_rate:item.rate})">
					<view>{{$t('common.d17')}}</view>
					<view>{{item.rate}}%{{$t('exchange.e3')}}</view>
				</view>
				<view class="ratebox" v-for="(items,indexs) in item.params" @click="Subscriptiontab({...items,index:2,coin_id:item.coin_id,indexs1:indexs})"
				:class="Subscriptionindex==indexs?'Subscriptionbox':''">
					<view>{{items.day}}{{$t('exchange.f0')}}</view>
					<view>{{items.fixed_rate}}%{{$t('exchange.e3')}}</view>
				</view>
			</view>
			<view style="margin-top: 40rpx;">
				<view>{{$t('common.d29')}}</view>
				<view style="margin: 30rpx 0rpx;">
					<v-input v-model="amount" class="h-50 p-x-sm p-y-xxs color-light" style="border: 1px solid #ccc;border-radius: 20rpx;" :placeholder="$t('common.d30')">
					  <template #right>
					    <view class="color-default color-light">USDT</view>
					  </template>
					</v-input>
				</view>
				<view class="d-flex">
					<view>{{$t('common.d22')}}</view>
					<view class="m-l-ms">{{activeCoin.usable_balance}} USDT</view>
					<!-- <view class="m-l-lg" style="color: #b5b500;" @click="_router.push('/pages/transfer/index')">{{$t('common.d31')}}</view> -->
					<view class="m-l-lg" style="color: #b5b500;" @click="_router.push(userinfo.primary_status!=1?'/pages/auth/index':'/pages/assets/recharge')">{{$t('common.d31')}}</view>
				</view>
				<view class="text1">{{$t('common.d32')}}<span style="color: #4097f4;">{{parseInt(amount/100)*20}}BXPE</span>{{$t('common.d33')}}</view>
				<view style="font-size: 24rpx;">
					{{$t('common.d34')}}：<br />
					{{$t('common.d35')}}<br />
					{{$t('common.d36')}}
				</view>
				<view class="d-flex" style="margin: 40rpx 0rpx;">
					<view @click="bool1=1" style="margin-right: 80rpx;" :class="bool1==1?'col-border':''">{{$t('common.d37')}}</view>
					<view @click="bool1=2" :class="bool1==2?'col-border':''">{{$t('common.d38')}}</view>
				</view>
				<view v-if="bool1==1">
					<view class="d-flex justify-between m-b-lg">
						<view>{{$t('common.d39')}}</view>
						<view style="color: ##60c08c;">{{amount*(subscriptionobj.fixed_rate/100)}}USDT</view>
					</view>
					<view>{{$t('common.d40')}}</view>
				</view>
				<view v-if="bool1==2">
					<view style="margin-top: 20rpx;">
						<view>1、{{$t('common.d41')}}</view>
						<view>{{$t('common.d42')}}</view>
					</view>
					<view style="margin-top: 20rpx;">
						<view>2、{{$t('common.d14')}}</view>
						<view>{{$t('common.d43')}}</view>
					</view>
					<view style="margin-top: 20rpx;">
						<view>2、{{$t('common.d47')}}</view>
						<view>
							<table style="width: 100%;margin-top: 20rpx;" border="1" cellspacing="0" cellpadding="5">
								<thead>
								  <tr style="background-color: #dfdfdf;color: #868686;">
								    <th style="width: 33%;">{{$t('common.d48')}}</th>
								    <th style="width: 33%;">{{$t('common.d49')}}</th>
								    <th style="width: 33%;">{{$t('common.d50')}}</th>
								  </tr>
								</thead>
								<tbody>
									<tr v-for="(items,indexs) in tablelist" :key="indexs" style="color: #868686;">
										<td style="width: 33%;text-align: center;">{{items.vip}}</td>
										<td style="width: 33%;text-align: center;">{{items.money}}</td>
										<td style="width: 33%;text-align: center;">{{items.proportion}}</td>
									</tr>
								</tbody>
							</table>
						</view>
					</view>
				</view>
			</view>
			<view style="background-color: #fff;height: 150rpx;position: fixed;bottom: 0rpx;display: flex;align-items: center;">
				<view class="bottom_box" @click="define">{{$t('auth.b3')}}</view>
			</view>
		</view>
		<view style="height: 136rpx;"></view>
	</view>
</template>

<script>
import Wallet from "@/api/wallet";
export default {
  name: "finances-product",
  props: {
    
  },
  components: {
	
  },
  computed: {
	
  },
  watch: {
	
  },
  created() {
    this.init()
	this.getBalance()
  },
  data() {
    return {
      userAdressList:[],
	  subscriptionobj:{
		coin_id:1,
		index:1,
		fixed_rate:0.50
	  },
	  coin_name:"USDT",
	  activeCoin:{},
	  amount:null,
	  bool1:1,
	  stopsubscription:false,
	  Subscriptionindex:null,
	  userinfo:uni.getStorageSync("user"),
	  tablelist:[
		{"vip":"v1","money":"10000","proportion":"20%"},
		{"vip":"v2","money":"100000","proportion":"40%"},
		{"vip":"v3","money":"500000","proportion":"60%"},
		{"vip":"v4","money":"1000000","proportion":"80%"},
		{"vip":"v5","money":"10000000","proportion":"100%"}
	  ]
    };
  },
  methods: {
    init(){
		Wallet.activity().then(res => {
			this.userAdressList = res.data;
			// console.log(this.userAdressList);
		})
	},
	// Subscription(data){
	// 	this.subscriptionobj = data;
	// 	this.stopsubscription = true
	// 	// console.log(this.subscriptionobj);
	// },
	// Subscription1(data){
	// 	data.index = 2;
	// 	data.rate = data.fixed_rate;
	// 	// data.coin_name = 2;
	// 	this.subscriptionobj = data;
	// 	this.stopsubscription = true
	// 	// console.log(this.subscriptionobj);
	// },
	Subscriptiontab(data){
		if(data.index==1){
			this.Subscriptionindex = null;
			this.subscriptionobj = data;
		}else{
			this.Subscriptionindex = data.indexs1;
			this.subscriptionobj = data;
		}
		
	},
	define() {
		const data = {
			amount: this.amount,
			coin_id: this.subscriptionobj.coin_id,
			type: this.subscriptionobj.index,
			day: this.subscriptionobj.day?this.subscriptionobj.day:''
		}
		// console.log(data);
		Wallet.financialNow(data).then(res => {
		  // console.log(res);
		  if(res.code==200){
			this.amount = '';
			this.$toast(this.$t("common.success"));
			this.getBalance();
		  }
		});
	},
	getBalance(){
		let data = {
		  account: 4,
		  coin_name: this.coin_name
		};
		Wallet.getBalance(data).then(res => {
		  this.activeCoin = res.data;
		  // console.log(res);
		});
	}
  }
};
</script>
<style>
	
</style>
<style scoped lang="scss">
	::v-deep .el-collapse-item__header{
		line-height: 15px !important;
	}
	::v-deep .collapse_box{
		align-items: center;
	}
	.color1{
		color: #908F94;
	}
	tbody tr:hover{
		background: #e9e9e9;
	}
	.jump_btn{
	  display: inline-block;
	  min-width: 80px;
	  height: 35px;
	  line-height: 33px;
	  text-align: center;
	  color: #fff;
	  border: 1px solid #444444;
	  border-radius: 50px;
	  font-size: 15px;
	  padding: 0px 20px;
	  font-weight: 400;
	  color: #000;
	  box-sizing: border-box;
	}
	.tr_box{
		display: flex;
		margin: 0px 10px;
		padding: 40rpx 0px;
		// line-height: 50px;
	}
	.collapse_box{
		width: 100%;
		display: flex;
		font-size: 15px;
		font-weight: bold;
	}
	.collapse_box1{
		padding: 20rpx 0px;
		display: flex;
		font-size: 15px;
		font-weight: bold;
		line-height: 15px;
		align-items: center;
		justify-content: space-between;
	}
	.collapse_box2{
		padding: 20rpx 0px;
		display: flex;
		font-size: 15px;
		// line-height: 50px;
		font-weight: bold;
		align-items: center;
		justify-content: space-between;
	}
	.box1{
		width: 26%;
		padding-left: 5px;
	}
	.box2{
		width: 25%;
	}
	.box4{
		width: 40%;
		text-align: right;
	}
	.ratebox{
		width: 150rpx;
		padding: 20rpx;
		font-size: 25rpx;
		margin-top: 20rpx;
		margin-right: 28rpx;
		border-radius: 10rpx;
		border: 1px solid #757575;
	}
	.text1{
		font-size: 34rpx;
		font-weight: bold;
		text-align: center;
		padding: 30rpx 0rpx;
		border-bottom: 2px solid #ccc;
	}
	.col-border{
		color: #4097f4;
		border-bottom: 2px solid #4097f4;
	}
	.bottom_box{
		color: #fff;
		width: 660rpx;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		background-color: #585f69;
	}
	.Subscriptionbox{
		width: 150rpx;
		color: #4097f4;
		padding: 20rpx;
		font-size: 25rpx;
		border-radius: 10rpx;
		border: 1px solid #4097f4;
	}
</style>