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"
}
},
{
"path": "pages/menu/backUp/transPawKey/index",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/menu/backUp/transPawKeyOut/index",
"style": {

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

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

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

@ -84,6 +84,7 @@
walletInfo: {},
go: false,
name: '',
typename:'',
info: {},
};
},
@ -112,147 +113,26 @@
return;
}
const a = uni.getStorageSync('createWalletName')
console.log(a)
this.typename = uni.getStorageSync('createWalletName')
console.log(this.walletInfo[this.typename].length,1111)
console.log(this.typename)
this.walletInfo = uni.getStorageSync('walletInfo');
var mnemonic = this.wordInfo;
uni.setStorageSync('privateKey', mnemonic);
// privateKeyEstablishWallet
console.log(mnemonic)
uni.navigateTo({
url: '/pages/menu/backUp/transPaw2/index'
for(var i=0;i<this.walletInfo[this.typename].length;i++){
if( this.wordInfo==this.walletInfo[this.typename][i].privateKey){
uni.showToast({
title: 'The wallet has been imported',
icon: 'none',
duration: 1500
})
// if (a == 'ETH' && a != '' && a != undefined) {
// try {
// this.walletInfo = uni.getStorageSync('walletInfo');
// 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)
// }
// }
return;
}else{
uni.setStorageSync('privateKey', this.wordInfo);
uni.navigateTo({
url:'/pages/menu/backUp/transPawKey/index'
})
}
}
},

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

@ -82,18 +82,28 @@
if(uni.getStorageSync('walletInfo')){
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,
})
setTimeout(() => {
uni.navigateTo({
url: '../../wallet/index'
})
}, 1500)
try {
this.$walletUtil.mnemonicEstablishWallet(a,mnemonic,e)
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,
})
}
}else{
this.setWalletInfo();
uni.showToast({

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

@ -2,33 +2,36 @@
<view class="">
<navigation :showBack="true" :bgnum="false">
<text class="big_title">
Transaction password
Transaction password
</text>
</navigation>
<view class="main">
<view class="big_title" v-if="borNum">
Set transaction password
</view>
<view class="big_title" v-if="borNum2">
Please enter again
<view class="big_title" v-if="borNum2">
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 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>
</template>
@ -38,205 +41,91 @@
export default {
data() {
return {
password:'',
password2:'',
msg:'',
msgLength:0,
fes:false,
borNum:true,
borNum2:false,
info:false,
word:{},
walletInfo:{},
password: '',
password2: '',
msg: '',
msgLength: 0,
fes: false,
borNum: true,
borNum2: false,
info: false,
word: {},
walletInfo: {},
btcBalance: 0,
ethBbalance: 0,
trxBbalance: 0,
}
},
watch:{
},
onLoad() {
}
methods: {
watch: {
},
setWalletInfo(e){
methods: {
//
setWalletInfo(e) {
this.word = uni.getStorageSync('word');
this.walletInfo=this.$Token.initialWallet(this.word,e)
uni.setStorageSync('walletInfo',this.walletInfo);
this.$walletUtil.initialWallet(this.word,this.password )
},
//
back(e){
if(e.length<6){
this.info=false;
//
back(e) {
if (e.length < 6) {
this.info = false;
}
},
//
finish2(e) {
var a=uni.getStorageSync('createWalletName')
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;
}
finish2(e) {
if (this.password != e) {
this.info = true;
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) {
this.password=e
var that=this;
that.borNum=false;
that.borNum2=false;
// uni.setStorage({
// key: 'transPaw',
// data: e,
// success: function() {
//
// },
// });
setTimeout(()=>{
that.borNum2=true;
},50)
this.password = e
var that = this;
that.borNum = false;
that.borNum2 = false;
setTimeout(() => {
that.borNum2 = true;
}, 50)
},
},
onLoad() {
}
};
</script>

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

@ -111,7 +111,7 @@
})
this.showAddress=false;
setTimeout(()=>{
uni.reLaunch({
uni.navigateTo({
url:'../../mwallet/index'
})
},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', //自定义请求头信息
},
success: (res) => {
console.log(res.data.data[6].tokenDecimal)
for(let i=1;i<res.data.data.length;i++){
if(res.data.data[i].tokenAbbr==='USDT'){
list[1].balance=(Number(res.data.data[i].balance)/ Math.pow(10, res.data.data[i].tokenDecimal));

Loading…
Cancel
Save