Browse Source

代码

master
Dread 4 years ago
parent
commit
547c9fa9c7
  1. 7
      pages.json
  2. 315
      pages/menu/backUp/backUp4/index.vue
  3. 158
      pages/menu/backUp/backUp5/index.vue
  4. 34
      pages/menu/backUp/transPaw/index.vue
  5. 297
      pages/menu/backUp/transPawKey/index.vue
  6. 2
      pages/menu/wallet/mwallet/manage/index.vue
  7. 10
      unpackage/dist/dev/app-plus/app-service.js
  8. 1
      utils/TronUtil.js

7
pages.json

@ -109,7 +109,12 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
{
"path": "pages/menu/backUp/transPawKey/index",
"style": {
"navigationStyle": "custom"
}
},
{ {
"path": "pages/menu/backUp/transPawKeyOut/index", "path": "pages/menu/backUp/transPawKeyOut/index",
"style": { "style": {

315
pages/menu/backUp/backUp4/index.vue

@ -1,64 +1,63 @@
<template> <template>
<view class=""> <view class="">
<navigation :showBack="true"> <navigation :showBack="true">
Import by mnemonics Import mnemonics
</navigation> </navigation>
<view class="main"> <view class="main">
<view class="title"> <view class="title">
Mnemonic import verification Mnemonics import verification
</view> </view>
<textarea v-model="wordInfo" class="textareaa" placeholder="Enter mnemonic words separated by spaces" placeholder-style="color:rgb(224,229,242)"> <textarea v-model="wordInfo" class="textareaa" placeholder="Enter mnemonic words separated by spaces" placeholder-style="color:rgb(224,229,242)">
</textarea>
</textarea> <u-button class="custom-style" @click="confirm">Confirm</u-button>
<u-button class="custom-style" @click="confirm">Confirm</u-button> <view class="info_con" v-if="show">
<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img2" @click="show=false">
</image>
<view class="info_con" v-if="show"> <image src="../../../../static/tongyonh/Frame60.png" mode="aspectFit" class="img"></image>
<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img2" @click="show=false"></image> <view class="info">
<image src="../../../../static/tongyonh/Frame60.png" mode="aspectFit" class="img"></image> Successful
<view class="info"> </view>
Successful <view class="text">
</view> Backup mnemonic completed!
<view class="text"> </view>
Backup mnemonic completed! <view class="btn">
</view> Confirm
<view class="btn"> </view>
Confirm </view>
</view>
</view> <view class="info_con" v-if="show2">
<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img2" @click="show2=false">
<view class="info_con" v-if="show2"> </image>
<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img2" @click="show2=false"></image> <image src="../../../../static/tongyonh/Subtract.png" mode="aspectFit" class="img"></image>
<image src="../../../../static/tongyonh/Subtract.png" mode="aspectFit" class="img"></image> <view class="info">
<view class="info"> Invalid Seed
Invalid Seed </view>
</view> <view class="text">
<view class="text"> You entered the wrong booster words, <br>please try again.
You entered the wrong booster words, <br>please try again. </view>
</view> <view class="btncon">
<view class="btncon"> <view class="can" @click="show2=false">
<view class="can" @click="show2=false"> Cancel
Cancel </view>
</view> <view class="con" @click="restart">
<view class="con" @click="restart"> Confirm
Confirm </view>
</view>
</view>
</view> </view>
</view>
<u-mask :show="show" z-index="10"></u-mask>
<u-mask :show="show" z-index="10"></u-mask> <u-mask :show="show2" z-index="10"></u-mask>
<u-mask :show="show2" z-index="10"></u-mask>
</view>
</view> </view>
</view> </view>
</view>
</template> </template>
<script> <script>
@ -66,182 +65,75 @@
export default { export default {
data() { data() {
return { return {
mnemonics:[], mnemonics: [],
wordArr:[], wordArr: [],
show: false, show: false,
index:0, index: 0,
returnIndex:0, returnIndex: 0,
// //
mnemonics2:[], mnemonics2: [],
show2:false, show2: false,
wordInfo:'', wordInfo: '',
walletInfo:{}, walletInfo: {},
go:true, go: false,
name:'', name: '',
typename:'',
info: {},
}; };
}, },
methods: { methods: {
// //
goTranPaw(){ goTranPaw() {
uni.navigateTo({ uni.navigateTo({
url:'/pages/menu/backUp/transPaw/index' url: '/pages/menu/backUp/transPaw/index'
}) })
}, },
// //
restart(){ restart() {
uni.redirectTo({ uni.redirectTo({
url:'../backUp4/index' url: '../backUp4/index'
}) })
}, },
// //
confirm(){ confirm() {
if(this.wordInfo==''){ this.walletInfo = uni.getStorageSync('walletInfo');
uni.showToast({ if (this.wordInfo == '') {
title: 'Cannot be empty',
icon: 'none',
duration: 1500
})
return;
}
var a=uni.getStorageSync('createWalletName')
if(a=='BTC'&&a!=''&&a!=undefined){
this.walletInfo=uni.getStorageSync('walletInfo');
var mnemonic=this.wordInfo;
uni.setStorageSync('word',mnemonic);
let btc;
console.log(1111111)
try{
btc=this.$Token.generateBtc(mnemonic);
}catch(e){
uni.showToast({
title: e.message,
icon: 'none',
duration: 1500
})
return;
}
for(var i=0;i<this.walletInfo.BTC.length;i++){
if(this.walletInfo.BTC[i].address==btc.address){
uni.showToast({
title: 'The wallet has been imported',
icon: 'none',
duration: 1500
})
this.go=false;
}else{
this.go=true;
}
}
if(this.go){
uni.showToast({
title: 'Import succeeded',
icon: 'success',
duration: 1500
})
setTimeout(()=>{
uni.navigateTo({
url:'/pages/menu/backUp/transPaw/index'
})
},1500)
}
}
if(a=='ETH'&&a!=''&&a!=undefined){
this.walletInfo=uni.getStorageSync('walletInfo');
var mnemonic=this.wordInfo;
uni.setStorageSync('word',mnemonic);
let eth;
try{
eth=this.$Token.generateEth(mnemonic);
}catch(e){
uni.showToast({ uni.showToast({
title: e.message, title: 'Cannot be empty',
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
return; return;
} }
this.typename = uni.getStorageSync('createWalletName')
for(var i=0;i<this.walletInfo.ETH.length;i++){
if(this.walletInfo.ETH[i].address==eth.address){ this.walletInfo = uni.getStorageSync('walletInfo');
uni.showToast({ for(var i=0;i<this.walletInfo[this.typename].length;i++){
title: 'The wallet has been imported', if( this.wordInfo==this.walletInfo[this.typename][i].address){
icon: 'none', uni.showToast({
duration: 1500 title: 'The wallet has been imported',
}) icon: 'none',
this.go=false; duration: 1500
}else{ })
this.go=true; return;
} }else{
uni.setStorageSync('word', this.wordInfo);
} uni.navigateTo({
if(this.go){ url:'/pages/menu/backUp/transPaw/index'
uni.showToast({ })
title: 'Import succeeded', }
icon: 'success',
duration: 1500 }
})
setTimeout(()=>{
uni.navigateTo({
url:'/pages/menu/backUp/transPaw/index'
})
},1500)
}
}
if(a=='TRX'&&a!=''&&a!=undefined){
this.walletInfo=uni.getStorageSync('walletInfo');
var mnemonic=this.wordInfo;
uni.setStorageSync('word',mnemonic);
let tron=this.$Token.generateTron(mnemonic);
console.log(tron,444444)
for(var i=0;i<this.walletInfo.TRON.length;i++){
if(this.walletInfo.TRON[i].address==tron.address){
uni.showToast({
title: 'The wallet has been imported',
icon: 'none',
duration: 1500
})
this.go=false;
}else{
this.go=true;
}
}
if(this.go){
uni.showToast({
title: 'successfully',
icon: 'success',
duration: 1500
})
setTimeout(()=>{
uni.navigateTo({
url:'/pages/menu/backUp/transPaw/index'
})
},1500)
}
}
}, },
}, },
onLoad(item) { onLoad(item) {
if(item!=''||item!=undefined){ if (item != '' || item != undefined) {
uni.setStorageSync('createWalletName',item.name) uni.setStorageSync('createWalletName', item.name)
} }
}, },
}; };
@ -250,12 +142,13 @@
.custom-style { .custom-style {
height: 112rpx; height: 112rpx;
text-align: center; text-align: center;
color: #fff; color: #fff;
background-color: #5B53FF !important; background-color: #5B53FF !important;
border-radius: 40rpx; border-radius: 40rpx;
margin-top: 50rpx; margin-top: 50rpx;
} }
.u-default-hover{
.u-default-hover {
background-color: #5B53FF !important; background-color: #5B53FF !important;
border-radius: 40rpx !important; border-radius: 40rpx !important;
color: #fff !important; color: #fff !important;
@ -264,7 +157,5 @@
</style> </style>
<style> <style>
@import './index.css'; @import './index.css';
</style> </style>

158
pages/menu/backUp/backUp5/index.vue

@ -84,6 +84,7 @@
walletInfo: {}, walletInfo: {},
go: false, go: false,
name: '', name: '',
typename:'',
info: {}, info: {},
}; };
}, },
@ -112,147 +113,26 @@
return; return;
} }
const a = uni.getStorageSync('createWalletName') this.typename = uni.getStorageSync('createWalletName')
console.log(a) console.log(this.walletInfo[this.typename].length,1111)
console.log(this.typename)
this.walletInfo = uni.getStorageSync('walletInfo'); this.walletInfo = uni.getStorageSync('walletInfo');
var mnemonic = this.wordInfo; for(var i=0;i<this.walletInfo[this.typename].length;i++){
uni.setStorageSync('privateKey', mnemonic); if( this.wordInfo==this.walletInfo[this.typename][i].privateKey){
// privateKeyEstablishWallet uni.showToast({
console.log(mnemonic) title: 'The wallet has been imported',
icon: 'none',
uni.navigateTo({ duration: 1500
url: '/pages/menu/backUp/transPaw2/index'
}) })
return;
}else{
// if (a == 'ETH' && a != '' && a != undefined) { uni.setStorageSync('privateKey', this.wordInfo);
// try { uni.navigateTo({
// this.walletInfo = uni.getStorageSync('walletInfo'); url:'/pages/menu/backUp/transPawKey/index'
// var mnemonic = this.wordInfo; })
// uni.setStorageSync('privateKey', mnemonic); }
// console.log(mnemonic)
}
// let eth = this.$Token.importEthPrivateKey(mnemonic);
// for (var i = 0; i < this.walletInfo.ETH.length; i++) {
// if (this.walletInfo.ETH[i].privateKey == eth.privateKey) {
// uni.showToast({
// title: 'The wallet has been imported',
// icon: 'none',
// duration: 1500
// })
// this.go = false;
// } else {
// this.go = true;
// }
// }
// } catch (err) {
// uni.showToast({
// title: 'Private key does not exist',
// icon: 'none',
// duration: 1500
// })
// }
// if (this.go) {
// uni.showToast({
// title: 'Import succeeded',
// icon: 'success',
// duration: 1500
// })
// setTimeout(() => {
// uni.navigateTo({
// url: '/pages/menu/backUp/transPaw2/index'
// })
// }, 1500)
// }
// }
// if (a == 'TRX' && a != '' && a != undefined) {
// try {
// this.walletInfo = uni.getStorageSync('walletInfo');
// var mnemonic = this.wordInfo;
// console.log(this.wordInfo)
// uni.setStorageSync('privateKey', mnemonic);
// console.log(mnemonic)
// this.info = this.$Token.importTronPrivateKey(mnemonic);
// for (var i = 0; i < this.walletInfo.TRON.length; i++) {
// if (this.walletInfo.TRON[i].privateKey == this.info.privateKey) {
// uni.showToast({
// title: 'The wallet has been imported',
// icon: 'none',
// duration: 1500
// })
// this.go = false;
// } else {
// this.go = true;
// }
// }
// } catch (err) {
// console.log(err)
// uni.showToast({
// title: 'Private key does not exist',
// icon: 'none',
// duration: 1500
// })
// }
// if (this.go) {
// console.log(this.info, 111)
// this.$store.commit('addTroni', 1)
// let that = this;
// this.$TronUtil.getTronBalance(this.info.address).then((res) => {
// that.info.balance = res
// }).catch(err => {
// console.log(err)
// })
// this.info.coinList = [
// {
// name: "TRX",
// name2: "TRX",
// xname: 'TRON',
// icon: require('@/static/tongyonh/tron1.png'),
// balance: this.info.balance
// },
// {
// name:"USDT",
// name2:"TRC20-USDT",
// xname:'Tether USD',
// contractAddress:'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
// icon:require('@/static/tongyonh/tether_usd.png')
// }
// ];
// uni.setStorageSync('wallet', this.info)
// uni.setStorageSync('walleti', this.info.privateKey)
// this.walletInfo.TRON[this.$store.state.troni] = this.info
// uni.setStorageSync('walletInfo', this.walletInfo)
// uni.showToast({
// title: 'Import succeeded',
// icon: 'success',
// duration: 1500
// })
// setTimeout(() => {
// uni.navigateTo({
// url: '/pages/menu/backUp/transPaw2/index'
// })
// }, 1500)
// }
// }
}, },

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

@ -82,18 +82,28 @@
if(uni.getStorageSync('walletInfo')){ if(uni.getStorageSync('walletInfo')){
var a = uni.getStorageSync('createWalletName') var a = uni.getStorageSync('createWalletName')
var mnemonic = uni.getStorageSync('word'); var mnemonic = uni.getStorageSync('word');
this.$walletUtil.mnemonicEstablishWallet(a,mnemonic,e) try {
this.$walletUtil.mnemonicEstablishWallet(a,mnemonic,e)
uni.showToast({ uni.showToast({
title: 'Set successfully', title: 'Set successfully',
icon: 'success', icon: 'success',
duration: 1500, duration: 1500,
}) })
setTimeout(() => { setTimeout(() => {
uni.navigateTo({ uni.navigateTo({
url: '../../wallet/index' url: '../../wallet/index'
}) })
}, 1500) }, 1500)
}
catch(err){
uni.showToast({
title: 'Creation failed',
icon: 'none',
duration: 1500,
})
}
}else{ }else{
this.setWalletInfo(); this.setWalletInfo();
uni.showToast({ uni.showToast({

297
pages/menu/backUp/transPawKey/index.vue

@ -2,33 +2,36 @@
<view class=""> <view class="">
<navigation :showBack="true" :bgnum="false"> <navigation :showBack="true" :bgnum="false">
<text class="big_title"> <text class="big_title">
Transaction password Transaction password
</text> </text>
</navigation> </navigation>
<view class="main"> <view class="main">
<view class="big_title" v-if="borNum"> <view class="big_title" v-if="borNum">
Set transaction password Set transaction password
</view> </view>
<view class="big_title" v-if="borNum2"> <view class="big_title" v-if="borNum2">
Please enter again Please enter again
</view>
<view class="title">
Secure transaction passwords, <br>please do not disclose
</view>
<u-message-input @finish="finish" inactive-color="#E0E5F2" active-color="#5B53FF" :width="94" :maxlength="6"
mode="box" :focus="fes" :dot-fill="true" v-if="borNum"></u-message-input>
<u-message-input @finish="finish2" :inactive-color="info?'#F16063':'#E0E5F2'" active-color="#5B53FF"
:width="94" :maxlength="6" mode="box" :focus="fes" :dot-fill="true" v-if="borNum2" @change="back">
</u-message-input>
<view class="infoText" v-if="info">
Password discrepansies
</view>
</view> </view>
<view class="title">
Secure transaction passwords, <br>please do not disclose
</view>
<u-message-input @finish="finish" inactive-color="#E0E5F2" active-color="#5B53FF" :width="94" :maxlength="6" mode="box" :focus="fes" :dot-fill="true" v-if="borNum"></u-message-input>
<u-message-input @finish="finish2" :inactive-color="info?'#F16063':'#E0E5F2'" active-color="#5B53FF" :width="94" :maxlength="6" mode="box" :focus="fes" :dot-fill="true" v-if="borNum2" @change="back"></u-message-input>
<view class="infoText" v-if="info">
Password discrepansies
</view> </view>
</view> </view>
</view>
</view>
</template> </template>
@ -38,205 +41,91 @@
export default { export default {
data() { data() {
return { return {
password:'', password: '',
password2:'', password2: '',
msg:'', msg: '',
msgLength:0, msgLength: 0,
fes:false, fes: false,
borNum:true, borNum: true,
borNum2:false, borNum2: false,
info:false, info: false,
word:{}, word: {},
walletInfo:{}, walletInfo: {},
btcBalance: 0,
ethBbalance: 0,
trxBbalance: 0,
} }
}, },
watch:{ watch: {
}, },
onLoad() {
}
methods: {
setWalletInfo(e){ methods: {
//
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,this.password )
uni.setStorageSync('walletInfo',this.walletInfo);
}, },
// //
back(e){ back(e) {
if(e.length<6){ if (e.length < 6) {
this.info=false; this.info = false;
} }
}, },
// finish2(e) {
finish2(e) { if (this.password != e) {
var a=uni.getStorageSync('createWalletName') this.info = true;
console.log(a);
console.log('222222')
if(a=='BTC'&&a!=''&&a!=undefined){
this.walletInfo=uni.getStorageSync('walletInfo');
var mnemonic=uni.getStorageSync('privateKey');
console.log(mnemonic,7777777777)
let btc=this.$Token.importBtcPrivateKey(mnemonic);
btc.mnemonic=mnemonic;
btc.password=e;
btc.coinList=[{
name:"BTC",
name2:"BTC",
xname:'Bitcoin',
icon:require('@/static/tongyonh/bye.png')
}];
console.log(this.$store.state.btci,555566565)
this.$store.commit('addBtci',1)
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: 'Set 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');
console.log(mnemonic,7777777777)
let eth=this.$Token.generateEth(mnemonic);
eth.mnemonic=mnemonic;
eth.password=e;
eth.coinList=[{
name:"ETH",
name2:"ETH",
xname:'Ethereum',
icon:require('@/static/tongyonh/Frame3299.png')
}];
console.log(this.$store.state.ethi,555566565)
this.$store.commit('addEthi',1)
this.walletInfo.ETH[this.$store.state.ethi]=eth;
//
console.log(this.$store.state.ethi,555566565)
console.log(this.walletInfo,44444)
uni.setStorageSync('walletInfo',this.walletInfo);
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; return;
} else {
//
var createWalletName= uni.getStorageSync('createWalletName')
var privateKey= uni.getStorageSync('privateKey')
uni.setStorageSync('privateKey', this.wordInfo);
try {
this.$walletUtil.privateKeyEstablishWallet(createWalletName,privateKey,this.password);
uni.showToast({
title: 'Set successfully',
icon: 'success',
duration: 1500,
})
setTimeout(() => {
uni.navigateTo({
url: '../../wallet/index'
})
}, 1500)
}
catch(err){
uni.showToast({
title: 'Creation failed',
icon: 'none',
duration: 1500,
})
}
this.info = false;
} }
if(a=='TRX'&&a!=''&&a!=undefined){
this.walletInfo=uni.getStorageSync('walletInfo');
var mnemonic=uni.getStorageSync('word');
let tron=this.$Token.generateTron(mnemonic);
tron.mnemonic=mnemonic;
tron.password=e;
tron.coinList=[{
name:"TRX",
name2:"TRX",
xname:'TRON',
icon:require('@/static/tongyonh/tron1.png')
}];
console.log(this.$store.state.troni,555566565)
//
this.$store.commit('addTroni',1)
this.walletInfo.TRON[this.$store.state.troni]=tron;
uni.setStorageSync('walletInfo',this.walletInfo);
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{
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;
}
},
//
},
//
finish(e) { finish(e) {
this.password=e this.password = e
var that=this; var that = this;
that.borNum=false; that.borNum = false;
that.borNum2=false; that.borNum2 = false;
// uni.setStorage({
// key: 'transPaw', setTimeout(() => {
// data: e, that.borNum2 = true;
// success: function() { }, 50)
//
// }, },
// });
setTimeout(()=>{
that.borNum2=true;
},50)
}, },
onLoad() {
} }
}; };
</script> </script>

2
pages/menu/wallet/mwallet/manage/index.vue

@ -111,7 +111,7 @@
}) })
this.showAddress=false; this.showAddress=false;
setTimeout(()=>{ setTimeout(()=>{
uni.reLaunch({ uni.navigateTo({
url:'../../mwallet/index' url:'../../mwallet/index'
}) })
},1500) },1500)

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

File diff suppressed because one or more lines are too long

1
utils/TronUtil.js

@ -83,7 +83,6 @@ let tron = {
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息 'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
}, },
success: (res) => { success: (res) => {
console.log(res.data.data[6].tokenDecimal)
for(let i=1;i<res.data.data.length;i++){ for(let i=1;i<res.data.data.length;i++){
if(res.data.data[i].tokenAbbr==='USDT'){ if(res.data.data[i].tokenAbbr==='USDT'){
list[1].balance=(Number(res.data.data[i].balance)/ Math.pow(10, res.data.data[i].tokenDecimal)); list[1].balance=(Number(res.data.data[i].balance)/ Math.pow(10, res.data.data[i].tokenDecimal));

Loading…
Cancel
Save