bitcooo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

697 lines
18 KiB

<template>
<view class="ac">
<navigation :showBack="false" :bgnum="true">
<image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="back" @click="back()"></image>
<text class="big_title">
{{coin.name}} {{i18n.Transfer}}
</text>
</navigation>
<view class="main">
<view class="main_con">
<view class="yuan">
<image :src="coin.icon" mode="aspectFit" class="img1"></image>
</view>
<view class="title">
{{coin.name}}
</view>
<view class="item">
<view class="top flex">
<view class="text1">
{{i18n.Receivingaddress}}
</view>
<view class="text2" @click="goAddress('transfer')">
{{i18n.AddressBook}}
</view>
</view>
<view class="inputcon">
<input type="text" value="" placeholder-style="font-size: 30rpx; color: #D0D0D2;"
:placeholder="teee" class="input1"
v-model="transInfoPass.toAddress" />
<image src="../../../../static/tongyonh/Frame330.png" mode="aspectFit" class="img1" @click="scanCode"></image>
</view>
</view>
<view class="item">
<view class="top flex">
<view class="text1">
{{i18n.Transferamount}}
</view>
</view>
<view class="inputcon2 flex">
<view class="inputc flex">
<view class="textt">
{{coin.name}}
</view>
<input type="text" value="" placeholder-style="font-size: 30rpx; color: #D0D0D2;"
placeholder="0.0000000" class="input3" v-model="transInfoPass.amount" />
</view>
<text> ≈ </text>
<view class="inputc flex">
<view class="textt">
{{currency}}
</view>
<input type="text" :value="(price*transInfoPass.amount).toFixed(2)" disabled="disabled"
placeholder-style="font-size: 30rpx; color: #D0D0D2;" placeholder="0.0000000"
class="input3" />
</view>
</view>
<view class="top flex bottom">
<view class="text3">
{{i18n.Balance}}: {{coin.balance}}
</view>
<view class="text1 bg" @click="forAll">
{{i18n.ALL}}
</view>
</view>
</view>
<view class="item">
<view class="top flex">
<view class="text1">
{{i18n.Remark}}
</view>
</view>
<view class="inputcon">
<input type="text" value="" placeholder-style="font-size: 30rpx; color: #D0D0D2;"
:placeholder="teee2" v-model="transInfoPass.remark"
class="input1" />
</view>
</view>
<view class="item">
<view class="top flex">
<view class="text1">
{{i18n.Transactionfee}}
</view>
</view>
<view class="inputcon">
<input type="text" v-model="transInfoPass.fee" disabled="disabled" value=""
placeholder-style="font-size: 30rpx; color: #D0D0D2;"
placeholder="Please enter a note (off-chain)" class="input2" />
<view class="rig">
<text class="text2">{{coin.type}}</text>
</view>
</view>
</view>
</view>
</view>
<view class="big_con" v-if="showBottom">
<view class="tiao" @click="cancelAll">
</view>
<view class="bigtitle">
{{i18n.Transferconfirmation}}
</view>
<view class="bottom_con">
<view class="yuan">
<image :src="coin.icon" mode="aspectFit" class="img1"></image>
</view>
<view class="title">
{{coin.type}}
</view>
<view class="title_con flex">
<view class="text1">
Amount
</view>
<view class="text1">
{{transInfoPass.amount}} {{coin.name}}
</view>
</view>
<view class="item">
<view class="text1">
Send address
</view>
<view class="text2">
{{transInfoPass.fromAddress}}
</view>
</view>
<view class="item">
<view class="text1">
{{i18n.Receivingaddress}}
</view>
<view class="text2">
{{transInfoPass.toAddress}}
</view>
</view>
<view class="item">
<view class="text1">
{{i18n.Remark}}
</view>
<view class="text2">
{{transInfoPass.remark}}
</view>
</view>
<view class="item">
<view class="text1">
{{i18n.Transactionfee}}
</view>
<view class="text2">
{{transInfoPass.fee}} {{coin.type}}
</view>
</view>
<view class="goto" @click="confirmTo">
{{i18n.Confirm}}
</view>
</view>
</view>
<u-mask z-index="10" :show="show" @click="cancelAll"></u-mask>
<!-- <u-mask z-index="1000" :show="show2" @click="show2 = false"></u-mask> -->
<view class="zhiwen_con" v-if="showFinger">
<view class="tiao" @click="cancel">
</view>
<view class="bigtitle">
{{i18n.Fingerprintpassword}}
</view>
<view class="bottom_con">
<image src="../../../../static/tongyonh/zhiwen.png" mode="aspectFit" class="img1"></image>
<view class="text1">
{{i18n.fingerprintsensor}}
</view>
<view class="flex con">
<view class="textt1" @click="goPassword">
{{i18n.UsePassword}}
</view>
<view class="textt2" @click="cancel">
{{i18n.Cancel}}
</view>
</view>
</view>
</view>
<view class="zhiwen_con" v-if="fingerFail">
<view class="tiao">
</view>
<view class="bigtitle">
{{i18n.Fingerprintpassword}}
</view>
<view class="bottom_con">
<image src="../../../../static/tongyonh/alert-circle.png" mode="aspectFit" class="img1"></image>
<view class="text1 red">
{{i18n.Fingerprintrecognized}}<br><text @click="confirmTo('try')">{{i18n.Tryagain}}</text> .
</view>
<view class="flex con">
<view class="textt1" @click="goPassword">
{{i18n.UsePassword}}
</view>
<view class="textt2" @click="cancelFail">
{{i18n.Cancel}}
</view>
</view>
</view>
</view>
<view class="zhiwen_con" v-if="fingerSuccess">
<view class="tiao">
</view>
<view class="bigtitle">
{{i18n.fingerPass}}
</view>
<view class="bottom_con">
<image src="../../../../static/tongyonh/x-circle.png" mode="aspectFit" class="img1"></image>
<view class="text1 green">
{{i18n.Fingerprintrecognized}}
</view>
<view class="flex con">
<view class="textt1">
{{i18n.UsePassword}}
</view>
<view class="textt2">
{{i18n.Confirm}}
</view>
</view>
</view>
</view>
<view class="btn_con" @click="Confirm">
<view class="btn">
{{i18n.Confirm}}
</view>
</view>
</view>
</template>
<script>
import cont from "@/components/navigation/navigation.vue"
export default {
data() {
return {
coin: {},
fee: 0,
show: false,
show2: false,
currency:'USD',
showFinger: false,
showBottom: false,
fingerSuccess: false,
fingerFail: false,
// 是否显示使用密码,有设置指纹就不显示
passShow: false,
price: 0,
// 不用指纹去密码页面存的信息
transInfoPass: {
fromAddress: '',
toAddress: '',
privateKey: '',
amount: '',
remark: '',
contractAddress: '',
password: '',
balancePrice: 0,
fee: 0
},
transaction: {},
teee:this.$t('index').Pleaserecipientaddress,
teee2:this.$t('index').offchain,
}
},
computed: {
i18n() {
return this.$t('index')
},
},
methods: {
sendTransaction() {
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: this.$t('index').Transfersucceeded,
icon: 'none',
duration: 1500
})
setTimeout(() => {
that.fingerSuccess = false;
uni.reLaunch({
url: '/pages/menu/wallet/index'
})
}, 1000)
} else {
that.showFinger = false;
that.showBottom = true;
uni.showToast({
title: this.$t('index').Transferfailedconfirm,
icon: 'none',
duration: 1500
})
}
})
} else if (this.coin.type === 'TRX') {
this.$TronUtil.transaction(this.transaction, this.transInfoPass.privateKey, this.transInfoPass
.contractAddress)
.then((res) => {
console.log(1212121212121212)
that.showFinger = false
that.showBottom = false;
that.fingerSuccess = true;
uni.showToast({
title: this.$t('index').Transfersucceeded,
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: this.$t('index').Transferfailedconfirm,
icon: 'none',
duration: 1500
})
})
}
},
cancelAll() {
this.show = false;
this.showBottom = false;
},
cancelFail() {
this.printCancel()
this.fingerFail = false
this.showBottom = true;
this.showFinger = false;
},
cancel() {
this.showFinger = false
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 (!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();
}
},
back() {
uni.reLaunch({
url: '../../token/btc/index'
})
},
// 点击获取所有钱
forAll() {
this.transInfoPass.amount = this.coin.balance
},
// 确认提交
Confirm() {
// 做判断
if (this.transInfoPass.amount == '') {
uni.showToast({
title: this.$t('index').enterthetransferamount,
icon: 'none',
duration: 1500
})
return
}
if (this.transInfoPass.toAddress == '') {
uni.showToast({
title: this.$t('index').enterthereceivingaddress,
icon: 'none',
duration: 1500
})
return
}
if (Number(this.transInfoPass.amount) == '' < 0) {
uni.showToast({
title: this.$t('index').lessthan,
icon: 'none',
duration: 1500
})
return
}
if (Number(this.transInfoPass.amount) > this.coin.balance) {
uni.showToast({
title: this.$t('index').yourcredit,
icon: 'none',
duration: 1500
})
return
}
let that = this
if (this.coin.type === 'ETH') {
if(!this.$Token.validateEth(this.transInfoPass.toAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
this.$EthUtil.getGas().then((res) => {
console.log(res, 'ETH')
this.$EthUtil.getGas().then((res) => {
that.transInfoPass.fee = res * 61000 / Math.pow(10, 18)
that.showBottom = true;
that.show = true;
})
})
} else if (this.coin.type === 'TRX') {
if(!this.$Token.validateTrx(this.transInfoPass.toAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
this.$TronUtil.getTransaction(this.transInfoPass.fromAddress,
this.transInfoPass.toAddress, this.transInfoPass.amount, this.transInfoPass.remark, this
.transInfoPass.contractAddress)
.then((res) => {
that.transaction = res;
uni.setStorageSync('transaction', that.transaction)
console.log(JSON.stringify(that.transaction))
let size = JSON.stringify(that.transaction).replace(/[^x00-xFF]/g, '**').length;
console.log(size, "size")
console.log(size.toString().length, "size")
that.transInfoPass.fee = Number(size) * (size.toString().length + 1) * 1000 / Math.pow(10,
6)
that.showBottom = true;
that.show = true;
}).catch(err => {
console.log(err)
that.showFinger = false;
uni.showToast({
title: this.$t('index').failedInitiate,
icon: 'none',
duration: 1500
})
})
}else if(this.coin.type === 'BTC'){
if(!this.$Token.validateBtc(this.transInfoPass.toAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
}
},
scanCode() {
var _this = this
uni.scanCode({
success: function(res) {
console.log('扫码内容', res.result)
_this.transInfoPass.toAddress = res.result;
}
});
},
// 取消指纹识别
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
if (!plus.fingerprint.isSupport()) {
uni.showToast({
title: this.$t('index').fingerprintidentification,
icon: 'none',
duration: 1500
})
// this.disabled = true;
} else if (!plus.fingerprint.isKeyguardSecure()) {
uni.showToast({
title: this.$t('index').notequipped,
icon: 'none',
duration: 1500
})
} else if (!plus.fingerprint.isEnrolledFingerprints()) {
uni.showToast({
title: this.$t('index').oninthesetting,
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;
// #ifdef APP-PLUS
plus.fingerprint.authenticate(function() {
plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
that.sendTransaction()
}, function(e) {
switch (e.code) {
// 指纹识别失败后的各种情况
case e.AUTHENTICATE_MISMATCH:
plus.nativeUI.toast(that.$t('index').Fingerprintmatchingfailed);
// uni.setStorageSync('fingerPass',false)
console.log(that.showFinger, 454545)
that.showBottom = false;
that.fingerFail = true;
that.show=false;
console.log(that.fingerFail, 454545)
break;
case e.AUTHENTICATE_OVERLIMIT:
plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
plus.nativeUI.alert(that.$t('index').Thenumberoffingerprint);
// uni.setStorageSync('fingerPass',false)
console.log(that.showFinger, 454545)
that.showBottom = false;
that.fingerFail = true;
that.show=false;
console.log(that.fingerFail, 454545)
break;
case e.CANCEL:
plus.nativeUI.toast(that.$t('index').Recognitioncancelled);
// uni.setStorageSync('fingerPass',false)
console.log(that.showFinger, 454545)
that.showBottom = false;
that.fingerFail = true;
that.show=false;
console.log(that.fingerFail, 454545)
break;
default:
plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
// uni.setStorageSync('fingerPass', false)
console.log(that.showFinger, 454545)
that.showBottom = false;
that.fingerFail = true;
that.show=false;
console.log(that.fingerFail, 454545)
plus.nativeUI.alert(that.$t('index').Fingerprintidentificationfailed);
break;
}
});
// Android平台手动弹出等待提示框
if ('Android' == plus.os.name) {
this.show = true;
/* plus.nativeUI.showWaiting('指纹识别中...').onclose = function() {
plus.fingerprint.cancel();
} */
}
// #endif
}
// #endif
},
goAddress(text) {
uni.setStorageSync('transInfoPass',this.transInfoPass)
uni.setStorageSync('sourcePage', '/pages/menu/sendToken/transfer/index');
uni.navigateTo({
url: '../address/index?item=transfer'
})
}
},
onLoad(a) {
if(a.item==='address'){
this.transInfoPass=uni.getStorageSync('transInfoPass');
}else if(a.item ==='index'){
this.transInfoPass.toAddress=uni.getStorageSync('address');
}else{
uni.removeStorageSync('transInfoPass')
uni.removeStorageSync('address')
}
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')
}
let currency=uni.getStorageSync('currency');
if(currency){
this.currency=currency;
}
if(this.currency==='USD'){
if (this.coin.balancePrice&&this.coin.balancePrice>0) {
this.price = (this.coin.balancePrice / this.coin.balance).toFixed(2)
}
}else{
if (this.coin.balanceCnyPrice&&this.coin.balancePrice>0) {
this.price = (this.coin.balanceCnyPrice / this.coin.balance).toFixed(2)
}
}
}
};
</script>
<style scoped>
page {
background: #FAFAFA;
height: 100%;
}
</style>
<style>
@import './index.css';
</style>