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.
164 lines
4.1 KiB
164 lines
4.1 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'){
|
|
var walleti=uni.getStorageSync('walleti')
|
|
var walletInfo=uni.getStorageSync('walletInfo')
|
|
console.log(walleti)
|
|
|
|
for(var i=0;i<walletInfo[this.coinType].length;i++){
|
|
console.log(walletInfo[this.coinType].address,111)
|
|
console.log(walleti,2211)
|
|
if(walletInfo[this.coinType][i].address==walleti){
|
|
console.log(1111)
|
|
var that=this
|
|
this.$EthUtil.getTokenBalance(this.coinAddress
|
|
,item.contractAddress,function(balance){
|
|
console.log(balance,123132)
|
|
that.tmoney=balance
|
|
});
|
|
var b={
|
|
name:item.chainName,
|
|
name2:item.contractName,
|
|
xname:item.chainName,
|
|
icon:item.contractIconUrlAbs,
|
|
contractAddress:item.contractAddress,
|
|
balance:this.tmoney,
|
|
};
|
|
walletInfo[this.coinType][i].coinList.push(b)
|
|
}
|
|
}
|
|
uni.setStorageSync('walletInfo',walletInfo)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
// 拿代币
|
|
getCoin(){
|
|
uni.request({
|
|
url: 'http://wallet-api.weirui0755.com/api/contract/getContractInfoList?chainName='+this.coinType, //请求接口
|
|
header: {
|
|
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
|
|
},
|
|
success: (res) => {
|
|
this.coinInfo=res.data.data
|
|
}
|
|
});
|
|
},
|
|
|
|
|
|
},
|
|
|
|
};
|
|
</script>
|
|
<style scoped>
|
|
|
|
</style>
|
|
|
|
<style>
|
|
@import './index.css';
|
|
</style>
|
|
|