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.
 
 
 
 

570 lines
14 KiB

<template>
<view class="hr">
<navigation :showBack="true" :bgnum="true">
<text class="big_title">
{{i18n.Addaddress}}
</text>
</navigation>
<view class="main">
<view class="main_con">
<view class="item">
<view class="top flex">
<view class="text1">
{{i18n.curr}}
</view>
</view>
<view class="inputcon">
<input type="text" value="" v-model="value"
placeholder-style="font-size: 30rpx; color: #D0D0D2;" :placeholder="teee1" class="input1"
@click="showSelect()" :disabled="true" />
<image src="../../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="img1">
</image>
</view>
</view>
<view class="item">
<view class="top flex">
<view class="text1">
{{i18n.Address}}
</view>
</view>
<view class="inputcon">
<input type="text" value="" @input="showSave()"
placeholder-style="font-size: 30rpx; color: #D0D0D2;" :placeholder="teee2" class="input1"
v-model="bigAddress" />
<image src="../../../../static/tongyonh/Frame330.png" mode="aspectFit" class="img2"
@click="chooseImage"></image>
</view>
</view>
<view class="item">
<view class="top flex">
<view class="text1">
{{i18n.Name}}
</view>
</view>
<view class="inputcon">
<input type="text" @input="showSave" value=""
placeholder-style="font-size: 30rpx; color: #D0D0D2;" :placeholder="teee3" class="input1"
v-model="addressName" />
</view>
</view>
<view class="btn" @click="handove()" :class="save?'sheng':''">
{{i18n.Save}}
</view>
</view>
<u-mask z-index="10" :show="show" @click="show = false"></u-mask>
</view>
<view class="big_con w100" v-if="show">
<view class="tiao" @click="show=false"></view>
<view class="title">
{{i18n.selectcurrency}}
</view>
<view class="bottom_con zindex" v-if="show">
<u-radio-group v-model="value">
<view class="item flex" v-for="(item, index) in list" :key="index" @click="handove2(item)">
<view class="text1 flex">
<image :src="item.url" mode="aspectFit" class="img"></image>
<view class="textcon">
<view class="text1">
{{item.lang}}
</view>
<view class="text2">
{{item.name}}
</view>
</view>
</view>
<u-radio :name="item.name" :disabled="item.disabled" active-color="#5B53FF">
</u-radio>
</view>
</u-radio-group>
<view class="select_btn">
{{i18n.langSelect}}
</view>
</view>
</view>
</view>
</template>
<script>
import cont from "@/components/navigation/navigation.vue"
export default {
data() {
return {
AddressInfo: {},
teee1: this.$t('index').selectcurrency,
teee2: this.$t('index').Pleaserecipientaddress,
teee3: this.$t('index').enterthename,
info: {},
addressName: '',
value: '',
bigAddress: '',
save: true,
AddressIndex: -1,
gai: [],
show: false,
checked: false,
list: [{
url: '../../../../static/tongyonh/bye.png',
lang: 'Bitcoin',
disabled: false,
name: "BTC"
},
{
url: '../../../../static/tongyonh/Frame3299.png',
lang: 'Ethereum',
disabled: false,
name: "ETH"
},
{
url: '../../../../static/tongyonh/tron1.png',
lang: 'Tron',
disabled: false,
name: "TRX"
},
],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
value: '',
}
},
onLoad() {
if (uni.getStorageSync('AddressInfo')) {
this.info = uni.getStorageSync('AddressInfo')
this.AddressInfo = uni.getStorageSync('AddressInfo')
this.addressName = this.AddressInfo.name
this.bigAddress = this.AddressInfo.address,
this.value = uni.getStorageSync('AddressName')
this.AddressIndex = uni.getStorageSync('AddressIndex')
}
},
computed: {
i18n() {
return this.$t('index')
},
},
methods: {
// 唤醒摄像头
chooseImage() {
var _this = this
uni.scanCode({
success: function(res) {
console.log('扫码内容', res.result)
_this.bigAddress = res.result;
}
});
// ass()
},
handove2(item) {
this.value = item.name;
this.show = false;
},
showSave() {
if (this.bigAddress != '' && this.name != '' && this.value != '') {
this.save = true;
} else {
this.save = false;
}
},
handove(item) {
if (this.value == '') {
this.save = false
uni.showToast({
title: this.$t('index').selectcurrency,
icon: 'none',
duration: 1500
})
return;
}
if (this.bigAddress == '' || this.addressName == '') {
this.save = false
uni.showToast({
title: this.$t('index').Addressorname,
icon: 'none',
duration: 1500
})
return;
}
if (this.info.coinList[0].name2 == 'TRX') {
this.$walletUtil.updateAddress(this.info.coinList[0].name2, this.value);
if (this.value == 'ETH') {
if(!this.$Token.validateEth(this.bigAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
this.gai = uni.getStorageSync('ETHAddressInfo')
this.gai2 = uni.getStorageSync('TRXAddressInfo')
var index = uni.getStorageSync('editIndex')
let eth = new Object;
eth.address = this.bigAddress;
eth.name = this.addressName
eth.coinList = [{
name: "ETH",
name2: "ETH",
xname: 'Ethereum',
icon: require('@/static/tongyonh/Frame3299.png')
}];
this.gai2.splice(index, 1)
uni.setStorageSync('TRXAddressInfo', this.gai2)
if(this.gai==''){
this.gai=[];
this.gai[0]=eth
}else{
this.gai.push(eth);
}
uni.setStorageSync('ETHAddressInfo', this.gai)
uni.showToast({
title: this.$t('index').Successful,
icon: 'success',
duration: 1500
})
uni.navigateTo({
url: '../address/index'
})
}
if (this.value == 'TRX') {
this.gai = uni.getStorageSync('TRXAddressInfo')
var index = uni.getStorageSync('editIndex')
let trx = new Object;
trx.address = this.bigAddress;
trx.name = this.addressName
trx.coinList = [{
name: "TRX",
name2: "TRX",
xname: 'TRON',
icon: require('@/static/tongyonh/tron1.png')
}];
this.gai[index] = trx;
uni.setStorageSync('TRXAddressInfo', this.gai)
uni.showToast({
title: this.$t('index').Successful,
icon: 'success',
duration: 1500
})
uni.navigateTo({
url: '../address/index'
})
}
if (this.value == 'BTC') {
if(uni.getStorageSync('BTCAddressInfo')){
this.gai = uni.getStorageSync('BTCAddressInfo')
}
this.gai2 = uni.getStorageSync('TRXAddressInfo')
var index = uni.getStorageSync('editIndex')
let btc = new Object;
btc.address = this.bigAddress;
btc.name = this.addressName
btc.coinList = [{
name: "BTC",
name2: "BTC",
xname: 'Bitcoin',
icon: require('@/static/tongyonh/bye.png')
}];
this.gai2.splice(index, 1)
uni.setStorageSync('TRXAddressInfo', this.gai2)
if(this.gai==''){
this.gai=[];
this.gai[0]=btc
}else{
this.gai.push(btc);
}
uni.setStorageSync('BTCAddressInfo', this.gai)
uni.showToast({
title: this.$t('index').Successful,
icon: 'success',
duration: 1500
})
uni.navigateTo({
url: '../address/index'
})
}
}
if (this.info.coinList[0].name2 == 'ETH') {
if (this.value == 'TRX') {
if(!this.$Token.validateTrx(this.bigAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
this.gai = uni.getStorageSync('TRXAddressInfo')
this.gai2 = uni.getStorageSync('ETHAddressInfo')
var index = uni.getStorageSync('editIndex')
let trx = new Object;
trx.address = this.bigAddress;
trx.name = this.addressName
trx.coinList = [{
name: "TRX",
name2: "TRX",
xname: 'TRON',
icon: require('@/static/tongyonh/tron1.png')
}];
this.gai2.splice(index, 1)
uni.setStorageSync('ETHAddressInfo', this.gai2)
if(this.gai==''){
this.gai=[];
this.gai[0]=trx
}else{
this.gai.push(trx);
}
uni.setStorageSync('TRXAddressInfo', this.gai)
uni.showToast({
title: this.$t('index').Successful,
icon: 'success',
duration: 1500
})
uni.navigateTo({
url: '../address/index'
})
}
if (this.value == 'ETH') {
if(!this.$Token.validateEth(this.bigAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
this.gai = uni.getStorageSync('ETHAddressInfo')
var index = uni.getStorageSync('editIndex')
let eth = new Object;
eth.address = this.bigAddress;
eth.name = this.addressName
eth.coinList = [{
name: "ETH",
name2: "ETH",
xname: 'Ethereum',
icon: require('@/static/tongyonh/Frame3299.png')
}];
this.gai[index] = eth;
uni.setStorageSync('ETHAddressInfo', this.gai)
uni.showToast({
title: this.$t('index').Successful,
icon: 'success',
duration: 1500
})
uni.navigateTo({
url: '../address/index'
})
}
if (this.value == 'BTC') {
if(!this.$Token.validateBtc(this.bigAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
this.gai = uni.getStorageSync('BTCAddressInfo')
this.gai2 = uni.getStorageSync('ETHAddressInfo')
var index = uni.getStorageSync('editIndex')
let btc = new Object;
btc.address = this.bigAddress;
btc.name = this.addressName
btc.coinList = [{
name: "BTC",
name2: "BTC",
xname: 'Bitcoin',
icon: require('@/static/tongyonh/bye.png')
}];
this.gai2.splice(index, 1)
uni.setStorageSync('ETHAddressInfo', this.gai2)
if(this.gai==''){
this.gai=[];
this.gai[0]=btc
}else{
this.gai.push(btc);
}
uni.setStorageSync('BTCAddressInfo', this.gai)
uni.showToast({
title: this.$t('index').Successful,
icon: 'success',
duration: 1500
})
uni.navigateTo({
url: '../address/index'
})
}
}
if (this.info.coinList[0].name2 == 'BTC') {
if (this.value == 'TRX') {
if(!this.$Token.validateTrx(this.bigAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
this.gai = uni.getStorageSync('TRXAddressInfo')
this.gai2 = uni.getStorageSync('BTCAddressInfo')
var index = uni.getStorageSync('editIndex')
let trx = new Object;
trx.address = this.bigAddress;
trx.name = this.addressName
trx.coinList = [{
name: "TRX",
name2: "TRX",
xname: 'TRON',
icon: require('@/static/tongyonh/tron1.png')
}];
this.gai2.splice(index, 1)
uni.setStorageSync('BTCAddressInfo', this.gai2)
// 11月23日 改 假设一开始就要改地址币种 该币种还没有数组
if(this.gai==''){
this.gai=[];
console.log(this.gai,454545)
this.gai[0]=trx
}else{
this.gai.push(trx);
}
uni.setStorageSync('TRXAddressInfo', this.gai)
uni.showToast({
title: this.$t('index').Successful,
icon: 'success',
duration: 1500
})
uni.navigateTo({
url: '../address/index'
})
}
if (this.value == 'BTC') {
if(!this.$Token.validateBtc(this.bigAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
this.gai = uni.getStorageSync('BTCAddressInfo')
var index = uni.getStorageSync('editIndex')
let btc = new Object;
btc.address = this.bigAddress;
btc.name = this.addressName
btc.coinList = [{
name: "BTC",
name2: "BTC",
xname: 'Bitcoin',
icon: require('@/static/tongyonh/bye.png')
}];
this.gai[index] = btc;
uni.setStorageSync('BTCAddressInfo', this.gai)
uni.showToast({
title: this.$t('index').Successful,
icon: 'success',
duration: 1500
})
uni.navigateTo({
url: '../address/index'
})
}
if (this.value == 'ETH') {
if(!this.$Token.validateEth(this.bigAddress))
{
uni.showToast({
title: this.$t('index').addressFormatError,
icon: 'none',
duration: 1500
})
return
}
this.gai = uni.getStorageSync('ETHAddressInfo')
this.gai2 = uni.getStorageSync('BTCAddressInfo')
var index = uni.getStorageSync('editIndex')
let eth = new Object;
eth.address = this.bigAddress;
eth.name = this.addressName
eth.coinList = [{
name: "ETH",
name2: "ETH",
xname: 'Ethereum',
icon: require('@/static/tongyonh/Frame3299.png')
}];
this.gai2.splice(index, 1)
uni.setStorageSync('BTCAddressInfo', this.gai2)
if(this.gai==''){
this.gai=[];
this.gai[0]=eth
}else{
this.gai.push(eth);
}
uni.setStorageSync('ETHAddressInfo', this.gai)
uni.showToast({
title: this.$t('index').Successful,
icon: 'success',
duration: 1500
})
uni.navigateTo({
url: '../address/index'
})
}
}
},
showSelect() {
this.show = true;
},
}
};
</script>
<style scoped>
page {
background: #FAFAFA;
height: 100%;
}
</style>
<style>
@import './index.css';
</style>