Browse Source

代码

master
Dread 4 years ago
parent
commit
9661fdf8b2
  1. 401
      pages/menu/backUp/transPaw/index.vue
  2. 6
      unpackage/dist/dev/app-plus/app-service.js
  3. 69
      utils/WalletUtil.js

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

@ -77,222 +77,222 @@
//
//
finish2(e) {
var a = uni.getStorageSync('createWalletName')
if (a == 'BTC' && a != '' && a != undefined) {
this.walletInfo = uni.getStorageSync('walletInfo');
var mnemonic = uni.getStorageSync('word');
console.log(mnemonic, 7777777777)
let btc = this.$Token.generateBtc(mnemonic);
btc.mnemonic = mnemonic;
btc.password = e;
this.$api.getBtcBalance().then((res) => {
var b = res.data.data[0]
for (var k in b) {
this.btcBalance = b[k]
}
})
btc.coinList = [{
name: "BTC",
name2: "BTC",
xname: 'Bitcoin',
icon: require('@/static/tongyonh/bye.png'),
balance: this.btcBalance
}];
btc.balance = this.btcBalance
console.log(this.$store.state.btci, 555566565)
this.$store.commit('addBtci', 1)
uni.setStorageSync('wallet', btc)
uni.setStorageSync('walleti', btc.privateKey)
this.walletInfo.BTC[this.$store.state.btci] = btc;
//
console.log(this.$store.state.btci, 555566565)
console.log(this.walletInfo, 44444)
uni.setStorageSync('walletInfo', this.walletInfo);
if (this.password != e) {
this.info = true;
return;
} else {
uni.showToast({
title: 'successfully',
icon: 'success',
duration: 1500,
})
setTimeout(() => {
uni.navigateTo({
url: '../../wallet/index'
})
}, 1500)
this.info = false;
}
return;
}
if (a == 'ETH' && a != '' && a != undefined) {
this.walletInfo = uni.getStorageSync('walletInfo');
var mnemonic = uni.getStorageSync('word');
let eth = this.$Token.generateEth(mnemonic);
eth.mnemonic = mnemonic;
eth.password = e;
this.$EthUtil.getBalance(eth.address,function(res){
eth.balance = res
this.ethBbalance = res;
console.log(res,'手机eth的钱包余额')
});
eth.coinList = [
{
name: "ETH",
name2: "ETH",
xname: 'Ethereum',
icon: require('@/static/tongyonh/Frame3299.png'),
balance: this.ethBbalance
},
{
name:"USDT",
name2:"ERC20-USDT",
xname:'Tether USD',
contractAddress:'0xdac17f958d2ee523a2206206994597c13d831ec7',
icon:require('@/static/tongyonh/img500.png')
}
];
this.$store.commit('addEthi', 1)
uni.setStorageSync('walleti', eth.privateKey)
this.walletInfo.ETH[this.$store.state.ethi] = eth;
//
console.log(this.$store.state.ethi, 555566565)
console.log(this.walletInfo, 44444)
setTimeout(()=>{
uni.setStorageSync('walletInfo', this.walletInfo);
// 便
var e=uni.getStorageSync(ethi)
e+=1
uni.setStorageSync('ethi', e);
uni.setStorageSync('itype', true);
},1000)
setTimeout(()=>{
uni.setStorageSync('wallet', eth)
},1000)
if (this.password != e) {
this.info = true;
return;
} else {
uni.showToast({
title: 'successfully',
icon: 'success',
duration: 1500,
})
setTimeout(() => {
uni.navigateTo({
url: '../../wallet/index'
})
}, 1500)
this.info = false;
}
return;
}
if (a == 'TRX' && a != '' && a != undefined) {
console.log(123123)
this.walletInfo = uni.getStorageSync('walletInfo');
var mnemonic = uni.getStorageSync('word');
let tron = this.$Token.generateTron(mnemonic);
tron.mnemonic = mnemonic;
tron.password = e;
this.$TronUtil.getTronBalance(tron.address).then((res) => {
tron.balance = res
this.trxBbalance = res
console.log(res,'手机tron的钱包余额')
}).catch(err => {
console.log(err)
})
tron.coinList = [
{
name: "TRX",
name2: "TRX",
xname: 'TRON',
icon: require('@/static/tongyonh/tron1.png'),
balance: this.trxBbalance
},
{
name:"USDT",
name2:"TRC20-USDT",
xname:'Tether USD',
contractAddress:'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
icon:require('@/static/tongyonh/tether_usd.png')
}
];
console.log(this.$store.state.troni, 555566565)
//
this.$store.commit('addTroni', 1)
setTimeout(()=>{
uni.setStorageSync('wallet', tron)
},1000)
uni.setStorageSync('walleti', tron.privateKey)
this.walletInfo.TRON[this.$store.state.troni] = tron;
setTimeout(()=>{
uni.setStorageSync('walletInfo', this.walletInfo);
},1000)
if (this.password != e) {
this.info = true;
return;
} else {
uni.showToast({
title: 'Set successfully',
icon: 'success',
duration: 1500,
})
setTimeout(() => {
uni.navigateTo({
url: '../../wallet/index'
})
}, 1500)
this.info = false;
}
return;
}
if (this.password != e) {
this.info = true;
return;
} else {
var a = uni.getStorageSync('createWalletName')
var mnemonic = uni.getStorageSync('word');
this.$walletUtil.mnemonicEstablishWallet(a,mnemonic,e)
uni.showToast({
title: 'Set successfully',
icon: 'success',
duration: 1500,
})
this.setWalletInfo(e);
setTimeout(() => {
// uni.navigateTo({
// url:'../reSuccessful'
// })
uni.navigateTo({
url: '../../wallet/index'
})
}, 1500)
this.info = false;
}
// if (a == 'BTC' && a != '' && a != undefined) {
// this.walletInfo = uni.getStorageSync('walletInfo');
// console.log(mnemonic, 7777777777)
// let btc = this.$Token.generateBtc(mnemonic);
// btc.mnemonic = mnemonic;
// btc.password = e;
// this.$api.getBtcBalance().then((res) => {
// var b = res.data.data[0]
// for (var k in b) {
// this.btcBalance = b[k]
// }
// })
// btc.coinList = [{
// name: "BTC",
// name2: "BTC",
// xname: 'Bitcoin',
// icon: require('@/static/tongyonh/bye.png'),
// balance: this.btcBalance
// }];
// btc.balance = this.btcBalance
// console.log(this.$store.state.btci, 555566565)
// this.$store.commit('addBtci', 1)
// uni.setStorageSync('wallet', btc)
// uni.setStorageSync('walleti', btc.privateKey)
// this.walletInfo.BTC[this.$store.state.btci] = btc;
// //
// console.log(this.$store.state.btci, 555566565)
// console.log(this.walletInfo, 44444)
// uni.setStorageSync('walletInfo', this.walletInfo);
// if (this.password != e) {
// this.info = true;
// return;
// } else {
// uni.showToast({
// title: 'successfully',
// icon: 'success',
// duration: 1500,
// })
// setTimeout(() => {
// uni.navigateTo({
// url: '../../wallet/index'
// })
// }, 1500)
// this.info = false;
// }
// return;
// }
// if (a == 'ETH' && a != '' && a != undefined) {
// this.walletInfo = uni.getStorageSync('walletInfo');
// var mnemonic = uni.getStorageSync('word');
// let eth = this.$Token.generateEth(mnemonic);
// eth.mnemonic = mnemonic;
// eth.password = e;
// this.$EthUtil.getBalance(eth.address,function(res){
// eth.balance = res
// this.ethBbalance = res;
// console.log(res,'eth')
// });
// eth.coinList = [
// {
// name: "ETH",
// name2: "ETH",
// xname: 'Ethereum',
// icon: require('@/static/tongyonh/Frame3299.png'),
// balance: this.ethBbalance
// },
// {
// name:"USDT",
// name2:"ERC20-USDT",
// xname:'Tether USD',
// contractAddress:'0xdac17f958d2ee523a2206206994597c13d831ec7',
// icon:require('@/static/tongyonh/img500.png')
// }
// ];
// this.$store.commit('addEthi', 1)
// uni.setStorageSync('walleti', eth.privateKey)
// this.walletInfo.ETH[this.$store.state.ethi] = eth;
// //
// console.log(this.$store.state.ethi, 555566565)
// console.log(this.walletInfo, 44444)
// setTimeout(()=>{
// uni.setStorageSync('walletInfo', this.walletInfo);
// // 便
// var e=uni.getStorageSync(ethi)
// e+=1
// uni.setStorageSync('ethi', e);
// uni.setStorageSync('itype', true);
// },1000)
// setTimeout(()=>{
// uni.setStorageSync('wallet', eth)
// },1000)
// if (this.password != e) {
// this.info = true;
// return;
// } else {
// uni.showToast({
// title: 'successfully',
// icon: 'success',
// duration: 1500,
// })
// setTimeout(() => {
// uni.navigateTo({
// url: '../../wallet/index'
// })
// }, 1500)
// this.info = false;
// }
// return;
// }
// if (a == 'TRX' && a != '' && a != undefined) {
// console.log(123123)
// this.walletInfo = uni.getStorageSync('walletInfo');
// var mnemonic = uni.getStorageSync('word');
// let tron = this.$Token.generateTron(mnemonic);
// tron.mnemonic = mnemonic;
// tron.password = e;
// this.$TronUtil.getTronBalance(tron.address).then((res) => {
// tron.balance = res
// this.trxBbalance = res
// console.log(res,'tron')
// }).catch(err => {
// console.log(err)
// })
// tron.coinList = [
// {
// name: "TRX",
// name2: "TRX",
// xname: 'TRON',
// icon: require('@/static/tongyonh/tron1.png'),
// balance: this.trxBbalance
// },
// {
// name:"USDT",
// name2:"TRC20-USDT",
// xname:'Tether USD',
// contractAddress:'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
// icon:require('@/static/tongyonh/tether_usd.png')
// }
// ];
// console.log(this.$store.state.troni, 555566565)
// //
// this.$store.commit('addTroni', 1)
// setTimeout(()=>{
// uni.setStorageSync('wallet', tron)
// },1000)
// uni.setStorageSync('walleti', tron.privateKey)
// this.walletInfo.TRON[this.$store.state.troni] = tron;
// setTimeout(()=>{
// uni.setStorageSync('walletInfo', this.walletInfo);
// },1000)
// if (this.password != e) {
// this.info = true;
// return;
// } else {
// uni.showToast({
// title: 'Set successfully',
// icon: 'success',
// duration: 1500,
// })
// setTimeout(() => {
// uni.navigateTo({
// url: '../../wallet/index'
// })
// }, 1500)
// this.info = false;
// }
// return;
// }
},
//
finish(e) {
@ -300,14 +300,7 @@
var that = this;
that.borNum = false;
that.borNum2 = false;
// uni.setStorage({
// key: 'transPaw',
// data: e,
// success: function() {
//
// },
// });
setTimeout(() => {
that.borNum2 = true;
}, 50)

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

File diff suppressed because one or more lines are too long

69
utils/WalletUtil.js

@ -10,8 +10,8 @@ let fullWallet = {
icon: require('@/static/tongyonh/bye.png')
}]
}],
"ETH": [
{balance: 0,
"ETH": [{
balance: 0,
name: "ETH",
coinList: [{
name: "ETH",
@ -26,11 +26,11 @@ let fullWallet = {
contractAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
icon: require('@/static/tongyonh/img500.png')
}
]}
],
"TRON": [
{balance: 0,
name: "TRON",
]
}],
"TRX": [{
balance: 0,
name: "TRX",
coinList: [{
name: "TRX",
xname: 'TRON',
@ -44,8 +44,8 @@ let fullWallet = {
contractAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
icon: require('@/static/tongyonh/tether_usd.png')
}
]}
]
]
}]
}
let WalletUtil = {
@ -67,7 +67,9 @@ let WalletUtil = {
walletInfo.TRON[0].password = password;
walletInfo.TRON[0].privateKey = tron.privateKey;
walletInfo.TRON[0].address = tron.address;
let wallet = walletInfo.BTC[0];
uni.setStorageSync('walletInfo', walletInfo);
uni.setStorageSync('wallet', wallet);
},
//修改钱包名称
updateWalletName: function(type, address, name) {
@ -79,6 +81,55 @@ let WalletUtil = {
}
}
uni.setStorageSync('walletInfo', walletInfo);
},
mnemonicEstablishWallet: function(type, mnemonic, password) {
let walletInfo = uni.getStorageSync('walletInfo');
let walletdec;
switch (type) {
case 'BTC':
walletdec = TokenUtil.generateBtc(mnemonic);
break;
case 'ETH':
walletdec = TokenUtil.generateTron(mnemonic);
break;
case 'TRX':
walletdec = TokenUtil.generateEth(mnemonic);
break;
}
let wallet=fullWallet[type][0];
wallet.password = password;
wallet.privateKey = walletdec.privateKey;
wallet.mnemonic = mnemonic;
wallet.address = walletdec.address;
console.log(wallet)
walletInfo[type].push(wallet);
console.log(walletInfo,1111111)
uni.setStorageSync('walletInfo', walletInfo);
uni.setStorageSync('wallet', wallet);
},
privateKeyEstablishWallet: function(type, privateKey, password) {
let walletInfo = uni.getStorageSync('walletInfo');
console.log(type)
let walletdec;
switch (type) {
case 'BTC':
walletdec = TokenUtil.importBtcPrivateKey(privateKey);
break;
case 'ETH':
walletdec = TokenUtil.importEthPrivateKey(privateKey);
break;
case 'TRX':
walletdec = TokenUtil.importTronPrivateKey(privateKey);
break;
}
let wallet=fullWallet[type][0];
wallet.password = password;
wallet.privateKey = walletdec.privateKey;
wallet.address = walletdec.address;
walletInfo.push(wallet);
uni.setStorageSync('walletInfo', walletInfo);
uni.setStorageSync('wallet', wallet);
}
}
export default WalletUtil

Loading…
Cancel
Save