OSDN Git Service

update vote confirm page.
authorZhiting Lin <zlin035@uottawa.ca>
Wed, 11 Sep 2019 01:44:17 +0000 (09:44 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Wed, 11 Sep 2019 01:44:17 +0000 (09:44 +0800)
src/assets/language/cn.js
src/assets/language/en.js
src/router.js
src/views/sendTransaction/advancedTransfer.vue
src/views/vote/veto.vue
src/views/vote/vote.vue
src/views/vote/voteConfirm.vue [new file with mode: 0644]

index d247236..7b15cc0 100644 (file)
@@ -66,8 +66,10 @@ const cn = {
     bp:'正式共识节点',
     standbyBP:'备选共识节点',
     bpName:'节点名称',
+    bpPubkey:'节点公钥',
     vote:'投票',
-    votes:'票数'
+    votes:'票数',
+    voteAccount:'投票账户'
   },
   listCancel:{
     voted:'已投票',
index 71c9a9b..8142558 100644 (file)
@@ -66,8 +66,10 @@ const en = {
     bp:'BP',
     standbyBP:'Standby BP',
     bpName:'BP name',
+    bpPubkey:'BP Public Key',
     vote:'Vote',
-    votes:'Votes'
+    votes:'Votes',
+    voteAccount:'Vote Account'
   },
   listCancel:{
     voted:'Voted',
index 9bdb04c..51506bd 100644 (file)
@@ -74,6 +74,14 @@ const routers = [
         }
       },
       {
+        path: '/vote/confirm',
+        name: 'vote-confirm',
+        meta: { title: '投票确认' },
+        component: resolve => {
+          require(['@/views/vote/voteConfirm.vue'], resolve)
+        }
+      },
+      {
         path: '/crossChain',
         name: 'cross-chain',
         meta: { title: '跨链' },
index cf25e0f..bf0e82e 100644 (file)
             <td class="col label">{{ $t('transfer.fee') }}</td>
             <td class="col value">{{transaction.fee}}<span class="uint">BTM</span></td>
           </tr>
-          
+
         </tbody>
       </table>
     </section>
index 71cacd9..d40f0a4 100644 (file)
@@ -187,7 +187,7 @@ export default {
             transaction.buildVeto(this.currentAccount.guid, vote,  Num.convertToNue(this.transaction.amount,8), this.transaction.confirmations).then(result => {
                 loader.hide();
                 this.transaction.fee = Number(result.fee / 100000000);
-                this.$router.push({ name: 'transfer-confirm', params: { account: this.currentAccount, transaction: this.transaction, assetAlias: 'BTM',rawData: result} })
+                this.$router.push({ name: 'vote-confirm', params: { account: this.currentAccount, transaction: this.transaction, assetAlias: 'BTM',rawData: result} })
             }).catch(error => {
                 loader.hide();
                 this.$dialog.show({
index aaa059f..9d374fb 100644 (file)
@@ -76,7 +76,6 @@
                   <label class="form-item-label">
                     {{ $t('transfer.quantity') }}
 
-                    <small class="float-right" style="margin-right: 8px;">{{ formatCurrency(transaction.cost||0) }}</small>
                   </label>
                   <div class="form-item-content" style=" display: flex;">
                       <input type="number" v-model="transaction.amount" :placeholder="bytomBalance">
@@ -187,7 +186,7 @@ export default {
             transaction.buildVote(this.currentAccount.guid, vote,  Num.convertToNue(this.transaction.amount,8), this.transaction.confirmations).then(result => {
                 loader.hide();
                 this.transaction.fee = Number(result.fee / 100000000);
-                this.$router.push({ name: 'transfer-confirm', params: { account: this.currentAccount,  transaction: this.transaction,assetAlias: 'BTM', rawData: result} })
+                this.$router.push({ name: 'vote-confirm', params: { account: this.currentAccount,  transaction: this.transaction,assetAlias: 'BTM', rawData: result} })
             }).catch(error => {
                 loader.hide();
                 this.$dialog.show({
diff --git a/src/views/vote/voteConfirm.vue b/src/views/vote/voteConfirm.vue
new file mode 100644 (file)
index 0000000..f051dcd
--- /dev/null
@@ -0,0 +1,277 @@
+<style lang="" scoped>
+.warp {
+    position: absolute;
+    top: 0;
+    left: 0;
+    right: 0;
+    height: 600px;
+    z-index: 2;
+}
+.header {
+  display: flex;
+}
+.header p{
+  text-align: center;
+  width: 270px;
+  padding-top: 17px;
+}
+
+.content {
+    margin: 20px;
+    padding: 20px;
+    overflow: hidden;
+    border-radius:4px;
+    width: 280px;
+}
+
+.ft {
+    border-radius: 5px;
+    padding: 0 20px !important;
+    line-height: 45px;
+    margin-bottom: 20px;
+}
+
+.ft .from {
+    overflow-x: hidden;
+    width: 90px;
+}
+.ft .to {
+    overflow-x: hidden;
+    padding-left: 20px;
+    float: right;
+}
+
+.right-arrow {
+    width: 32px;
+    height: 32px;
+    border-top: 12px solid #3c454b;
+    border-right: 12px solid #3c454b;
+    transform: rotate(45deg);
+    position: absolute;
+    left: 105px;
+}
+
+.divider {
+    margin: 15px 0;
+}
+
+.value .uint {
+    font-size: 12px;
+    margin-left: 3px;
+    text-transform: uppercase;
+}
+
+.fee-intro {
+    font-size: 10px;
+}
+
+.btn-inline {
+    display: flex;
+    padding: 0;
+}
+.btn-inline .btn {
+    margin: 10px 15px;
+}
+.row{
+  word-break: break-all;
+}
+  .col{
+    font-size: 14px;
+    width: 35%;
+  }
+  .label{
+    color: #7B7B7B;
+  }
+  .value{
+    color: #282828;
+    width: 60%;
+  }
+  .asset{
+    text-transform: uppercase;
+  }
+  table{
+    width: 100%;
+  }
+  .form-item{
+    padding:0;
+    margin:0;
+    margin-bottom: 10px;
+  }
+  .scorll-panel{
+    overflow: scroll;
+    height: 545px;
+  }
+.view-link{
+  font-size: 14px;
+  color: #035BD4;
+}
+</style>
+
+<template>
+    <div class="warp bg-gray">
+        <section class="header bg-header">
+            <i class="iconfont icon-back" @click="$router.go(-1)"></i>
+            <p>{{ title || $t('transfer.confirmTransaction') }}</p>
+        </section>
+
+        <div class="scorll-panel">
+            <section class="content bg-white">
+                <table>
+                    <tbody>
+                        <tr class="row">
+                            <td class="col label">{{ $t('listVote.voteAccount') }}</td>
+                            <td class="col value">{{account.alias}}</td>
+                        </tr>
+                        <tr v-if="selectVote.name" class="row">
+                            <td class="col label">{{ $t('listVote.bpName')}}</td>
+                            <td class="col value">{{selectVote.name}}</td>
+                        </tr>
+                        <tr v-else class="row">
+                            <td class="col label">{{ $t('listVote.bpPubkey')}}</td>
+                            <td class="col value">{{transaction.toShort}}</td>
+                        </tr>
+                        <div class="divider"></div>
+                        <tr class="row">
+                            <td class="col label">{{ $t('listVote.votes') }}</td>
+                            <td class="col value">{{transaction.amount}}<span v-if="assetAlias" class="uint">{{assetAlias}}</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>
+
+            <section class="content bg-white">
+              <div class="form">
+                <div class="form-item">
+                  <label class="form-item-label">{{ $t('transfer.confirmPassword') }}</label>
+                  <div class="form-item-content">
+                    <input type="password"  v-model="password" autofocus>
+                  </div>
+                </div>
+              </div>
+            </section>
+
+            <div class="row" style="margin: 20px;">
+                <div class="btn bg-green" @click="transfer">{{ $t('transfer.confirm') }}</div>
+            </div>
+        </div>
+
+    </div>
+
+</template>
+
+<script>
+  import address from "@/utils/address";
+  import transaction from "@/models/transaction";
+  import BigNumber from "bignumber.js"
+  import account from "@/models/account";
+import modalPasswd from "@/components/modal-passwd";
+import getLang from "@/assets/language/sdk";
+import { LocalStream } from 'extension-streams';
+import { mapGetters,mapState } from 'vuex'
+
+export default {
+    components: {
+        modalPasswd
+    },
+    data() {
+        return {
+          full: false,
+          title:null,
+          rawData: {},
+            account: {},
+            transaction: {
+                to: "",
+                toShort: "",
+                amount: 0,
+                fee: ""
+            },
+            password:'',
+            assetAlias:null
+        };
+    },
+    watch: {
+      '$route'(to, from) {
+        console.log(from)
+        console.log(to)
+        if (from.name == 'vote') {
+          this.title = 'vote'
+        }else if(from.name =='veto'){
+          this.title = 'veto'
+        }
+      },
+    },
+    computed: {
+      totalAmount(){
+        if(this.assetAlias && this.assetAlias.toUpperCase() === 'BTM'){
+          const n = new BigNumber(this.transaction.amount)
+          return n.plus(this.transaction.fee).toNumber()
+        }else{
+          return Number(this.transaction.amount)
+        }
+      },
+      ...mapState([
+        'selectVote'
+      ]),
+      ...mapGetters([
+        'language',
+        'net'
+      ])
+    },
+    methods: {
+        shortAddress: function (add) {
+          return address.short(add)
+        },
+        transfer: function () {
+            if (this.password == "") {
+              this.$dialog.show({
+                body: this.$t("transfer.emptyPassword")
+              });
+              return;
+            }
+            let loader = this.$loading.show({
+                // Optional parameters
+                container: null,
+                canCancel: true,
+                onCancel: this.onCancel
+            });
+
+            // rawData, password
+            transaction.transfer(this.account.guid, this.rawData, this.password)
+                .then(ret => {
+                    loader.hide();
+                    if(this.$route.params.type == 'popup'){
+                      LocalStream.send({method:'transfer',action:'success', message:ret});
+                      window.close();
+                    }
+                    this.$dialog.show({
+                      type: 'success',
+                      body: this.$t("transfer.success")
+                    });
+                    this.$router.push('/')
+                    if(this.transaction.type === 'toVapor'){
+                      account.setupNet(`${this.net}vapor`)
+                    }
+                })
+                .catch(error => {
+                    loader.hide();
+                    this.$dialog.show({
+                        body: getLang(error.message, this.language)
+                    });
+                });
+        }
+    }, mounted() {
+        let params = this.$route.params;
+
+        this.account = params.account;
+        this.transaction = params.transaction;
+        this.transaction.toShort = params.transaction.to;
+        this.rawData = params.rawData;
+
+        this.assetAlias = params.assetAlias;
+    }
+};
+</script>