17 .transferType input[type=radio] {
22 .transferType input[type="radio"]:checked+label{
24 background-color: #333333;
35 background-color: white;
41 background-color: #f7f7f7;
64 background: rgba(255,255,255,0.1);
74 <div class="warp-chlid bg-gray">
75 <section class="header bg-header">
76 <i class="iconfont icon-back" @click="close"></i>
77 <p>{{ $t('crossChain.title') }}</p>
80 <section class="transferType">
82 <input type="radio" id="typeChoice1"
83 value="toVapor" v-model="transaction.type">
84 <label class="choice" for="typeChoice1">{{$t('crossChain.toVapor')}}</label>
88 <input type="radio" id="typeChoice2"
89 value="toBytom" v-model="transaction.type">
90 <label class="choice" for="typeChoice2">{{$t('crossChain.toBytom')}}</label>
95 <section class="form-container">
96 <div class="form bg-white">
97 <!--<div class="form-item">-->
98 <!--<label class="form-item-label">{{ $t('crossChain.asset') }}</label>-->
99 <!--<!–<div class="form-item-content" >–>-->
100 <!--<v-select style="height: 32px;" class="v-select" v-bind:colorBlack="true" :clearable="false" :value="aOptions[0]" :options="aOptions"></v-select>-->
101 <!--<!–</div>–>-->
103 <div class="form-item">
104 <label class="form-item-label">
105 {{ $t('transfer.quantity') }}
107 <small class="float-right" style="margin-right: 8px;">{{ transaction.cost||0 }} CNY</small>
109 <div class="form-item-content" style=" display: flex;">
110 <input type="number" v-model="transaction.amount" :placeholder="bytomBalance">
111 <span class="color-grey" style="width: 40px; font-size: 15px;position: absolute;right: 0;">{{unit}}</span>
113 <p class="small color-grey">{{$t('crossChain.amountHint')}}</p>
116 <a class="btn btn-primary" @click="send">{{ $t('transfer.send') }}</a>
122 import account from "@/models/account";
123 import transaction from "@/models/transaction";
124 import getLang from "@/assets/language/sdk";
125 import Confirm from "./transferConfirm";
126 import { BTM } from "@/utils/constants";
127 import { mapActions, mapGetters, mapState } from 'vuex'
128 import * as Actions from '@/store/constants';
136 "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
149 { label: "BTM", value: ASSET_BTM },
153 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff: "BTM"
157 accountBalance: 0.00,
158 fee: this.$t("transfer.feeType"),
159 feeTypeOptions: [this.$t("transfer.feeType")],
172 return this.assets[this.transaction.asset];
174 bytomBalance: function () {
175 let balance, balances
176 if(this.transaction.type === 'toVapor'){
177 balances = this.currentAccount.balances
178 }else if(this.transaction.type === 'toBytom'){
179 balances = this.currentAccount.vpBalances
181 if(balances && balances.length >0 ){
182 const balanceObject = balances.filter(b => b.asset === BTM)[0]
183 balance = balanceObject.balance/Math.pow(10,balanceObject.decimals)
186 if(this.transaction.type === 'toVapor'){
187 return `Bytom${this.$t("crossChain.amountPlaceHolder")}${(balance != null && balance != 0) ? balance : '0.00'}`
189 return `Vapor${this.$t("crossChain.amountPlaceHolder")}${(balance != null && balance != 0) ? balance : '0.00'}`
203 selectAsset: function (val) {
204 this.transaction.asset = val.assets;
206 "transaction.amount": function (newAmount) {
207 transaction.asset(this.transaction.asset).then(ret => {
208 this.transaction.cost = Number(ret.cny_price * newAmount).toFixed(2);
211 account: function (newAccount) {
212 this.guid = newAccount.guid;
214 guid: function (newGuid) {
215 this.accountList.forEach(account => {
216 if (account.guid == newGuid.guid) {
217 this.account = account;
222 account.balance(newGuid).then(balances => {
224 if(balances.length >0 ) {
225 const balanceObject = balances.filter(b => b.asset === BTM)[0]
226 balance = balanceObject.balance / Math.pow(10, balanceObject.decimals)
228 this.accountBalance = balance;
237 this.transaction.to = "";
238 this.transaction.amount = "";
239 account.setupNet(`${this.net}${this.netType}`);
240 if(this.$route.query.type == 'popup'){
245 if (this.transaction.amount <= 0) {
247 body: this.$t("transfer.noneBTM")
252 let loader = this.$loading.show({
253 // Optional parameters
256 onCancel: this.onCancel
260 if(this.transaction.type === 'toVapor'){
261 transaction.chainStatus().then((resp)=>{
262 const address = resp.federation_address
263 account.setupNet(`${this.net}bytom`)
264 this.transaction.to = address
265 transaction.build(this.account.guid, address, this.transaction.asset, this.transaction.amount*100000000, this.transaction.confirmations).then(result => {
267 this.transaction.fee = Number(result.fee / 100000000);
268 this.$router.push({ name: 'transfer-confirm', params: { account: this.account, transaction: this.transaction, rawData: result, type: this.$route.query.type } })
272 body: getLang(error.message)
280 const address = this.account.address
281 account.setupNet(`${this.net}vapor`)
282 this.transaction.to = address
283 transaction.buildCrossChain(this.account.guid, address, this.transaction.asset, this.transaction.amount*100000000, this.transaction.confirmations).then(result => {
285 this.transaction.fee = Number(result.fee / 100000000);
286 this.$router.push({ name: 'transfer-confirm', params: { account: this.account, transaction: this.transaction, rawData: result, type: this.$route.query.type } })
290 body: getLang(error.message)
298 if(this.$route.query.type === 'popup'){
299 if (this.$route.query.from != undefined) {
300 this.guid = this.$route.query.from
301 this.account = this.accountList.filter(e => e.guid === this.guid)[0]
304 if (this.$route.query.asset != undefined) {
305 this.transaction.asset= this.$route.query.asset
307 if (this.$route.query.to != undefined) {
308 this.transaction.to = this.$route.query.to
310 if (this.$route.query.amount != undefined) {
311 this.transaction.amount = this.$route.query.amount /100000000
313 if (this.$route.query.gas != undefined) {
314 this.transaction.fee = this.$route.query.gas /100000000
316 if(this.$route.query.confirmations != undefined) {
317 this.transaction.confirmations = this.$route.query.confirmations
320 this.account = this.currentAccount