<template>
	<view class="maintoP">
		<navigation :showBack="false" :bgnum="true" class="aaa">
			<image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="back" @click="back()"></image>
			<text class="big_title">
				{{i18n.NFTcollection}}
			</text>
		</navigation>
		<view class="main">
			<view class="main_con">
				<view class="flex item">
					<view class="imgcon flex2">
						<image :src="wallet.coinList[0].icon" mode="aspectFit" class="img"></image>
						<text class="tex1">{{wallet.coinList[0].name2}}</text>
					</view>
					<view class="text1">
						{{wallet.address}}
						<image src="../../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit"
							class="lfetimg"></image>
					</view>
				</view>
				<view class="item2">
					<view class="title">
							{{i18n.Contractaddress}}
					</view>
					<input type="text" v-model="caddress" value="" class="input"
						placeholder-style="color:#BEBEBE;fontSize:14px"
						:placeholder="teee1" />
				</view>
				<view class="item2">
					<view class="title">
							{{i18n.TokenID}}
					</view>
					<input type="text" v-model="tid" value="" class="input"
						placeholder-style="color:#BEBEBE;fontSize:14px" :placeholder="teee2" />
				</view>
				<view class="btn" @click="Add">
					{{i18n.Confirm}}
				</view>
			</view>

		</view>

	</view>
</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	import token from "@/utils/TokenUtil"
	export default {
		data() {
			return {
				teee1:this.$t('index').entercontractaddress,
				teee2:this.$t('index').entercontractaddress,
				caddress: '',
				tid: '',
				wallet: {},
				nftIndex: 0,
				nftContrct: [
					[]
				],
				walletInfo: {},
				address: '',
				proid: '',

			}
		},

		onLoad() {
			if (uni.getStorageSync('wallet')) {
				this.address = uni.getStorageSync('wallet').address
				this.wallet = uni.getStorageSync('wallet')
				this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address
					.substring(25, this.wallet.address.length);

			} else {
				this.wallet = uni.getStorageSync('walletInfo').BTC[0]
				this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address
				console.log(this.wallet, 111)
			}


		},
		computed: {
						i18n() {
							return this.$t('index')
						},
					},
		methods: {
			
			back() {
				uni.reLaunch({
					url: '../collectionDetail/index'
				})
			},
			async Add() {
				this.proid = uni.getStorageSync('proid')
				let params = {
					address: this.address,
					contract: this.caddress,
					tonkenId: this.tid,
					nftProjectId: this.proid
				};
				const response = await this.$api.addNftCollection(params)

				if (response.code == 200) {
					uni.showToast({
						title: this.$t('index').Successful,
						icon: 'success',
						duration: 1500
					})
					setTimeout(() => {
						uni.navigateTo({
							url: '../collectionDetail/index'
						})
					}, 1500)
				}else{
					uni.showToast({
						title: response.msg,
						icon: 'error',
						duration: 1500
					})
				}


			},






		}



	};
</script>
<style scoped>

</style>

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