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.
239 lines
6.5 KiB
239 lines
6.5 KiB
<template>
|
|
<view class="main">
|
|
<view class="flex">
|
|
<view class="topview">
|
|
<image src="../../../../static/tongyonh/search.png" mode="aspectFit" class="searchimg"></image>
|
|
<u-input @input="getSearchContract()" placeholderStyle="fontSize:12px;color:#D0D0D2" :placeholder="teee" v-model="params.searchName" :focus="true" :type="type" :border="border" class="custom-style" />
|
|
</view>
|
|
<text class="text" @click="back"> {{i18n.Cancel}}</text>
|
|
</view>
|
|
<u-empty font-size="24" :text="aotext" mode="list" v-if="valueNu"></u-empty>
|
|
|
|
<view class="main_con">
|
|
<scroll-view :scroll-y="true" style="max-height: 1080rpx;"
|
|
@scrolltolower="scrollToPage" lower-threshold="50">
|
|
<view class="item flex" v-for="item,index in conInfo" :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="trueIndex[index]!=item.contractAddress" ></image>
|
|
<image src="../../../../static/tongyonh/backj.png" mode="aspectFit" class="img2" v-if="item.contractAddress==trueIndex[index]" @click="removeOther(item,index)"></image>
|
|
</view>
|
|
</scroll-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>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
//
|
|
// No related tokens found
|
|
return {
|
|
teee:this.$t('index').tela,
|
|
coinType:'',
|
|
imgindex:[],
|
|
walletInfo:{},
|
|
coinAddress:'',
|
|
toTop:false,
|
|
tmoney:0,
|
|
trueIndex:[],
|
|
aotext: this.$t('index').thetokenname,
|
|
type: 'text',
|
|
valueNu:true,
|
|
show: false,
|
|
border: false,
|
|
conInfo:[],
|
|
isNoData: false,
|
|
params:{
|
|
pageNum:1,
|
|
pageSize:10,
|
|
orderByColumn:'',
|
|
searchName:'',
|
|
}
|
|
}
|
|
},
|
|
onPullDownRefresh() {
|
|
this.conInfo=[];
|
|
this.params.pageNum =1;
|
|
this.getSearchContract();
|
|
setTimeout(function() {
|
|
uni.stopPullDownRefresh();
|
|
}, 500);
|
|
},
|
|
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')
|
|
},
|
|
methods: {
|
|
scrollToPage() {
|
|
if (!this.isNoData) {
|
|
this.params.pageNum = this.params.pageNum + 1;
|
|
this.getSearchContract('scroll');
|
|
}
|
|
},
|
|
// 添加代币到钱包
|
|
|
|
addOther(item,index){
|
|
console.log(index,454545)
|
|
console.log(item,444)
|
|
this.imgindex.push(item.contractAddress)
|
|
// 添加代币修改
|
|
for(var i=0;i<this.imgindex.length;i++){
|
|
if(this.imgindex[i]==item.contractAddress){
|
|
this.trueIndex[index]=item.contractAddress;
|
|
uni.setStorageSync('trueIndex',this.trueIndex)
|
|
}
|
|
}
|
|
// 添加代币修改
|
|
this.toTop=true
|
|
uni.showLoading({
|
|
title: 'loading',
|
|
mask: true
|
|
})
|
|
setTimeout(()=>{
|
|
uni.hideLoading()
|
|
this.toTop=false
|
|
},500)
|
|
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.abbreviation,
|
|
xname:item.contractName,
|
|
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])
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
// 删除eth代币
|
|
removeOther(item,index){
|
|
console.log(index,466666545)
|
|
// 添加代币修改
|
|
for(var i=0;i<this.imgindex.length;i++){
|
|
if(this.imgindex[i]==item.contractAddress){
|
|
this.trueIndex[index]=null;
|
|
uni.setStorageSync('trueIndex',this.trueIndex)
|
|
this.imgindex.splice(i, 1)
|
|
uni.setStorageSync('imgindex',this.imgindex)
|
|
this.$forceUpdate()
|
|
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
|
|
for(var j=0;j<walletInfo[that.coinType][i].coinList.length;j++){
|
|
if(item.contractAddress==walletInfo[that.coinType][i].coinList[j].contractAddress){
|
|
walletInfo[this.coinType][i].coinList.splice(j, 1);
|
|
console.log(item,7777777)
|
|
|
|
uni.setStorageSync('walletInfo',walletInfo)
|
|
uni.setStorageSync('wallet',walletInfo[this.coinType][i])
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
},
|
|
|
|
async getSearchContract(scroll){
|
|
const response = await this.$api.getSearchContract(this.params)
|
|
if(response.data.rows.length==0){
|
|
this.isNoData = true;
|
|
if (this.params.pageNum == 1) {
|
|
this.valueNu=true
|
|
this.aotext=this.$t('index').tokensfound
|
|
}
|
|
}else{
|
|
this.valueNu=false
|
|
}
|
|
if(scroll){
|
|
this.conInfo = this.conInfo.concat(response.data.rows);
|
|
}else{
|
|
this.conInfo =response.data.rows;
|
|
}
|
|
if(this.params.searchName==''){
|
|
console.log(this.params.searchName,777777)
|
|
this.valueNu=true
|
|
this.params.pageNum = 1;
|
|
this.aotext=this.$t('index').thetokenname
|
|
this.conInfo=[]
|
|
return;
|
|
}
|
|
console.log(response.data.rows,787878)
|
|
},
|
|
back(){
|
|
uni.navigateBack({
|
|
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
@import './index.css';
|
|
</style>
|