bitcooo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

157 lines
3.9 KiB

<template>
<view class="maintoP">
<navigation :showBack="false" :bgnum="true" class="aaa">
<image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="back" @click="back()" ></image>
Add Token
</navigation>
<view class="main">
<view class="topview">
<image src="../../../../static/tongyonh/search.png" mode="aspectFit" class="searchimg"></image>
<input type="text" value="" class="topinput" @focus="goSearch"/>
</view>
<view class="title">
Hot assets
</view>
<view class="main_con">
<view class="item flex" v-for="item,index in coinInfo" :key="index">
<view class="left flex2">
<image :src="item.contractIconUrlAbs" mode="aspectFit" class="img"></image>
<view class="textcon">
<view class="text1">
{{item.contractName}}
</view>
<view class="text2">
{{item.contractAddress}}
</view>
</view>
</view>
<image src="../../../../static/tongyonh/IconGroup.png" mode="aspectFit" class="img" @click="addOther(item,index)" v-if="index!=imgindex[index]" ></image>
<image src="../../../../static/tongyonh/x-circle.png" mode="aspectFit" class="img opci" v-if="index==imgindex[index]"></image>
</view>
</view>
<view class="info_con green" :class="toTop?'goTop':''">
<image src="../../../../static/tongyonh/copy_24px_2.png" mode="aspectFit" class="copyImg"></image>
Added successfully
</view>
</view>
</view>
</template>
<script>
import cont from "@/components/navigation/navigation.vue"
import token from "@/utils/TokenUtil"
export default {
data() {
return {
coinType:'',
coinInfo:[],
imgindex:[],
walletInfo:{},
coinAddress:'',
toTop:false,
tmoney:0
}
},
onLoad(option) {
const item = JSON.parse(option.type);
console.log(item,12132)
if(uni.getStorageSync('imgindex').length>0){
this.imgindex=uni.getStorageSync('imgindex')
}
this.coinAddress=item.address
this.coinType=item.type
this.walletInfo=uni.getStorageSync('walletInfo')
this.getCoin();
},
methods: {
goSearch(){
uni.navigateTo({
url:'/pages/menu/wallet/search/index'
})
},
back(){
uni.reLaunch({
url:'/pages/menu/wallet/index'
})
},
// 添加代币到钱包
addOther(item,index){
console.log(item,444)
if(uni.getStorageSync('imgindex').length>0){
this.imgindex.push(index)
this.toTop=true
setTimeout(()=>{
this.toTop=false
},1500)
uni.setStorageSync('imgindex',this.imgindex)
}else{
this.imgindex.push(index)
this.toTop=true
setTimeout(()=>{
this.toTop=false
},1500)
uni.setStorageSync('imgindex',this.imgindex)
}
if(this.coinType=='ETH'){
const walleti=uni.getStorageSync('walleti')
const walletInfo=uni.getStorageSync('walletInfo')
console.log(walleti)
for(var i=0;i<walletInfo[this.coinType].length;i++){
if(walletInfo[this.coinType][i].address==walleti){
var that=this
this.$EthUtil.getTokenBalance(this.coinAddress
,item.contractAddress,function(balance){
console.log(balance,123132)
that.tmoney=balance
});
var b={
name:item.contractName,
xname:item.chainName,
icon:item.contractIconUrlAbs,
contractAddress:item.contractAddress,
balance:this.tmoney,
};
walletInfo[this.coinType][i].coinList.push(b)
console.log(walletInfo[this.coinType][i],22222)
uni.setStorageSync('walletInfo',walletInfo)
uni.setStorageSync('wallet',walletInfo[this.coinType][i])
}
}
}
},
// 拿代币
async getCoin(){
let params = {
chainName: this.coinType
}
const response = await this.$api.getContractInfoList(params)
this.coinInfo=response.data
},
},
};
</script>
<style scoped>
</style>
<style>
@import './index.css';
</style>