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.
168 lines
4.3 KiB
168 lines
4.3 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>
|
|
{{i18n.AddToken}}
|
|
</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">
|
|
{{i18n.Hotassets}}
|
|
</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!=trueIndex[index]" ></image>
|
|
<image src="../../../../static/tongyonh/x-circle.png" mode="aspectFit" class="img opci" v-if="index==trueIndex[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>
|
|
{{i18n.Addedsuccessfully}}
|
|
</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,
|
|
trueIndex:[],
|
|
}
|
|
},
|
|
computed: {
|
|
i18n() {
|
|
return this.$t('index')
|
|
},
|
|
},
|
|
onLoad() {
|
|
// 添加代币修改
|
|
if(uni.getStorageSync('imgindex').length>0){
|
|
this.imgindex=uni.getStorageSync('imgindex')
|
|
}
|
|
if(uni.getStorageSync('trueIndex').length>0){
|
|
this.trueIndex=uni.getStorageSync('trueIndex')
|
|
}
|
|
// 添加代币修改
|
|
this.coinAddress=uni.getStorageSync('wallet').address
|
|
this.coinType=uni.getStorageSync('wallet').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(index,454545)
|
|
console.log(item,444)
|
|
this.imgindex.push(index)
|
|
// 添加代币修改
|
|
for(var i=0;i<this.imgindex.length;i++){
|
|
if(this.imgindex[i]==index){
|
|
this.trueIndex[index]=index;
|
|
uni.setStorageSync('trueIndex',this.trueIndex)
|
|
}
|
|
}
|
|
// 添加代币修改
|
|
this.toTop=true
|
|
setTimeout(()=>{
|
|
this.toTop=false
|
|
},1500)
|
|
uni.setStorageSync('imgindex',this.imgindex)
|
|
// }
|
|
console.log(this.coinType,444444)
|
|
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: uni.getStorageSync('wallet').type
|
|
}
|
|
console.log(params,888888888,this.coinType)
|
|
const response = await this.$api.getContractInfoList(params)
|
|
this.coinInfo=response.data
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
};
|
|
</script>
|
|
<style scoped>
|
|
|
|
</style>
|
|
|
|
<style>
|
|
@import './index.css';
|
|
</style>
|
|
|