<template>
	<view class="maintoP">
		<navigation :showBack="false" :bgnum="true" class="head">
		{{i18n.NFTcollection}}
		</navigation>
		<view class="big_con">
		<view class="main">
		<view class="main_con">
			<view class="item flex" @click="showMsg(item,index)" v-for="item,index in collectinInfo" :key="index">
				<view class="left flex2">
					<image :src="item.projectIconUrlAbs" mode="aspectFit" class="img"></image>
				    <view class="textcon">
				    	<view class="text1">
							{{item.projectName}}
				    	</view>
						<view class="text2">
							{{item.collectionTotal}} collections
						</view>
						<view class="text2">
							{{item.chainName}}
						</view>
				    </view>
				</view> 
				<image src="../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="letImg"></image>
			</view>
		
		
		</view>

	<tab-bar :selectActive="2"></tab-bar>

		</view>
		</view>
	<view class="bottom_con" v-if="showbottom">
		<image src="../../../static/tongyonh/xg.png" mode="aspectFit" class="ethimg2" @click="showbottom=false"></image>
		<view class="title_con">
			Select Wallet
		</view>
		<view class="money_con">
			<view class="info_con">
				<view class="item flexx pur" @click="goDetail2(item)"     v-for="item,index in ethInfo" :key="index">
				 <view class="left flex">
				 	<image src="../../../static/tongyonh/ETH_icon.png" mode="aspectFit" class="ethimg1"></image>
				   <view class="textcon"> 
				   	<view class="text1 text111">
				   	{{item.coinList[0].name}}
				   	</view>
					<view class="text2">
					{{item.address}}
					</view>
				   </view>
				 </view>	
				<!-- <view class="gou">
				 	<image src="../../../static/tongyonh/Shape.png" mode="aspectFit" class="img"></image>
				 </view> -->
			
				
				</view>
			
		
				
			</view>
			
		</view>
	
	</view>
	<u-mask :show="showbottom"  z-index="8888"></u-mask>
	</view>
</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	import token from "@/utils/TokenUtil"
	export default {
		data() {
			return {
				address:'',
				collectinInfo:[],
				ethInfo:{},
				showbottom:false,
				test:{},
				testindex:0,
			}
		},
	
		onLoad() {
          this.ethInfo=uni.getStorageSync('walletInfo').ETH;
		  console.log( this.ethInfo,444)
			if(uni.getStorageSync('wallet')){
				this.address=uni.getStorageSync('wallet').address
			}else{
				this.address=uni.getStorageSync('walletInfo').BTC[0].address
			}

		this.getCollection();
	

		},
		computed: {
						i18n() {
							return this.$t('index')
						},
					},
		// onPullDownRefresh() {
		// 	console.log('refresh');
		// 	this.getCollection();
		// 	setTimeout(function() {
		// 		uni.stopPullDownRefresh();
		// 	}, 500);
		// },
		methods: {
			showMsg(item,index){
				this.test=item
				this.testindex=index
				if(uni.getStorageSync('wallet').type=='ETH'){
					this.showbottom=false
					this.goDetail();
				}else{
					this.showbottom=true
				}
			},
			// 拿收藏品
			async getCollection(){
				let params = {
					address: this.address
				}
				const response = await this.$api.getNftProjectList(params)
				this.collectinInfo=response.data
				
			},
	goDetail2(itemm,index){
		uni.setStorageSync('proid',this.test.id)
		uni.setStorageSync('wallet',itemm)
		uni.setStorageSync('walleti',itemm.address)
		console.log(itemm,444)
		uni.setStorageSync('nftIndex',this.testindex)
		let item = JSON.stringify(this.test)
		uni.setStorageSync('nftitem',this.test)
		uni.navigateTo({
			url:'./collectionDetail/index?type='+item
		})
		this.showbottom=false;
	},
		goDetail(itemm,index){
			uni.setStorageSync('proid',this.test.id)
			uni.setStorageSync('nftIndex',this.testindex)
			uni.setStorageSync('nftitem',this.test)
			uni.navigateTo({
				url:'./collectionDetail/index'
			})
			this.showbottom=false;
		}

		},

	};
</script>
<style scoped>

</style>

<style>
	@import './index.css';
</style>
