OSDN Git Service

update underscore to camelcase
[bytom/Byone.git] / src / views / sendTransaction / advancedTransfer.vue
index 78f1bfc..b02018c 100644 (file)
 
           <div class="divider"></div>
 
+          <tr v-for="(amountInput, index) in transaction.amounts" :key="index" class="row">
+            <td class="col label">{{index ==0 && $t('transfer.transferAmount') }}</td>
+            <td class="col value">{{amountInput.amount}}<span class="uint uppercase">{{amountInput.alias || amountInput.asset}}</span></td>
+          </tr>
+
           <tr class="row">
             <td class="col label">{{ $t('transfer.fee') }}</td>
             <td class="col value">{{transaction.fee}}<span class="uint">BTM</span></td>
           </tr>
+
         </tbody>
       </table>
     </section>
@@ -140,13 +146,16 @@ import { LocalStream } from 'extension-streams';
 import {apis} from '@/utils/BrowserApis';
 import NotificationService from '../../services/NotificationService'
 import { mapActions, mapGetters, mapState } from 'vuex'
+import _ from 'lodash';
+import account from "@/models/account";
+import { Number as Num } from "@/utils/Number"
+
+
 
 export default {
     data() {
         return {
             full: false,
-            // full2: false,
-            // account: {},
             transaction: {
                 input: "",
                 output: "",
@@ -162,6 +171,8 @@ export default {
     computed: {
       ...mapGetters([
         'currentAccount',
+        'net',
+        'netType',
       ])
     },
     watch: {
@@ -178,7 +189,7 @@ export default {
                 onCancel: this.onCancel
             });
 
-            transaction.buildTransaction(this.currentAccount.guid,  this.transaction.input, this.transaction.output, this.transaction.fee * 100000000, this.transaction.confirmations).then(async (result) => {
+            transaction.buildTransaction(this.currentAccount.guid,  this.transaction.input, this.transaction.output, this.transaction.fee , this.transaction.confirmations).then(async (result) => {
 
               let arrayData
               if(this.transaction.args){
@@ -205,7 +216,10 @@ export default {
                     body: getLang(error.message)
                 });
             });
-        }
+        },
+      queryAsset: function(assetID){
+        return transaction.asset(assetID)
+      }
     }, mounted() {
           this.prompt = window.data || apis.extension.getBackgroundPage().notification || null;
 
@@ -221,14 +235,37 @@ export default {
                  this.transaction.args = inout.args
               }
               if(inout.gas !== undefined){
-                 this.transaction.fee = inout.gas/100000000
+                 this.transaction.fee = inout.gas
               }
               if(inout.confirmations !== undefined){
                  this.transaction.confirmations = inout.confirmations
               }
 
               const array = inout.input.filter(action => action.type ==='spend_wallet')
-              this.transaction.amounts = array
+
+              if(array.length>0){
+                account.setupNet(`${this.net}${this.netType}`)
+              const promise =
+                _(array)
+                  .groupBy('asset')
+                  .map((objs, key) => {
+                    return this.queryAsset(key).then(resp =>{
+                      return {
+                        'asset': key,
+                        'alias':resp.alias,
+                        'amount':Num.formatNue( _.sumBy(objs, 'amount'), resp.decimals)
+                      }
+                    })
+                  })
+
+                let that = this;
+                Promise.all(promise).then(function(output) {
+                  that.transaction.amounts = output
+                })
+
+              }
+
+
           }
       }
 };