From 9b56247acf2df8ccd6be4c3ac9412ab4cde0c6be Mon Sep 17 00:00:00 2001
From: qiushaoxi <qiushaoxi@163.com>
Date: Wed, 31 Jul 2019 11:23:23 +0800
Subject: [PATCH] see sharedWallet stake info

---
 src/common/lang/en.js                         |  1 +
 src/common/lang/zh.js                         |  1 +
 .../Node/NodeAuthorize/StakeHistory.vue       | 34 ++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/common/lang/en.js b/src/common/lang/en.js
index 381ebfe..887b86a 100644
--- a/src/common/lang/en.js
+++ b/src/common/lang/en.js
@@ -86,6 +86,7 @@ export default {
     ontid: 'ONT ID',
     selectWallet: 'Select Wallet to pay for the transaction fee',
     commonWallet: 'Individual Wallet',
+    sharedWallet: 'Shared Wallet',
     ledgerWallet: 'Ledger Wallet',
     payerPassword: 'Input the password of your selected wallet',
     selectCommonWallet: 'Select local individual wallet',
diff --git a/src/common/lang/zh.js b/src/common/lang/zh.js
index d54ba12..d1ded9f 100644
--- a/src/common/lang/zh.js
+++ b/src/common/lang/zh.js
@@ -86,6 +86,7 @@ export default {
     ontid: 'ONT ID',
     selectWallet: '请选择钱包来支付交易费用',
     commonWallet: '普通钱包',
+    sharedWallet: '共享钱包',
     ledgerWallet: 'Ledger钱包',
     payerPassword: '输入所选钱包的密码',
     selectCommonWallet: '选择本地普通钱包',
diff --git a/src/renderer/components/Node/NodeAuthorize/StakeHistory.vue b/src/renderer/components/Node/NodeAuthorize/StakeHistory.vue
index 7916cef..79b8c03 100644
--- a/src/renderer/components/Node/NodeAuthorize/StakeHistory.vue
+++ b/src/renderer/components/Node/NodeAuthorize/StakeHistory.vue
@@ -35,6 +35,7 @@
                 <p class="font-medium-black">{{$t('nodeStake.selectStakeWallet')}}</p>
                 <a-radio-group @change="changePayerWallet" v-model="payerWalletType" class="change-payer-radio">
                 <a-radio value="commonWallet" class="payer-radio-item">{{$t('createIdentity.commonWallet')}}</a-radio>
+                <a-radio value="sharedWallet" class="payer-radio-item">{{$t('createIdentity.sharedWallet')}}</a-radio>
                 <a-radio value="ledgerWallet" class="payer-radio-item">{{$t('createIdentity.ledgerWallet')}}</a-radio>
 
                 <div v-if="payerWalletType === 'commonWallet'">
@@ -44,6 +45,13 @@
                     </a-select>
                 </div>
 
+                <div v-if="payerWalletType === 'sharedWallet'">
+                    <a-select :options="sharedWallet" class="select-wallet" v-model="payerWalletValue"
+                    :placeholder="$t('createIdentity.sharedWallet')"
+                        @change="handleChangePayer">
+                    </a-select>
+                </div>
+
                 <div v-if="payerWalletType === 'ledgerWallet'">
 
                     <div class="payer-ledger-status">
@@ -165,6 +173,17 @@ export default {
                 });
             }
         },
+        sharedWallet: {
+            get() {
+                const list = this.$store.state.Wallets.SharedWallet.slice();
+                return list.map(i => {
+                    return Object.assign({}, i, {
+                        label: i.sharedWalletName + " " + i.sharedWalletAddress,
+                        value: i.sharedWalletAddress
+                    });
+                });
+            }
+        },
     },
     methods: {
         handleRouteBack() {
@@ -185,19 +204,32 @@ export default {
         },
         handleChangePayer(value) {
             this.payerWallet = this.normalWallet.find((v)=>{return v.address === value})
-            this.payerWalletValue = this.payerWallet.address
+            if(this.payerWallet){
+                this.payerWalletValue = this.payerWallet.address
+            } else {
+                // SharedWallet
+                this.payerWallet = this.sharedWallet.find((v)=>{return v.sharedWalletAddress === value})
+                this.payerWalletValue = this.payerWallet.sharedWalletAddress
+                this.payerWallet.address = this.payerWallet.sharedWalletAddress
+            }
         },
         handleSearch() {
             if(this.payerWalletType === 'commonWallet' && !this.payerWallet) {
                 this.$message.error(this.$t('nodeStake.selectIndividualWallet'))
                 return;
             }
+            if(this.payerWalletType === 'sharedWallet' && !this.payerWallet) {
+                this.$message.error(this.$t('nodeStake.selectIndividualWallet'))
+                return;
+            }
             if(this.payerWalletType === 'ledgerWallet' && !this.ledgerWallet.address) {
                 this.$message.error(this.$t('nodeStake.selectLedgerWallet'))
                 return;
             }
             if(this.payerWalletType === 'commonWallet' && this.payerWallet){
                 this.stakeWallet = this.payerWallet
+            } else if (this.payerWalletType === 'sharedWallet' && this.payerWallet){
+                this.stakeWallet = this.payerWallet
             } else {
                 this.stakeWallet = this.ledgerWallet
             }