From 90e5e12c9e157ae94ad0da08269906ca98af2d1b Mon Sep 17 00:00:00 2001 From: vee <897831508@qq.com> Date: Sat, 13 Nov 2021 19:25:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=92=B1=E5=8C=85=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/menu/wallet/index.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pages/menu/wallet/index.vue b/pages/menu/wallet/index.vue index b7a3367..b968ffd 100644 --- a/pages/menu/wallet/index.vue +++ b/pages/menu/wallet/index.vue @@ -91,10 +91,7 @@ onLoad() { this.setStorage(); - // this.$dataUtil.transactionData('TRX','send','TBREsCfBdPyD612xZnwvGPux7osbXvtzLh', - // 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',1,30,function(data){ - // console.log(data) - // }) + // this.getWalletBalance(); var a=uni.getStorageSync('wallet') From 5c4c6996f1902b779709bec8c66d855668f1f968 Mon Sep 17 00:00:00 2001 From: vee <897831508@qq.com> Date: Sat, 13 Nov 2021 20:07:59 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=92=B1=E5=8C=85=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/BtcUtil.js | 28 ++++++++++++++++++++++++++++ utils/WalletUtil.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 utils/BtcUtil.js diff --git a/utils/BtcUtil.js b/utils/BtcUtil.js new file mode 100644 index 0000000..6205b27 --- /dev/null +++ b/utils/BtcUtil.js @@ -0,0 +1,28 @@ +let BtcUtil = { + getBalance: function(address,success) { + let balance=0; + try{ + uni.request({ + url: 'http://scan.weirui0755.com/btc/api/address/balancetrend/btc/' + address, //请求接口 + header: { + 'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息 + }, + success: (res) => { + + if (res.data.code === 1) { + if(res.data.data.length>0){ + var data=res.data.data[0]; + for(obj b in data){ + balance=data[b]; + } + } + } + } + }); + }catch(e){ + //TODO handle the exception + } + success(balance); + } +} +export default BtcUtil \ No newline at end of file diff --git a/utils/WalletUtil.js b/utils/WalletUtil.js index eeca565..970d838 100644 --- a/utils/WalletUtil.js +++ b/utils/WalletUtil.js @@ -1,4 +1,9 @@ import TokenUtil from './TokenUtil.js' +import BtcUtil from './BtcUtil.js' +import BtcUtil from './BtcUtil.js' +import TronUtil from './TronUtil.js' +import EthUtil from './EthUtil.js' + let fullWallet = { "BTC": [{ balance: 0, @@ -175,6 +180,44 @@ console.log(password,'password') } } + }, + updateBalance:function() { + let wallet = uni.getStorageSync('wallet'); + switch (wallet.type) { + case 'BTC': + BtcUtil.getBalance(wallet.address,function(balance){ + wallet.balance=balance; + wallet.coinList[0].balance=balance + }) + break; + case 'ETH': + EthUtil.getBalance(wallet.address,function(balance){ + wallet.balance=balance; + wallet.coinList[0].balance=balance + for(let i=1;i { + wallet.balance=res; + wallet.coinList[0].balance=res + for(let i=1;i { + wallet.coinList[i].balance=res; + }) + } + }).catch(err => { + console.log(err) + }) + break; + uni.setStorageSync('wallet', wallet); + } } } export default WalletUtil From d7d4287f83979c52652783d73d0461739966272d Mon Sep 17 00:00:00 2001 From: vee <897831508@qq.com> Date: Sat, 13 Nov 2021 20:08:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=92=B1=E5=8C=85=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/WalletUtil.js | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/WalletUtil.js b/utils/WalletUtil.js index 970d838..fde9a7f 100644 --- a/utils/WalletUtil.js +++ b/utils/WalletUtil.js @@ -180,6 +180,7 @@ console.log(password,'password') } } + this.updateBalance(); }, updateBalance:function() { let wallet = uni.getStorageSync('wallet');