Browse Source

代码

master
Dread 4 years ago
parent
commit
3d326fa885
  1. 2
      main.js
  2. 145
      pages/menu/backUp/transPaw/index.vue
  3. 16
      unpackage/dist/dev/app-plus/app-service.js
  4. 7466
      unpackage/dist/dev/app-plus/app-view.js
  5. 16
      utils/WalletUtil.js

2
main.js

@ -13,6 +13,7 @@ import ethers from 'ethers'
import util from 'ethereumjs-util' import util from 'ethereumjs-util'
import store from './store' import store from './store'
import walletUtil from './utils/WalletUtil.js'
Vue.prototype.$store = store Vue.prototype.$store = store
Vue.prototype.tronweb = tronweb Vue.prototype.tronweb = tronweb
Vue.prototype.bip32 = bip32 Vue.prototype.bip32 = bip32
@ -21,6 +22,7 @@ Vue.prototype.Tx = Tx
Vue.prototype.bitcoin = bitcoin Vue.prototype.bitcoin = bitcoin
Vue.prototype.ethers = ethers Vue.prototype.ethers = ethers
Vue.prototype.$axios = axios Vue.prototype.$axios = axios
Vue.prototype.$walletUtil = walletUtil
// 自定义底部导航栏 // 自定义底部导航栏
import tabBar from 'components/tabBar/tabBar.vue' import tabBar from 'components/tabBar/tabBar.vue'
Vue.component('tab-bar', tabBar) Vue.component('tab-bar', tabBar)

145
pages/menu/backUp/transPaw/index.vue

@ -64,81 +64,82 @@
// //
setWalletInfo(e) { setWalletInfo(e) {
this.word = uni.getStorageSync('word'); this.word = uni.getStorageSync('word');
this.walletInfo = this.$Token.initialWallet(this.word, e) this.$walletUtil.initialWallet(this.word, e)
let that=this console.log(123123)
this.$api.getBtcBalance().then((res) => { // let that=this
var b = res.data.data[0] // this.$api.getBtcBalance().then((res) => {
for (var k in b) { // var b = res.data.data[0]
that.btcBalance = b[k] // for (var k in b) {
} // that.btcBalance = b[k]
}) // }
this.walletInfo.BTC[0].balance = this.btcBalance // })
this.walletInfo.BTC[0].coinList = [{ // this.walletInfo.BTC[0].balance = this.btcBalance
name: "BTC", // this.walletInfo.BTC[0].coinList = [{
name2: "BTC", // name: "BTC",
xname: 'Bitcoin', // name2: "BTC",
icon: require('@/static/tongyonh/bye.png'), // xname: 'Bitcoin',
balance: this.btcBalance // icon: require('@/static/tongyonh/bye.png'),
}]; // balance: this.btcBalance
// }];
// this.$EthUtil.getBalance(eth.address,function(res){
// eth.balance = res // // this.$EthUtil.getBalance(eth.address,function(res){
// this.ethBbalance = res; // // eth.balance = res
// }); // // this.ethBbalance = res;
console.log(this.walletInfo.ETH[0].address,2222222) // // });
this.$EthUtil.getBalance(this.walletInfo.ETH[0].address,function(res){ // console.log(this.walletInfo.ETH[0].address,2222222)
console.log(res,787878) // this.$EthUtil.getBalance(this.walletInfo.ETH[0].address,function(res){
that.walletInfo.ETH[0].balance = res // console.log(res,787878)
console.log(res,4444455555) // that.walletInfo.ETH[0].balance = res
that.walletInfo.ETH[0].coinList = [ // console.log(res,4444455555)
{ // that.walletInfo.ETH[0].coinList = [
name: "ETH", // {
name2: "ETH", // name: "ETH",
xname: 'Ethereum', // name2: "ETH",
icon: require('@/static/tongyonh/Frame3299.png'), // xname: 'Ethereum',
balance: res // icon: require('@/static/tongyonh/Frame3299.png'),
}, // balance: res
{ // },
name:"USDT", // {
name2:"ERC20-USDT", // name:"USDT",
xname:'Tether USD', // name2:"ERC20-USDT",
contractAddress:'0xdac17f958d2ee523a2206206994597c13d831ec7', // xname:'Tether USD',
icon:require('@/static/tongyonh/img500.png'), // contractAddress:'0xdac17f958d2ee523a2206206994597c13d831ec7',
balance: 0 // icon:require('@/static/tongyonh/img500.png'),
} // balance: 0
] // }
// ]
});
this.$TronUtil.getTronBalance(this.walletInfo.TRON[0].address).then((res) => {
that.walletInfo.TRON[0].balance = res
that.walletInfo.TRON[0].coinList = [
{
name: "TRX",
name2: "TRX",
xname: 'TRON',
icon: require('@/static/tongyonh/tron1.png'),
balance: res
},
{
name:"USDT",
name2:"TRC20-USDT",
xname:'Tether USD',
contractAddress:'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
icon:require('@/static/tongyonh/tether_usd.png')
}
]
// });
}).catch(err => { // this.$TronUtil.getTronBalance(this.walletInfo.TRON[0].address).then((res) => {
console.log(err) // that.walletInfo.TRON[0].balance = res
}) // that.walletInfo.TRON[0].coinList = [
setTimeout(()=>{ // {
uni.setStorageSync('ethi', 0); // name: "TRX",
uni.setStorageSync('itype', true); // name2: "TRX",
uni.setStorageSync('walletInfo', this.walletInfo); // xname: 'TRON',
},1500) // icon: require('@/static/tongyonh/tron1.png'),
// balance: res
// },
// {
// name:"USDT",
// name2:"TRC20-USDT",
// xname:'Tether USD',
// contractAddress:'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
// icon:require('@/static/tongyonh/tether_usd.png')
// }
// ]
// }).catch(err => {
// console.log(err)
// })
// setTimeout(()=>{
// uni.setStorageSync('ethi', 0);
// uni.setStorageSync('itype', true);
// uni.setStorageSync('walletInfo', this.walletInfo);
// },1500)
}, },

16
unpackage/dist/dev/app-plus/app-service.js

File diff suppressed because one or more lines are too long

7466
unpackage/dist/dev/app-plus/app-view.js

File diff suppressed because one or more lines are too long

16
utils/WalletUtil.js

@ -1,4 +1,4 @@
impor TokenUtil from './TokenUtil.js' import TokenUtil from './TokenUtil.js'
let fullWallet = { let fullWallet = {
"BTC": [{ "BTC": [{
balance: 0, balance: 0,
@ -11,7 +11,7 @@ let fullWallet = {
}] }]
}], }],
"ETH": [ "ETH": [
balance: 0, {balance: 0,
name: "ETH", name: "ETH",
coinList: [{ coinList: [{
name: "ETH", name: "ETH",
@ -26,10 +26,10 @@ let fullWallet = {
contractAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7', contractAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
icon: require('@/static/tongyonh/img500.png') icon: require('@/static/tongyonh/img500.png')
} }
] ]}
], ],
"TRON": [ "TRON": [
balance: 0, {balance: 0,
name: "TRON", name: "TRON",
coinList: [{ coinList: [{
name: "TRX", name: "TRX",
@ -44,7 +44,7 @@ let fullWallet = {
contractAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', contractAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
icon: require('@/static/tongyonh/tether_usd.png') icon: require('@/static/tongyonh/tether_usd.png')
} }
], ]}
] ]
} }
@ -52,17 +52,17 @@ let WalletUtil = {
//初次创建钱包 //初次创建钱包
initialWallet: function(mnemonic, password) { initialWallet: function(mnemonic, password) {
let walletInfo = fullWallet; let walletInfo = fullWallet;
let btc = TokenUtil.token.generateBtc(mnemonic); let btc = TokenUtil.generateBtc(mnemonic);
walletInfo.BTC[0].password = password; walletInfo.BTC[0].password = password;
walletInfo.BTC[0].mnemonic = mnemonic; walletInfo.BTC[0].mnemonic = mnemonic;
walletInfo.BTC[0].privateKey = btc.privateKey; walletInfo.BTC[0].privateKey = btc.privateKey;
walletInfo.BTC[0].address = btc.address; walletInfo.BTC[0].address = btc.address;
let eth = TokenUtil.token.generateEth(mnemonic) let eth = TokenUtil.generateEth(mnemonic)
walletInfo.ETH[0].password = password; walletInfo.ETH[0].password = password;
walletInfo.ETH[0].mnemonic = mnemonic; walletInfo.ETH[0].mnemonic = mnemonic;
walletInfo.ETH[0].privateKey = eth.privateKey; walletInfo.ETH[0].privateKey = eth.privateKey;
walletInfo.ETH[0].address = eth.mnemonic; walletInfo.ETH[0].address = eth.mnemonic;
let tron = TokenUtil.token.generateTron(mnemonic); let tron = TokenUtil.generateTron(mnemonic);
walletInfo.TRON[0].mnemonic = mnemonic; walletInfo.TRON[0].mnemonic = mnemonic;
walletInfo.TRON[0].password = password; walletInfo.TRON[0].password = password;
walletInfo.TRON[0].privateKey = tron.privateKey; walletInfo.TRON[0].privateKey = tron.privateKey;

Loading…
Cancel
Save