diff --git a/pages/menu/sendToken/enPassword/index.vue b/pages/menu/sendToken/enPassword/index.vue index 90e034a..ac6fa1e 100644 --- a/pages/menu/sendToken/enPassword/index.vue +++ b/pages/menu/sendToken/enPassword/index.vue @@ -34,8 +34,7 @@ info: false, transInfoPass: { - }, - wallet: {} + } } }, @@ -46,91 +45,79 @@ this.info = false; } }, - finish2(e) { - if (this.wallet.password != e) { - this.info = true; - return; - } else { - this.info = false; - } - // 密码正确调用 - // 如果转的是trx - if (this.wallet.type == 'TRX') { - // 如果转的不是trx代币 - if (!this.contractAddress) { - this.$TronUtil.sendTransaction(this.transInfoPass.fromAddress, this.transInfoPass.privateKey, this - .transInfoPass.toAddress, this.transInfoPass.amount) - .then((res) => { - console.log(res, 111) + transaction() { + if (this.transInfoPass.type === 'ETH') { + this.$EthUtil.transaction(this.transInfoPass.fromAddress, this.transInfoPass.privateKey, + this.transInfoPass.toAddress, this.transInfoPass.amount, this.transInfoPass.contractAddress, + function(hash, err) { + if (!err) { + uni.showToast({ - title: 'Successfully', - icon: 'success', - duration: 2000 - }) - uni.reLaunch({ - url: '/pages/menu/wallet/index' + title: 'Transfer succeeded', + icon: 'none', + duration: 1500 }) - }).catch(err => { + setTimeout(() => { + that.fingerSuccess = false; + uni.reLaunch({ + url: '/pages/menu/wallet/index' + }) + }, 1000) + } else { + + console.log(err, 'cuowu') + uni.showToast({ - title: err, + title: 'Transfer failed, please confirm the information is correct', icon: 'none', - duration: 2000 + duration: 1500 }) + } + }) + } else if (this.transInfoPass.type === 'TRX') { + this.$TronUtil.transaction(this.transInfoPass.fromAddress, this.transInfoPass.privateKey, + this.transInfoPass.toAddress, this.transInfoPass.amount, this.transInfoPass.remark, this.transInfoPass.contractAddress) + .then((res) => { + + uni.showToast({ + title: 'Transfer succeeded', + icon: 'none', + duration: 1500 }) - } else { - // 如果转的是trx代币 - this.$TronUtil.sendRawTransaction(this.info.address, this.info.privateKey, this.toAddress, this - .toValue, '', this.contractAddress) - .then((res) => { - uni.showToast({ - title: 'Successfully', - icon: 'success', - duration: 2000 - }) - this.show2 = false; + setTimeout(() => { + uni.reLaunch({ url: '/pages/menu/wallet/index' }) - }).catch(err => { - console.log(err) - uni.showToast({ - title: err, - icon: 'none', - duration: 2000 - }) + }, 1000) + }).catch(err => { + console.log(err, 'cuowu') + + uni.showToast({ + title: 'Transfer failed, please confirm the information is correct', + icon: 'none', + duration: 1500 }) - } - - + }) } - if (this.wallet.type == 'ETH') { - if (this.info.coinList[0].xname == 'Ethereum') { - this.$EthUtil.transaction(this.info.address, this.toAddress, this.toValue, this.info.privateKey) - .then(( - res) => { - console.log(res, '钱包') - this.show2 = false; - uni.reLaunch({ - url: '../transfer2/index' - }) - }).catch(err => { - console.log(err) - }) - - } + + }, + finish2(e) { + if (this.transInfoPass.password != e) { + this.info = true; + return; + } else { + this.info = false; + this.transaction(); } - - }, }, onLoad() { // 拿到转账信息 this.transInfoPass = uni.getStorageSync('transInfoPass') - // 拿到当前钱包信息 - this.wallet = uni.getStorageSync('wallet') + uni.removeStorageSync('transInfoPass') console.log(this.transInfoPass, 2222) - console.log(this.wallet, 2222) } }; diff --git a/pages/menu/sendToken/index.vue b/pages/menu/sendToken/index.vue index 993b55e..32c5e2a 100644 --- a/pages/menu/sendToken/index.vue +++ b/pages/menu/sendToken/index.vue @@ -1,45 +1,46 @@ @@ -53,67 +54,65 @@ }, data() { return { - addressInfo:{}, - toTop:false, - // 二维码的数据 - showErweiMask: false, - ercodeText: '', - size: 400, - background: '#ffffff', - foreground: '#000000', - pdground: '#000000', - iconsize: 30, - lv: 3, - onval: true, - unit: 'upx', - loadMake: true, - icon: '', - showLoading: true, - loadingText: 'One moment please', - // 二维码的数据 - } + addressInfo: {}, + toTop: false, + // 二维码的数据 + showErweiMask: false, + ercodeText: '', + size: 400, + background: '#ffffff', + foreground: '#000000', + pdground: '#000000', + iconsize: 30, + lv: 3, + onval: true, + unit: 'upx', + loadMake: true, + icon: '', + showLoading: true, + loadingText: 'One moment please', + // 二维码的数据 + } }, methods: { - copyTextMethod() { - // #ifdef H5 - this.$copyText(this.addressInfo.address).then(res => { - this.toTop=true; - setTimeout(()=>{ - this.toTop=false; - },1500) - - }) - // #endif - // #ifdef APP-PLUS - var that=this - console.log(123132) - uni.setClipboardData({ - data: this.addressInfo.address, - success() { - uni.hideToast() - that.toTop=true; - setTimeout(()=>{ - that.toTop=false; - },1500) - } - }) - // #endif - }, + copyTextMethod() { + // #ifdef H5 + this.$copyText(this.addressInfo.address).then(res => { + this.toTop = true; + setTimeout(() => { + this.toTop = false; + }, 1500) + + }) + // #endif + // #ifdef APP-PLUS + var that = this + console.log(123132) + uni.setClipboardData({ + data: this.addressInfo.address, + success() { + uni.hideToast() + that.toTop = true; + setTimeout(() => { + that.toTop = false; + }, 1500) + } + }) + // #endif + }, }, onLoad() { - this.addressInfo=uni.getStorageSync('coin') + this.addressInfo = uni.getStorageSync('coin') } }; diff --git a/pages/menu/sendToken/transfer/index.vue b/pages/menu/sendToken/transfer/index.vue index a9b8ded..b347f6f 100644 --- a/pages/menu/sendToken/transfer/index.vue +++ b/pages/menu/sendToken/transfer/index.vue @@ -27,7 +27,7 @@ + v-model="transInfoPass.toAddress" /> @@ -44,15 +44,16 @@ {{coin.name}} + placeholder="0.0000000" class="input3" v-model="transInfoPass.amount" /> USD - + @@ -74,7 +75,7 @@ + placeholder="Please enter a note (off-chain)" v-model="transInfoPass.remark" class="input1" /> @@ -89,7 +90,7 @@ - {{coin.type}} + {{coin.type}} @@ -114,7 +115,7 @@ Amount - {{transAmount}} {{coin.name}} + {{transInfoPass.amount}} {{coin.name}} @@ -122,7 +123,7 @@ Send address - {{coin.address}} + {{transInfoPass.fromAddress}} @@ -130,7 +131,7 @@ Receiving address - {{recipientAddress}} + {{transInfoPass.toAddress}} @@ -156,7 +157,7 @@ - + @@ -170,7 +171,7 @@ Touch the fingerprint sensor - + Use Password @@ -213,14 +214,14 @@ Fingerprint recognized. - + @@ -243,15 +244,12 @@ export default { data() { return { - coin:{}, + coin: {}, fee: 0, show: false, show2: false, showFinger: false, showBottom: false, - addressInfo: {}, - recipientAddress: '', - transAmount: '', fingerSuccess: false, fingerFail: false, // 是否显示使用密码,有设置指纹就不显示 @@ -259,16 +257,85 @@ // 不用指纹去密码页面存的信息 transInfoPass: { fromAddress: '', - toAddress: "", + toAddress: '1', privateKey: '', - amount: '', + amount: '1', + remark:'1', + contractAddress:'', + password:'' } } }, methods: { - cancelAll(){ - this.show=false; - this.showBottom=false; + transaction() { + let that=this; + if (this.coin.type === 'ETH') { + this.$EthUtil.transaction(this.transInfoPass.fromAddress, this.transInfoPass.privateKey, + this.transInfoPass.toAddress, this.transInfoPass.amount, this.transInfoPass.contractAddress, + function(hash, err) { + if (!err) { + console.log(2222211111) + that.showFinger = false + that.showBottom = false; + that.fingerSuccess = true; + uni.showToast({ + title: 'Transfer succeeded', + icon: 'none', + duration: 1500 + }) + setTimeout(() => { + that.fingerSuccess = false; + uni.reLaunch({ + url: '/pages/menu/wallet/index' + }) + }, 1000) + } else { + + console.log(err, 'cuowu') + that.showFinger = false; + that.showBottom = true; + uni.showToast({ + title: 'Transfer failed, please confirm the information is correct', + icon: 'none', + duration: 1500 + }) + } + }) + } else if (this.coin.type === 'TRX') { + this.$TronUtil.transaction(this.transInfoPass.fromAddress, this.transInfoPass.privateKey, + this.transInfoPass.toAddress, this.transInfoPass.amount, this.transInfoPass.remark, this.transInfoPass.contractAddress) + .then((res) => { + console.log(1212121212121212) + that.showFinger = false + that.showBottom = false; + that.fingerSuccess = true; + uni.showToast({ + title: 'Transfer succeeded', + icon: 'none', + duration: 1500 + }) + setTimeout(() => { + that.fingerSuccess = false; + uni.reLaunch({ + url: '/pages/menu/wallet/index' + }) + }, 1000) + }).catch(err => { + console.log(err, 'cuowu') + that.showFinger = false; + that.showBottom = true; + uni.showToast({ + title: 'Transfer failed, please confirm the information is correct', + icon: 'none', + duration: 1500 + }) + }) + } + + }, + cancelAll() { + this.show = false; + this.showBottom = false; }, cancelFail() { this.printCancel() @@ -278,36 +345,39 @@ }, cancel() { this.showFinger = false - this.showBottom=true; + this.showBottom = true; this.printCancel() }, // 不用指纹去密码页 goPassword() { this.printCancel(); + this.show = false; + this.showBottom=false; console.log(111) + uni.setStorageSync('transInfoPass', this.transInfoPass) uni.navigateTo({ url: '/pages/menu/sendToken/enPassword/index' }) }, // 唤起指纹 confirmTo(type) { - if (type == 'try') { - this.fingerFail = false; + if(!this.passShow){ + this.goPassword(); + }else{ + console.log('点击提交') + if (type == 'try') { + this.fingerFail = false; + } + console.log(123123132132132) + this.show = true + this.showFinger = true + this.showBottom = false; + + + this.fingerprint(); } - console.log(123123132132132) - this.show = true - this.showFinger = true - this.showBottom = false; - // 存储去密码页面的信息 - this.transInfoPass.fromAddress = this.addressInfo.address; - this.transInfoPass.toAddress = this.recipientAddress; - this.transInfoPass.privateKey = this.addressInfo.privateKey; - this.transInfoPass.amount = this.transAmount; - console.log(this.transInfoPass, 444) - // 存储去密码页面的信息 - uni.setStorageSync('transInfoPass', this.transInfoPass) - this.fingerprint(); - + + }, back() { uni.reLaunch({ @@ -316,12 +386,12 @@ }, // 点击获取所有钱 forAll() { - this.transAmount = this.coin.balance + this.transInfoPass.amount = this.coin.balance }, // 确认提交 Confirm() { // 做判断 - if (this.transAmount == '') { + if (this.transInfoPass.amount == '') { uni.showToast({ title: 'Please enter the transfer amount', icon: 'none', @@ -329,7 +399,7 @@ }) return } - if (this.recipientAddress == '') { + if (this.transInfoPass.toAddress == '') { uni.showToast({ title: 'Please enter the receiving address', icon: 'none', @@ -337,7 +407,7 @@ }) return } - if (this.transAmount == '' < 0) { + if (Number(this.transInfoPass.amount) == '' < 0) { uni.showToast({ title: 'The entered amount cannot be less than 0', icon: 'none', @@ -345,7 +415,7 @@ }) return } - if( this.transAmount>this.coin.balance){ + if (Number(this.transInfoPass.amount) > this.coin.balance) { uni.showToast({ title: 'Sorry, your credit is running low', icon: 'none', @@ -357,13 +427,13 @@ this.show = true; }, // 取消指纹识别 - printCancel(){ - this.showFinger=false; - console.log(this.showFinger,4444) - plus.fingerprint.cancel(); - console.log(this.showFinger,4444) - - }, + printCancel() { + this.showFinger = false; + console.log(this.showFinger, 4444) + //plus.fingerprint.cancel(); + console.log(this.showFinger, 4444) + + }, fingerprint: function(sett) { let bltype = true; // #ifdef APP-PLUS @@ -412,127 +482,9 @@ // #ifdef APP-PLUS plus.fingerprint.authenticate(function() { plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框 - console.log(that.transInfoPass,5656) - console.log(that.addressInfo,56556656) - if (that.addressInfo.type == 'TRX') { - console.log(that.addressInfo.type,11111) - console.log(that.transInfoPass,2222) - // if (!this.contractAddress) { - // 指纹通过转账成功 - that.$TronUtil.sendTransaction(that.transInfoPass.fromAddress,that.transInfoPass.privateKey,that.transInfoPass.toAddress,that.transInfoPass.amount ) - .then((res) => { - console.log(1212121212121212) - that.showFinger = false - that.showBottom = false; - that.fingerSuccess = true; - uni.showToast({ - title: 'Transfer succeeded', - icon: 'none', - duration: 1500 - }) - setTimeout(()=>{ - that.fingerSuccess = false; - uni.reLaunch({ - url: '/pages/menu/wallet/index' - }) - },1000) - }).catch(err => { - console.log(err,'cuowu') - that.showFinger=false; - that.showBottom=true; - uni.showToast({ - title: 'Transfer failed, please confirm the information is correct', - icon: 'none', - duration: 1500 - }) - }) - // }else{ - // this.$TronUtil.sendRawTransaction(this.info.address, this.info.privateKey, this.toAddress, this.toValue,'',this.contractAddress ) - // .then((res) => { - // uni.showToast({ - // title: 'Successfully', - // icon: 'success', - // duration: 2000 - // }) - // this.show2 = false; - // uni.reLaunch({ - // url: '/pages/menu/wallet/index' - // }) - // }).catch(err => { - // console.log(err) - // uni.showToast({ - // title: err, - // icon: 'none', - // duration: 2000 - // }) - // }) - // } - - - } - - - if (that.addressInfo.type == 'ETH') { - console.log(that.addressInfo.type,11111) - console.log(that.transInfoPass,2222) - // if (!this.contractAddress) { - // 指纹通过转账成功 - that.$EthUtil.transaction(that.transInfoPass.fromAddress,that.transInfoPass.privateKey,that.transInfoPass.toAddress,that.transInfoPass.amount ) - .then((res) => { - console.log(2222211111) - that.showFinger = false - that.showBottom = false; - that.fingerSuccess = true; - uni.showToast({ - title: 'Transfer succeeded', - icon: 'none', - duration: 1500 - }) - setTimeout(()=>{ - that.fingerSuccess = false; - uni.reLaunch({ - url: '/pages/menu/wallet/index' - }) - },1000) - - - }).catch(err => { - console.log(err,'cuowu') - that.showFinger=false; - that.showBottom=true; - uni.showToast({ - title: 'Transfer failed, please confirm the information is correct', - icon: 'none', - duration: 1500 - }) - }) - // }else{ - // this.$TronUtil.sendRawTransaction(this.info.address, this.info.privateKey, this.toAddress, this.toValue,'',this.contractAddress ) - // .then((res) => { - // uni.showToast({ - // title: 'Successfully', - // icon: 'success', - // duration: 2000 - // }) - // this.show2 = false; - // uni.reLaunch({ - // url: '/pages/menu/wallet/index' - // }) - // }).catch(err => { - // console.log(err) - // uni.showToast({ - // title: err, - // icon: 'none', - // duration: 2000 - // }) - // }) - // } - - - } - - - + + that.transaction() + }, function(e) { switch (e.code) { case e.AUTHENTICATE_MISMATCH: @@ -609,18 +561,20 @@ } }, onLoad() { - // 拿从地址页面传过来的接受地址 - if(uni.getStorageSync('myTransAddress')){ - this.recipientAddress=uni.getStorageSync('myTransAddress').address - // 拿完清掉 - uni.removeStorageSync('myTransAddress') - } - this.coin=uni.getStorageSync('coin') + + this.coin = uni.getStorageSync('coin') + // 每次进来拿缓存里有没有指纹 + this.transInfoPass.fromAddress=this.coin.address; + this.transInfoPass.privateKey=this.coin.privateKey; + this.transInfoPass.password=this.coin.password; + this.transInfoPass.contractAddress=this.coin.contractAddress + this.transInfoPass.type=this.coin.type; + console.log(this.transInfoPass,'指纹') if (uni.getStorageSync('fingerPass')) { this.passShow = uni.getStorageSync('fingerPass') } - + } }; diff --git a/pages/menu/setting/index.vue b/pages/menu/setting/index.vue index 702b4e2..dbc4b65 100644 --- a/pages/menu/setting/index.vue +++ b/pages/menu/setting/index.vue @@ -5,12 +5,7 @@ - - - Payment password - - - + Fingerprint password diff --git a/pages/menu/token/btc/index.css b/pages/menu/token/btc/index.css index b9bb5f4..36962fd 100644 --- a/pages/menu/token/btc/index.css +++ b/pages/menu/token/btc/index.css @@ -1,185 +1,211 @@ -.renYou{ +.renYou { width: 48rpx; height: 48rpx; position: absolute; right: 30rpx; } -.big_title{ + +.big_title { font-size: 36rpx; } -.main .money_con{ +.main .money_con { display: block; - width:95%; + width: 95%; margin: 0 auto; margin-top: 50rpx; margin-bottom: 50rpx; height: 320rpx; - background-image: linear-gradient(to right, #FF820C , #FFB606); - padding: 40rpx 50rpx; + background-image: linear-gradient(to right, #FF820C, #FFB606); + padding: 40rpx 50rpx; border-radius: 24rpx; } -.textcon1{ + +.textcon1 { display: flex; align-items: center; justify-content: space-between; line-height: 56rpx; } -.textcon1 .text1{ + +.textcon1 .text1 { color: #fff; - font-size: 56rpx ; + font-size: 56rpx; } -.textcon1 .text1 .text2{ + +.textcon1 .text1 .text2 { color: #fff; - font-size: 32rpx ; + font-size: 32rpx; } -.textcon1 .img1{ + +.textcon1 .img1 { width: 100rpx; height: 110rpx; } -.textcon1 .v1{ - -} -.textcon1 .v1 .t1{ + +.textcon1 .v1 {} + +.textcon1 .v1 .t1 { color: #fff; font-size: 32rpx; } -.textcon1 .v1 .t2{ + +.textcon1 .v1 .t2 { color: #fff; font-size: 24rpx; } -.textcon1 .v2{ + +.textcon1 .v2 { margin-right: 100rpx; } -.select_con{ + +.select_con { width: 100%; - padding-bottom: 260rpx; + padding-bottom: 260rpx; } -.select_con .select{ - margin: 0 12px; + +.select_con .select { + margin: 0 12px; border-radius: 30rpx; - background-color: #fff; + background-color: #fff; box-shadow: 0 0 30px #EBEEF1; } -/deep/ .u-tabs{ + +/deep/ .u-tabs { border-bottom: 2rpx solid #F6F8FD; border-radius: 30rpx 30rpx 0 0; } -.select_con .item1{ + +.select_con .item1 { display: flex; justify-content: space-between; padding-top: 60rpx; padding-bottom: 50rpx; border-bottom: 2rpx solid #F6F8FD; padding-left: 40rpx; - padding-right: 24rpx; + padding-right: 24rpx; } -.select_con .item1 .lef_con{ + +.select_con .item1 .lef_con { display: flex; align-items: center; } -.select_con .item1 .lef_con .img1{ + +.select_con .item1 .lef_con .img1 { width: 48rpx; height: 48rpx; } -.select_con .item1 .lef_con .textcon{ + +.select_con .item1 .lef_con .textcon { margin-left: 24rpx; } -.select_con .item1 .lef_con .textcon .text1{ - font-size: 32rpx; + +.select_con .item1 .lef_con .textcon .text1 { + font-size: 26rpx; } -.select_con .item1 .lef_con .textcon .text2{ - font-size: 24rpx; + +.select_con .item1 .lef_con .textcon .text2 { + font-size: 22rpx; color: #999; } -.select_con .item1 .rig_con .text1{ - font-size: 32rpx; +.select_con .item1 .rig_con .text1 { + font-size: 24rpx; } -.select_con .item1 .rig_con .img1{ + +.select_con .item1 .rig_con .img1 { width: 28rpx; height: 20rpx; float: right; margin-top: 20rpx; } -.select_con .item1 .rig_con .img2{ + +.select_con .item1 .rig_con .img2 { width: 28rpx; height: 40rpx; float: right; margin-top: 20rpx; } -.btnconn{ - position: fixed; - bottom: 0; + +.btnconn { + position: fixed; + bottom: 0; background-color: #fff; padding: 24rpx 24rpx; width: 100%; display: flex; justify-content: space-between; } -.btnconn .btn{ - width: 334rpx; - line-height: 96rpx; + +.btnconn .btn { + width: 306rpx; + line-height: 78rpx; border-radius: 30rpx; border: 2rpx solid #5B53FF; text-align: center; display: flex; align-items: center; - color:#5B53FF; - justify-content: center; - font-size: 34rpx; + color: #5B53FF; + justify-content: center; + font-size: 28rpx; position: relative; } -.active{ - color: #fff !important; + +.active { + color: #fff !important; background-color: #5B53FF; } -.btnconn .btn .img1{ + +.btnconn .btn .img1 { width: 48rpx; height: 48rpx; } -.arrow-up-left{ - width: 48rpx; - height: 48rpx; +.arrow-up-left { + width: 44rpx; + height: 44rpx; position: absolute; top: 50%; transform: translateY(-50%); left: 68rpx; } -.btn13{ + +.btn13 { margin-left: 40rpx; } -.main .money_con{ +.main .money_con { margin-top: 32rpx; - background-image: linear-gradient(to right, #6441CF , #877BFE); - height: 320rpx; + background-image: linear-gradient(to right, #6441CF, #877BFE); + height: 320rpx; padding: 40rpx 36rpx; position: relative; border-radius: 24rpx; } -.main .money_con2{ + +.main .money_con2 { margin-top: 32rpx; - background-image: linear-gradient(to right, #FF820C , #FFB606); - height: 320rpx; + background-image: linear-gradient(to right, #FF820C, #FFB606); + height: 320rpx; padding: 40rpx 36rpx; position: relative; border-radius: 24rpx; } - .main .money_con3{ + +.main .money_con3 { margin-top: 32rpx; - background-image: linear-gradient(to right, #B6162A , #F96D7D); - height: 320rpx; + background-image: linear-gradient(to right, #B6162A, #F96D7D); + height: 320rpx; padding: 40rpx 36rpx; position: relative; border-radius: 24rpx; } -.select_con .item1 .rig_con .text1 text{ - margin-left: 10rpx; +.select_con .item1 .rig_con .text1 text { + margin-left: 10rpx; } + /deep/ .u-empty { - padding: 30px !important; -} \ No newline at end of file + padding: 30px !important; +} diff --git a/pages/menu/token/btc/index.vue b/pages/menu/token/btc/index.vue index 482638e..55db849 100644 --- a/pages/menu/token/btc/index.vue +++ b/pages/menu/token/btc/index.vue @@ -45,7 +45,7 @@ - diff --git a/pages/menu/transction/detail/index.vue b/pages/menu/transction/detail/index.vue index 1b0efcd..9702c20 100644 --- a/pages/menu/transction/detail/index.vue +++ b/pages/menu/transction/detail/index.vue @@ -2,102 +2,103 @@ - Transaction details + Transaction details - - - - - - Confirmed - - - - - - - Amount - - - {{info.value}} {{info.network}} - - - - - Time - - - {{info.time}} - - - - - Tx Fee - - - {{info.fee}} {{info.network}} - - - - - Transaction ID - - - {{info.txid}} - - - - - - Send address - (others) - (me) - - - {{info.from}} - - - - - - Receiving address - (me) - (others) - - - {{info.to}} - - - - - - Go to your browser for more information - - - - - Copy address - - - Add to Address Book + + + - - - Cancel + + Confirmed + + + + + + Amount + + + {{info.value}} {{info.network}} + + + + + Time + + + {{info.time}} + + + + + Tx Fee + + + {{info.fee}} {{info.network}} + + + + + Transaction ID + + + {{info.txid}} + + + + + + Send address + (others) + (me) + + + {{info.from}} + + + + + + Receiving address + (me) + (others) + + + {{info.to}} + + + + + + Go to your browser for more information + + + + + + - - - - - - + @@ -109,16 +110,48 @@ export default { data() { return { - show: false, - info:{}, + show: false, + info: {}, + isIn:true, + toTop: false, } }, methods: { - + copyTextMethod(text) { + console.log(text) + // #ifdef H5 + this.$copyText(text).then(res => { + // Copy address Successful! + uni.showToast({ + title: 'Copy Successful!', + icon: 'none', + duration: 1500 + }) + + }) + // #endif + // #ifdef APP-PLUS + var that = this + console.log(123132) + uni.setClipboardData({ + data: text, + success() { + uni.showToast({ + title: 'Copy Successful!', + icon: 'none', + duration: 1500 + }) + } + }) + // #endif + } }, onLoad(option) { - this.info=uni.getStorageSync('transDetail') - this.info.time = index.formatyymmddhhmmss33(this.info.time); + this.info = uni.getStorageSync('transDetail') + console.log(this.info.type) + this.isIn=this.info.type==='in'; + console.log(this.isIn) + this.info.time = index.formatyymmddhhmmss33(this.info.time); } }; diff --git a/pages/menu/wallet/cwallet/index.css b/pages/menu/wallet/cwallet/index.css index 863987c..afd8e45 100644 --- a/pages/menu/wallet/cwallet/index.css +++ b/pages/menu/wallet/cwallet/index.css @@ -133,7 +133,7 @@ .bot_con .item .rig{ text-align: right; color: #fff; - font-size: 34rpx; + font-size: 30rpx; } .bot_con .item .rig .text1{ diff --git a/pages/menu/wallet/index.vue b/pages/menu/wallet/index.vue index 05bbdef..809216b 100644 --- a/pages/menu/wallet/index.vue +++ b/pages/menu/wallet/index.vue @@ -106,8 +106,11 @@ onLoad() { // 拿钱包 this.userObj = uni.getStorageSync('wallet'); - // this.userObj2 = uni.getStorageSync('wallet'); - this.updateData(); + let that=this; + this.$walletUtil.updateBalance(function(){ + that.userObj = uni.getStorageSync('wallet'); + that.userObj2 = uni.getStorageSync('wallet'); + }); }, // onPullDownRefresh() { @@ -118,30 +121,7 @@ // }, 500); // }, methods: { - updateData() { - let thar = this; - setTimeout( - function() { - thar.userObj = uni.getStorageSync('wallet'); - thar.userObj2 = uni.getStorageSync('wallet'); - // thar.userObj.address = thar.userObj.ellipsisAddress; - - // thar.userObj.address =thar.userObj.address.substring(0, 6) + '...' + thar.userObj.address.substring(25, - // thar.userObj.address.length); - // thar.$walletUtil.updateBalance(); - // thar.updateData(); - // }, 100); - - thar.$walletUtil.updateBalance(); - - console.log(thar.isStop,4444) - if (!thar.isStop) { - // thar.updateData() - } - }, 2000); - - - }, + goOther() { console.log(this.userObj2, 8888) let item = JSON.stringify(this.userObj2) @@ -163,7 +143,9 @@ goTrans(itemm, index) { let coin = this.userObj.coinList[index]; coin.type=this.userObj.type; + coin.privateKey=this.userObj.privateKey; coin.address=this.userObj.address; + coin.password=this.userObj.password; uni.setStorageSync('coin',coin) uni.navigateTo({ url: '/pages/menu/token/btc/index' diff --git a/pages/menu/wallet/mwallet/index.css b/pages/menu/wallet/mwallet/index.css index 6c01589..671a192 100644 --- a/pages/menu/wallet/mwallet/index.css +++ b/pages/menu/wallet/mwallet/index.css @@ -102,18 +102,18 @@ width:auto;flex:1 } .bot_con .item .left .textcon .text1{ - font-size: 36rpx; + font-size: 30rpx; color: #fff; } .bot_con .item .left .textcon .text2{ - font-size: 28rpx; - color: rgba(255,255,255,.5); + font-size: 24rpx; + color: #FFFFFF; word-break: break-word; } .bot_con .item .rig{ text-align: right; color: #fff; - font-size: 34rpx; + font-size: 30rpx; } .bot_con .item .rig .text1{ diff --git a/utils/EthUtil.js b/utils/EthUtil.js index 5800c44..e81312e 100644 --- a/utils/EthUtil.js +++ b/utils/EthUtil.js @@ -97,7 +97,7 @@ let eth = { - transaction: async function(fromAddress, toAddress, value, privateKey, success) { + sendTransaction: async function(fromAddress, toAddress, value, privateKey, success) { var nonce = await web3.eth.getTransactionCount(fromAddress); var gas = await web3.eth.estimateGas({ @@ -208,6 +208,14 @@ let eth = { + }, + transaction:async function(fromAddress, toAddress, value, privateKey, contract, success){ + if(contract){ + await this.sendTokenTransaction(fromAddress, toAddress, value, privateKey, contract, success); + }else{ + await this.sendTransaction(fromAddress, toAddress, value, privateKey, success) + + } } } export default eth; diff --git a/utils/TronUtil.js b/utils/TronUtil.js index 20bfcef..57bf24b 100644 --- a/utils/TronUtil.js +++ b/utils/TronUtil.js @@ -76,6 +76,13 @@ let tron = { } return null; }, + transaction:async function(fromAddress, privateKey, toAddress, amount, remark, contract){ + if(contract){ + return await this.sendRawTransaction(fromAddress, privateKey, toAddress, amount, remark, contract); + }else{ + return await this.sendTransaction(fromAddress, privateKey, toAddress, amount); + } + }, getContract:function(address,list,success){ uni.request({ url: 'https://apiasia.tronscan.io:5566/api/account/tokens?limit=100&address=' + address, //请求接口 diff --git a/utils/WalletUtil.js b/utils/WalletUtil.js index 2622aa4..0345c5e 100644 --- a/utils/WalletUtil.js +++ b/utils/WalletUtil.js @@ -7,7 +7,7 @@ let fullWallet = { "BTC": [{ balance: 0, name: "BTC", - type:'BTC', + type: 'BTC', coinList: [{ name: "BTC", xname: 'Bitcoin', @@ -18,7 +18,7 @@ let fullWallet = { "ETH": [{ balance: 0, name: "ETH", - type:'ETH', + type: 'ETH', coinList: [{ name: "ETH", xname: 'Ethereum', @@ -37,7 +37,7 @@ let fullWallet = { "TRX": [{ balance: 0, name: "TRX", - type:'TRX', + type: 'TRX', coinList: [{ name: "TRX", xname: 'TRON', @@ -58,7 +58,7 @@ let fullWallet = { let WalletUtil = { //初次创建钱包 initialWallet: function(mnemonic, password) { - console.log(password,'password') + console.log(password, 'password') let walletInfo = fullWallet; let btc = TokenUtil.generateBtc(mnemonic); walletInfo.BTC[0].password = password; @@ -95,30 +95,30 @@ let WalletUtil = { //助记词新建 mnemonicEstablishWallet: function(type, mnemonic, password) { let walletInfo = uni.getStorageSync('walletInfo'); - console.log(password,'password',type) + console.log(password, 'password', type) let walletdec; switch (type) { case 'BTC': walletdec = TokenUtil.generateBtc(mnemonic); - if(uni.getStorageSync('walletInfo')){ - uni.setStorageSync('walleti',walletdec.address) + if (uni.getStorageSync('walletInfo')) { + uni.setStorageSync('walleti', walletdec.address) } - + break; case 'ETH': walletdec = TokenUtil.generateEth(mnemonic); - if(uni.getStorageSync('walletInfo')){ - uni.setStorageSync('walleti',walletdec.address) + if (uni.getStorageSync('walletInfo')) { + uni.setStorageSync('walleti', walletdec.address) } - + break; case 'TRX': - + walletdec = TokenUtil.generateTron(mnemonic); - if(uni.getStorageSync('walletInfo')){ - uni.setStorageSync('walleti',walletdec.address) + if (uni.getStorageSync('walletInfo')) { + uni.setStorageSync('walleti', walletdec.address) } - + break; } let wallet = fullWallet[type][0]; @@ -132,13 +132,13 @@ let WalletUtil = { uni.setStorageSync('walletInfo', walletInfo); uni.setStorageSync('wallet', wallet); uni.setStorageSync('walleti', wallet.address); - + }, //私钥新建 privateKeyEstablishWallet: function(type, privateKey, password) { let walletInfo = uni.getStorageSync('walletInfo'); console.log(type) - console.log(password,'password') + console.log(password, 'password') let walletdec; switch (type) { case 'BTC': @@ -156,7 +156,7 @@ let WalletUtil = { wallet.privateKey = walletdec.privateKey; wallet.address = walletdec.address; walletInfo[type].push(wallet); - console.log(walletInfo,'当前私钥建的') + console.log(walletInfo, '当前私钥建的') uni.setStorageSync('walletInfo', walletInfo); uni.setStorageSync('wallet', wallet); uni.setStorageSync('walleti', wallet.address); @@ -176,8 +176,9 @@ let WalletUtil = { for (let obj in walletInfo) { for (var k = 0, length = walletInfo[obj].length; k < length; k++) { let address = walletInfo[obj][k].address; - - walletInfo[obj][k].ellipsisAddress = address.substring(0, 6) + '...' + address.substring(address.length-6, + + walletInfo[obj][k].ellipsisAddress = address.substring(0, 6) + '...' + address.substring( + address.length - 6, address.length); walletInfo[obj][k].type = obj; walletList.push(walletInfo[obj][k]); @@ -199,78 +200,86 @@ let WalletUtil = { uni.setStorageSync('wallet', walletList[k]); break; } - + } }, - updateBalance:function() { + updateBalance: function(success) { const wallet = uni.getStorageSync('wallet'); - console.log(wallet,'更新余额') + console.log(wallet, '更新余额') const walletInfo = uni.getStorageSync('walletInfo'); for (var k = 0, length = walletInfo[wallet.type].length; k < length; k++) { - if (walletInfo[wallet.type][k].address === wallet.address) { - walletInfo[wallet.type][k]=wallet; - break; + if (walletInfo[wallet.type][k].address === wallet.address) { + walletInfo[wallet.type][k] = wallet; + break; } } - uni.setStorageSync('walletInfo', walletInfo); - let that=this - this.getPrice(wallet.type,function(rr){ - that.getPrice('USDT',function(usdt){ + uni.setStorageSync('walletInfo', walletInfo); + let that = this + this.getPrice(wallet.type, function(rr) { + that.getPrice('USDT', function(usdt) { switch (wallet.type) { case 'BTC': - console.log("进来BTC") - BtcUtil.getBalance(wallet.address,function(balance){ - wallet.balance=balance; - wallet.balancePrice=(balance*rr).toFixed(2); - wallet.coinList[0].balance=balance - wallet.coinList[0].balancePrice=wallet.balancePrice + console.log("进来BTC") + BtcUtil.getBalance(wallet.address, function(balance) { + wallet.balance = balance; + wallet.balancePrice = (balance * rr).toFixed(2); + wallet.coinList[0].balance = balance + wallet.coinList[0].balancePrice = wallet.balancePrice uni.setStorageSync('wallet', wallet); + success() }) break; case 'ETH': - console.log("进来ETH") - EthUtil.getBalance(wallet.address,function(balance){ - wallet.balance=balance; - wallet.balancePrice=(balance*rr).toFixed(2); - wallet.coinList[0].balance=balance - wallet.coinList[0].balancePrice=wallet.balancePrice - for(let i=1;i { - wallet.balance=res; - wallet.balancePrice=(res*rr).toFixed(2); - wallet.coinList[0].balance=res - wallet.coinList[0].balancePrice=wallet.balancePrice - TronUtil.getContract(wallet.address,wallet.coinList,function(list){ - wallet.coinList=list; - wallet.coinList[1].balancePrice=(wallet.coinList[1].balance*usdt).toFixed(2); - console.log(wallet.coinList) - uni.setStorageSync('wallet', wallet); - }) - + wallet.balance = res; + wallet.balancePrice = (res * rr).toFixed(2); + wallet.coinList[0].balance = res + wallet.coinList[0].balancePrice = wallet.balancePrice + TronUtil.getContract(wallet.address, wallet.coinList, + function(list) { + wallet.coinList = list; + wallet.coinList[1].balancePrice = (wallet + .coinList[1].balance * usdt).toFixed(2); + console.log(wallet.coinList) + uni.setStorageSync('wallet', wallet); + success() + }) + }) - + break; - + } - + }) - + }) - + }, - getPrice:function(type,success){ + getPrice: function(type, success) { uni.request({ url: 'https://apilist.tronscan.org/api/token/price?token=' + type.toLowerCase(), //请求接口 header: { @@ -279,61 +288,61 @@ let WalletUtil = { success: (res) => { console.log(res.data.price_in_usd) success(res.data.price_in_usd) - - - + + + } }); - + }, - - + + // 封装地址方法 - updateAddress:function(type,value,bigAddress,addressName) { - let that=this - switch (wallet.type) { - case 'BTC': - - break; - case 'ETH': - - - break; - case 'TRX': - if(value=='ETH'){ - const gai = uni.getStorageSync('ETHAddressInfo') - const gai2 = uni.getStorageSync('TRXAddressInfo') - const index=uni.getStorageSync('editIndex') - let eth=new Object; - eth.address=bigAddress; - eth.name=addressName - eth.coinList=[{ - name:"ETH", - name2:"ETH", - xname:'Ethereum', - icon:require('@/static/tongyonh/Frame3299.png') - }]; - gai2.splice(index,1) - uni.setStorageSync('TRXAddressInfo',gai2) - gai.push(eth); - uni.setStorageSync('ETHAddressInfo',gai) - uni.showToast({ - title: 'Successfully', - icon: 'success', - duration: 1500 - }) - uni.navigateTo({ - url:'../address/index' - }) - } - - break; - + updateAddress: function(type, value, bigAddress, addressName) { + let that = this + switch (wallet.type) { + case 'BTC': + + break; + case 'ETH': + + + break; + case 'TRX': + if (value == 'ETH') { + const gai = uni.getStorageSync('ETHAddressInfo') + const gai2 = uni.getStorageSync('TRXAddressInfo') + const index = uni.getStorageSync('editIndex') + let eth = new Object; + eth.address = bigAddress; + eth.name = addressName + eth.coinList = [{ + name: "ETH", + name2: "ETH", + xname: 'Ethereum', + icon: require('@/static/tongyonh/Frame3299.png') + }]; + gai2.splice(index, 1) + uni.setStorageSync('TRXAddressInfo', gai2) + gai.push(eth); + uni.setStorageSync('ETHAddressInfo', gai) + uni.showToast({ + title: 'Successfully', + icon: 'success', + duration: 1500 + }) + uni.navigateTo({ + url: '../address/index' + }) } - + + break; + + } + }, // 指纹识别 - finger(){ + finger() { // #ifdef APP-PLUS if (!plus.fingerprint.isSupport()) { this.result = '此设备不支持指纹识别'; @@ -357,116 +366,118 @@ let WalletUtil = { this.result = '此平台不支持指纹识别'; // #endif }, - - fingerprint: function(sett) { - let bltype=true; - // #ifdef APP-PLUS - if (!plus.fingerprint.isSupport()) { - uni.showToast({ - title: 'This device does not support fingerprint identification', - icon: 'none', - duration: 1500 - }) - // this.disabled = true; - } else if (!plus.fingerprint.isKeyguardSecure()) { - uni.showToast({ - title: 'This device is not equipped with a password lock screen and cannot use fingerprint identification', - icon: 'none', - duration: 1500 - }) - - } else if (!plus.fingerprint.isEnrolledFingerprints()) { - uni.showToast({ - title: 'There is no fingerprint entered in this device. Please turn it on in the setting', - icon: 'none', - duration: 1500 - }) - // this.disabled = true; - } else { - // this.result = '此设备支持指纹识别'; - // // this.disabled = false; - // #ifdef MP-WEIXIN - // this.disabled = false; + + fingerprint: function(sett) { + let bltype = true; + // #ifdef APP-PLUS + if (!plus.fingerprint.isSupport()) { + uni.showToast({ + title: 'This device does not support fingerprint identification', + icon: 'none', + duration: 1500 + }) + // this.disabled = true; + } else if (!plus.fingerprint.isKeyguardSecure()) { + uni.showToast({ + title: 'This device is not equipped with a password lock screen and cannot use fingerprint identification', + icon: 'none', + duration: 1500 + }) + + } else if (!plus.fingerprint.isEnrolledFingerprints()) { + uni.showToast({ + title: 'There is no fingerprint entered in this device. Please turn it on in the setting', + icon: 'none', + duration: 1500 + }) + // this.disabled = true; + } else { + // this.result = '此设备支持指纹识别'; + // // this.disabled = false; + // #ifdef MP-WEIXIN + // this.disabled = false; + uni.showToast({ + title: 'Please use it in wechat real machine. The simulator does not support it', + icon: 'none', + duration: 1500 + }) + // #endif + // #ifndef APP-PLUS || MP-WEIXIN + uni.showToast({ + title: 'Fingerprint identification is not supported on this platform', + icon: 'none', + duration: 1500, + }) + // #endif + + + let that = this; + let forSett = true; + // #ifdef APP-PLUS + plus.fingerprint.authenticate(function() { + plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框 + // uni.showToast({ + // title: 'Fingerprint identification succeeded', + // icon: 'none', + // duration: 1500, + // }) + // 存储设置里开启指纹后的状态,隐藏使用密码 + console.log(forSett, 12121) + if (sett) { + uni.setStorageSync('fingerPass', true) + console.log(forSett, 12121) + + } + //plus.nativeUI.alert('Fingerprint identification succeeded'); + }, function(e) { + switch (e.code) { + case e.AUTHENTICATE_MISMATCH: + plus.nativeUI.toast('Fingerprint matching failed, please re-enter'); + break; + case e.AUTHENTICATE_OVERLIMIT: + plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框 + plus.nativeUI.alert( + 'The number of fingerprint identification failures exceeds the limit. Please use other methods for authentication' + ); + break; + case e.CANCEL: + plus.nativeUI.toast('Recognition has been cancelled'); + break; + default: + plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框 + plus.nativeUI.alert('Fingerprint identification failed, please try again'); + break; + } + }); + // Android平台手动弹出等待提示框 + if ('Android' == plus.os.name) { + this.show = true; + /* plus.nativeUI.showWaiting('指纹识别中...').onclose = function() { + plus.fingerprint.cancel(); + } */ + } + // #endif + + // #ifdef MP-WEIXIN + wx.startSoterAuthentication({ + requestAuthModes: ['fingerPrint'], + challenge: '123456', + authContent: '请用指纹解锁', + success(res) { uni.showToast({ - title: 'Please use it in wechat real machine. The simulator does not support it', - icon: 'none', + title: '识别成功', + mask: false, duration: 1500 - }) - // #endif - // #ifndef APP-PLUS || MP-WEIXIN - uni.showToast({ - title: 'Fingerprint identification is not supported on this platform', - icon: 'none', - duration: 1500, - }) - // #endif - - - let that=this; - let forSett=true; - // #ifdef APP-PLUS - plus.fingerprint.authenticate(function() { - plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框 - // uni.showToast({ - // title: 'Fingerprint identification succeeded', - // icon: 'none', - // duration: 1500, - // }) - // 存储设置里开启指纹后的状态,隐藏使用密码 - console.log(forSett,12121) - if(sett){ - uni.setStorageSync('fingerPass',true) - console.log(forSett,12121) - - } - //plus.nativeUI.alert('Fingerprint identification succeeded'); - }, function(e) { - switch (e.code) { - case e.AUTHENTICATE_MISMATCH: - plus.nativeUI.toast('Fingerprint matching failed, please re-enter'); - break; - case e.AUTHENTICATE_OVERLIMIT: - plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框 - plus.nativeUI.alert('The number of fingerprint identification failures exceeds the limit. Please use other methods for authentication'); - break; - case e.CANCEL: - plus.nativeUI.toast('Recognition has been cancelled'); - break; - default: - plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框 - plus.nativeUI.alert('Fingerprint identification failed, please try again'); - break; - } }); - // Android平台手动弹出等待提示框 - if ('Android' == plus.os.name) { - this.show=true; - /* plus.nativeUI.showWaiting('指纹识别中...').onclose = function() { - plus.fingerprint.cancel(); - } */ - } - // #endif - - // #ifdef MP-WEIXIN - wx.startSoterAuthentication({ - requestAuthModes: ['fingerPrint'], - challenge: '123456', - authContent: '请用指纹解锁', - success(res) { - uni.showToast({ - title: '识别成功', - mask: false, - duration: 1500 - }); - } - }) - // #endif } - // #endif - - - }, - printCancel:function(){ + }) + // #endif + } + // #endif + + + }, + printCancel: function() { plus.fingerprint.cancel(); // this.result="停止指纹识别" },