Explorar el Código

优化钱包详情

wkw hace 3 semanas
padre
commit
b70e430522

+ 1 - 0
src/stores/modules/systemStore.js

@@ -9,6 +9,7 @@ export const useSystemStore = defineStore("useSystemStore", {
     user_login_information: "",
     token: getLocalStorage("token") || "",
     stsClientInfo: {},
+    Administrator:{}
   }),
   persist: ["stsClientInfo"],
   getters: {

+ 55 - 24
src/stores/modules/walletStore.js

@@ -5,14 +5,13 @@ import { cloneDeep, forEach } from "lodash";
 import { sysLogin } from "@/common/login.js";
 import { showNotify } from 'vant';
 import router from '@/router/index'
-
-
+import { hotTokens } from '@/api/path/login.api'
 export const useWalletStore = defineStore("useWalletStore", {
   state: () => ({
     id: "", // name + @ + account
     isAuthenticated: false, // 登录状态
     account: null, // 钱包地址 
-    
+    tokenList: [],//代币数组
     privateKey: null, // 私钥
     encryptedKey: localStorage.getItem("encryptedKey") || null, // 加密后的密钥
     loading: false, // 加载状态
@@ -38,7 +37,7 @@ export const useWalletStore = defineStore("useWalletStore", {
       return this.walletList;
     },
   },
-  actions: { 
+  actions: {
     async initWeb3() {
       try {
         window.$web3 = new Web3(this.rpcUrl);
@@ -49,15 +48,15 @@ export const useWalletStore = defineStore("useWalletStore", {
         return null;
       }
     },
- 
+
     async getBalance() {
       if (!this.account || !window.$web3) {
         await this.initWeb3()
       }
       try {
         const weiBalance = await window.$web3.eth.getBalance(this.account);
-        this.balance  = await window.$web3.utils.fromWei(weiBalance, "ether");
-        return  this.balance;
+        this.balance = await window.$web3.utils.fromWei(weiBalance, "ether");
+        return this.balance;
       } catch (err) {
         this.error = "获取余额失败";
         return "0";
@@ -78,11 +77,11 @@ export const useWalletStore = defineStore("useWalletStore", {
           }
           // 从助记词派生私钥 (使用HD钱包)
           const hdwallet = web3.eth.accounts.wallet.create(1, this.words);
-          this.privateKey = hdwallet[0].privateKey; 
+          this.privateKey = hdwallet[0].privateKey;
         }
         if (!/^0x[0-9a-fA-F]{64}$/.test(this.privateKey)) {
           throw new Error("私钥格式不正确");
-        } 
+        }
         // 创建账户对象
         const account = await web3.eth.accounts.privateKeyToAccount(this.privateKey);
         // 验证是否为合约地址
@@ -91,7 +90,7 @@ export const useWalletStore = defineStore("useWalletStore", {
 
         this.account = account.address;
         this.isAuthenticated = true;
-        this.chainId =  `${await web3.eth.getChainId()}n`;
+        this.chainId = `${await web3.eth.getChainId()}n`;
         this.id = `${this.account}@${this.accountName}`
         this.addWallet()
         await sysLogin(this.account)
@@ -104,25 +103,28 @@ export const useWalletStore = defineStore("useWalletStore", {
         console.log("登录失败");
         this.error = err.message || "登录失败";
         throw err;
-      }finally {
+      } finally {
         this.$persist();
         this.loading = false;
       }
     },
 
     // 添加钱包
-    addWallet() { 
+    addWallet() {
+
       const data = cloneDeep(this.$state)
       Reflect.deleteProperty(data, "walletList");
-      if(this.walletList.length == 0) {
+      if (this.walletList.length == 0) {
         this.walletList.push(data)
-        return 
-      } 
-      const findIndex = this.walletList.findIndex(item =>  item.id === this.id);
-      if(findIndex != -1){
+        this.addTokenList()
+        return
+      }
+      const findIndex = this.walletList.findIndex(item => item.id === this.id);
+      if (findIndex != -1) {
         this.walletList[findIndex] = data
-      }else{
+      } else {
         this.walletList.push(data)
+        this.addTokenList()
       }
     },
     // 删除钱包
@@ -155,7 +157,7 @@ export const useWalletStore = defineStore("useWalletStore", {
           }
           this.isAuthenticated = false;
           this.id = '';
-     
+
           router.push({
             path: '/login'
           })
@@ -164,9 +166,9 @@ export const useWalletStore = defineStore("useWalletStore", {
       this.$persist();
     },
     // 切换钱包
-    switchWallet(id) { 
-      const item = this.walletList.find(item =>  item.id === id);
-      if(!item){
+    switchWallet(id) {
+      const item = this.walletList.find(item => item.id === id);
+      if (!item) {
         $msg($t("global.WalletDoesNotExist"))
       }
       forEach(this.$state, (_, key) => {
@@ -177,14 +179,43 @@ export const useWalletStore = defineStore("useWalletStore", {
       this.$persist()
     },
     // 修改钱包名称
-    updateWalletName(id,newName){
-      if (id == this.id){
+    updateWalletName(id, newName) {
+      if (id == this.id) {
         this.username = newName
       }
       const index = this.walletList.findIndex(item => item.id === id);
       if (index !== -1) {
         this.walletList[index].username = newName
       }
+    },
+    // 添加代币
+    async addTokenList() {
+      const findIndex = this.walletList.findIndex(item => item.id === this.id);
+      const { data } = await hotTokens({ chain: this.accountName, address: this.account });
+      this.tokenList = data;
+      this.walletList[findIndex].tokenList = data;
+    },
+    changeToten(name) {
+      const findIndex = this.walletList.findIndex(item => item.id === this.id);
+      const index = this.tokenList.findIndex(item => item.name === name);
+      this.tokenList[index].show = !this.tokenList[index].show
+      this.walletList[findIndex].tokenList = this.tokenList;
+    },
+    // 更新当前选中钱包代币余额
+    async updateTokenVal() {
+      const findIndex = this.walletList.findIndex(item => item.id === this.id);
+      const { data } = await hotTokens({ chain: this.accountName, address: this.account });
+      this.tokenList.forEach(el => {
+        data.forEach(ele => {
+          if (el.name == ele.name) {
+            el.balance = ele.balance;
+            el.money = ele.money
+            el.rate = ele.rate
+          }
+        })
+      })
+      this.walletList[findIndex].tokenList = this.tokenList;
+      return this.tokenList;
     }
   },
 });

+ 14 - 8
src/views/me/index.vue

@@ -50,9 +50,9 @@
     <!-- 用户索引栏 -->
     <van-list class="user-bar-list">
       <van-cell 
-        v-for="(item, index) in vanListConfig" 
+        v-for="(item, index) in filteredVanList" 
         :key="index" 
-        :class="index == vanListConfig.length - 1 ? 'user-bar-list-last' : ''"
+        :class="index == filteredVanList.length - 1 ? 'user-bar-list-last' : ''"
         :title="item.title"
         is-link
         @click="evGoPath(item.url)"
@@ -66,16 +66,22 @@
 </template>
 
 <script setup> 
+import { useSystemStore } from "@/stores/modules/systemStore"
+const systemStore = useSystemStore();
 const router = useRouter();
+
 const vanListConfig = [
-  { title: '元宝兑换', icon:"ingot",  url: 'exchange' },
-  { title: '竞赛', icon:"competition",  url: '/' },
-  { title: '节点分红', icon:"red-envelope",  url: 'nodeDividend' },
+  { title: '元宝兑换', icon:"ingot",  url: 'exchange',status:true },
+  { title: '竞赛', icon:"competition",  url: '/',status:true },
+  { title: '节点分红', icon:"red-envelope",  url: 'nodeDividend',status:systemStore.Administrator.is_white },
   // { title: '帮助中心', icon:"help",  url: '/' },
-  { title: $t('router.AboutUs'), icon:"me",  url: 'aboutUs' },
-  { title: '系统设置', icon:"set",  url: 'systemSettings' },
-  { title: '管理员设置', icon:"admin-set",  url: 'administratorSettings' },
+  { title: $t('router.AboutUs'), icon:"me",  url: 'aboutUs',status:true },
+  { title: '系统设置', icon:"set",  url: 'systemSettings',status:true },
+  { title: '管理员设置', icon:"admin-set",  url: 'administratorSettings',status:systemStore.Administrator.is_super },
 ]
+const filteredVanList = computed(() => {
+  return vanListConfig.filter(item => item.status !== false);
+});
 const evGoPath = (path)=>{
   router.push(path)
 }

+ 70 - 20
src/views/me/walletManagement/index.vue

@@ -5,7 +5,7 @@
                 :class="tabIndex == i?'active-border':''" 
                 v-for="(item,i) in tabList" :key="i" @click="tabIndex = i"
             >
-                <svg-icon class="tab-box-icon" :name="item.img" />
+                <van-image class="tab-box-icon" round :src="item.img"/>
                 <text>{{item.name}}</text>
             </div>
         </div>
@@ -14,21 +14,22 @@
                 <template #item="{ element }">
                     <div class="sort-box">
                         <div class="sort-title">
-                            <div>{{element.name}}</div>
+                            <div>{{ element.name }}</div>
                             <svg-icon class="sort-icon" name="px" />
                         </div>
-                        <div class="card-box">
+
+                        <div class="card-box" :class="element.id == walletStore.id?'active-border':''">
                             <div class="card-box-lf">
-                                <svg-icon class="card-box-lf-icon" :name="element.img" />
+                                <van-image class="card-box-lf-icon" round :src="element.img"/>
                                 <div class="card-box-lf-text">
-                                    <div>{{element.name}}</div>
+                                    <div>{{ element.name }}</div>
                                     <div class="address">
-                                        <span>{{element.address}}</span>
-                                        <svg-icon style="width:16px;height: 16px;margin-left: 2px;" name="copy" />
+                                    <span>{{ element.address }}</span>
+                                    <svg-icon name="copy" style="width:16px;height:16px;margin-left:2px" />
                                     </div>
                                 </div>
                             </div>
-                            <svg-icon style="width:16px;height: 16px;color: #4F4F4F;" name="bj" />
+                            <svg-icon name="bj" style="width:16px;height:16px;color:#4F4F4F" @click="goToPage(element.id)"/>
                         </div>
                     </div>
                 </template>
@@ -39,19 +40,65 @@
 
 <script setup>
 import Draggable from 'vuedraggable';
-const tabList = [{name:'ACC',img:'acc'},{name:'Ethereum',img:'acc'},{name:'BNB',img:'acc'}];
+import { useWalletStore } from '@/stores/modules/walletStore';
+import { useRouter } from 'vue-router'
+const walletStore = useWalletStore();
+const router = useRouter();
+
+const tabList = [
+  { name: 'ACC', img: 'https://wallet.angeltokens.io/storage/images/acc.svg' },
+  { name: 'Ethereum', img: 'https://wallet.angeltokens.io/storage/images/eth.svg' },
+  { name: 'BNB', img: 'https://wallet.angeltokens.io/storage/images/bsc.svg' }
+];
 const tabIndex = ref(0);
-const items = ref([
-    { id: 1, name: 'WWW',img:'acc',address:'0x01Ce8d3A...F5320f2' },
-    { id: 2, name: '香蕉',img:'acc',address:'123456789...98546212' },
-    { id: 3, name: '橘子',img:'acc',address:'0x01Ce8d3A...F5320f2' },
-    { id: 4, name: 'WWW',img:'acc',address:'0x01Ce8d3A...F5320f2' },
-    { id: 5, name: '香蕉',img:'acc',address:'123456789...98546212' },
-    { id: 6, name: '橘子',img:'acc',address:'0x01Ce8d3A...F5320f2' },
-    { id: 7, name: 'WWW',img:'acc',address:'0x01Ce8d3A...F5320f2' },
-    { id: 8, name: '香蕉',img:'acc',address:'123456789...98546212' },
-    { id: 9, name: '橘子',img:'acc',address:'0x01Ce8d3A...F5320f2' }
-]);
+
+/* 地址缩写 */
+const short = (addr) =>
+  addr ? addr.slice(0, 6) + '...' + addr.slice(-6) : '';
+
+/* 核心:带 setter 的 computed */
+const items = computed({
+  /* getter:根据当前 tab 过滤 */
+  get() {
+    const currName = tabList[tabIndex.value].name;
+    return walletStore.walletList
+      .filter(w => w.accountName === currName)
+      .map(w => ({
+        id: w.id,
+        name: w.username,
+        img: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
+        address: short(w.account),
+        _raw: w,            // 保留原始对象引用,更新时用
+      }));
+  },
+  /* setter:拖拽后新顺序 -> 回写 Pinia */
+  set(newOrder) {
+    const currName = tabList[tabIndex.value].name;
+
+    // 取出其他币种保持原顺序
+    const others = walletStore.walletList.filter(
+      w => w.accountName !== currName
+    );
+
+    // 新顺序的新数组(去掉临时字段 _raw)
+    const reordered = newOrder.map(o => o._raw);
+
+    // 合并并回写
+    walletStore.walletList = [...others, ...reordered];
+
+    // 有 pinia-plugin-persist 时,这一句可省;否则手动持久化
+    walletStore.$persist?.();
+  },
+});
+const goToPage = (id) => {
+    router.push({
+      path: 'walletDetail',
+      query:{
+        id
+      }
+    })
+}
+
 </script>
 
 <style scoped lang="less">
@@ -143,5 +190,8 @@ const items = ref([
             }
         }
     }
+    .active-border{
+        border: 1px solid @theme-color1;
+    }
 }
 </style>

+ 1 - 2
src/views/transaction/index.vue

@@ -95,7 +95,6 @@
 
 <script setup>
 import { useRouter } from 'vue-router'
-import { hotTokens } from '@/api/path/login.api'
 import { useWalletStore } from "@/stores/modules/walletStore";
 import { stt2acc } from '@/api/path/exchange.api'
 import { AES_CBC_ENCRYPT,generateSign } from '@/utils/crypto';
@@ -119,7 +118,7 @@ const isSellValid = computed(() => {
 });
 // 代币数据
 const gethotTokens = async () => {
-    const {data} = await hotTokens({chain: walletStore.accountName,address:walletStore.account});
+    const data =   await walletStore.updateTokenVal() 
     ACCLIST.value = data[0];
     STTLIST.value = data[1];
 }

+ 65 - 27
src/views/wallet/index.vue

@@ -36,7 +36,7 @@
             <svg-icon  style="width: 16px; height: 16px;" :name="isShow?'eyes':'seyes'" @click="isShow = !isShow"/>
           </div>
         </div>
-        <svg-icon style="width: 24px; height: 24px; margin-right: 27px;" name="right" @click="goToPage('walletDetail')"/>
+        <svg-icon style="width: 24px; height: 24px; margin-right: 27px;" name="right" @click="goToPageDetail"/>
       </div>
       <div class="card-box">
         <div class="box-cont" @click="goToPage('exchange')">
@@ -66,16 +66,18 @@
           <svg-icon style="width: 24px; height: 24px;" name="add" @click="changePop(1)"/>
         </div>
         <div class="list-ul">
-          <div class="list-li" v-for="item in hotTokensList" @click="changePop(2)">
-            <div class="list-li-lf">
-              <van-image width="30px" height="30px" round :src="item.logo"/>
-              <div style="margin-left: 8px;">{{item.name}}</div>
-            </div>
-            <div class="list-li-ri">
-              <div>{{item.balance}}</div>
-              <div class="list-li-ri-num">${{item.money}}</div>
+          <template v-for="(item,i) in walletStore.tokenList" :key="i">
+            <div class="list-li" v-if="item.name == 'ACC' || !item.show" @click="changePop(2)">
+              <div class="list-li-lf">
+                <van-image width="30px" height="30px" round :src="item.logo"/>
+                <div style="margin-left: 8px;">{{item.name}}</div>
+              </div>
+              <div class="list-li-ri">
+                <div>{{item.balance}}</div>
+                <div class="list-li-ri-num">${{item.money}}</div>
+              </div>
             </div>
-          </div>
+          </template>
         </div>
       </div>
       <van-popup v-model:show="showWallet" position="bottom" round>
@@ -91,7 +93,7 @@
               </div>
             </div>
             <div class="tree-ri">
-              <div class="tree-ri-title">{{networkList[netWorkIndex].name}}</div>
+              <div class="tree-ri-title">{{networkList[netWorkIndex]?.name}}</div>
               <div class="tree-ul">
                 <div class="tree-li" 
                   v-for="(item,i) in currentWallets" 
@@ -128,8 +130,8 @@
           </div>
           <!-- 1 -->
           <div class="pop-ul" v-if="type == 1">
-            <div class="pop-li" v-for="(item,i) in dbList">
-              <div class="pop-li-lf">
+            <div class="pop-li" v-for="(item,i) in walletStore.tokenList">
+              <div class="pop-li-lf" v-if="item.name != 'ACC'">
                 <van-image
                   width="32px"
                   height="32px"
@@ -141,7 +143,7 @@
                   <div class="pop-address">{{ formatAddress(item.address) }}</div>
                 </div>
               </div>
-              <svg-icon style="width: 20px; height: 20px;" :name="item.hide?'add-icon':'del-icon'" @click="item.hide = !item.hide"/>
+              <svg-icon v-if="item.name != 'ACC'" style="width: 20px; height: 20px;" :name="item.show?'add-icon':'del-icon'" @click="tokensHandle(item)"/>
             </div>
           </div>
           <!-- 2 -->
@@ -183,28 +185,49 @@
   
   <script setup>
   import { useRouter } from 'vue-router'
-  import { getNetwork,hotTokens } from '@/api/path/login.api'
+  import { getNetwork } from '@/api/path/login.api'
+  import { userInfo } from '@/api/path/jdfh.api'
   import { useWalletStore } from "@/stores/modules/walletStore";
+  import { useSystemStore } from "@/stores/modules/systemStore"
   const router = useRouter();
   const walletStore = useWalletStore();
+  const systemStore = useSystemStore();
 
-  
   const isShow = ref(true);
   const showWallet = ref(false);
   const showHistory = ref(false);
   const networkList = ref([]);
-  const hotTokensList = ref([]);
-  const dbList = ref([]);
   const netWorkIndex = ref(0);
-  const totalMoney = ref(0);//总数
   const type = ref('');
   const goToPage = (url) => {
     router.push(url)
   }
+  // 跳转详情
+  const goToPageDetail = () => {
+    router.push({
+      path: 'walletDetail',
+      query:{
+        id:walletStore.id
+      }
+    })
+  }
   const changePop = (val) => {
     showHistory.value = true;
     type.value = val;
   }
+  // 计算总和
+  const totalMoney = computed(() => {
+    const list = walletStore.tokenList
+    if (!Array.isArray(list) || list.length === 0) return 0
+    let total = Number(list[0].money || 0)
+    for (let i = 1; i < list.length; i++) {
+      if (!list[i].show) {
+        total += Number(list[i].money || 0)
+      }
+    }
+    return Number(total.toFixed(4))
+  })
+
   // 添加钱包
   const addWallet = () => {
     walletStore.accountName = networkList.value[netWorkIndex.value].name
@@ -236,22 +259,37 @@
   const changeWallet = (item) => {
     walletStore.switchWallet(item.id);
     showWallet.value = false;
-    gethotTokens();
+    // getuserInfo();
   }
-  // 代币数据
-  const gethotTokens = async () => {
-    const {data} = await hotTokens({chain: walletStore.accountName,address:walletStore.account});
-    hotTokensList.value = data;
-    dbList.value = data.slice(1, 3);
-    totalMoney.value = data.reduce((sum, item) => sum + Number(item.money || 0), 0).toFixed(8);
+  // 节点分红---获取用户是否为管理员以及是否加入了白名单
+  const getuserInfo = async () => {
+    const res = await userInfo({address:walletStore.account});
+    if(res.ret){
+      const isSuper = res.data.is_super;
+      const isWhite = res.data.is_white;
+      let data = {}
+      data.is_exclusive = res.data.is_exclusive || false;//链上加白名单
+      data.is_super = typeof isSuper === 'boolean' ? isSuper : false;
+      data.is_white = typeof isWhite === 'boolean' ? isWhite : false;
+
+      systemStore.setStateValue({
+        key: "Administrator",
+        value: data,
+        localStorage: true,
+      })
+    }
   }
   const formatAddress = (address) => {
     if (!address) return '';
     return address.slice(0, 8) + '...' + address.slice(-6);
   };
+  // 代币显示隐藏
+  const tokensHandle  = (item)=>{
+    walletStore.changeToten(item.name)
+  }
   onMounted(async ()=>{
     initNetwork();
-    gethotTokens();
+    // getuserInfo();
   })
   </script>
   

+ 1 - 2
src/views/wallet/transferDetail/index.vue

@@ -104,7 +104,6 @@
 <script setup>
 import { useRouter } from 'vue-router'
 import { useWalletStore } from "@/stores/modules/walletStore";
-import { hotTokens } from '@/api/path/login.api'
 import Web3 from "web3";
 import pubData from "@/utils/pub.json";
 import { showLoadingToast, showToast } from 'vant';
@@ -134,7 +133,7 @@ const isDisabled = computed(() => {
 
 // 获取代币信息
 const gethotTokens = async () => {
-    const {data} = await hotTokens({chain: walletStore.accountName,address:walletStore.account});
+    const data =   await walletStore.updateTokenVal() 
     hotTokensList.value = data;
     selecctList.value = data[0];
 }

+ 135 - 80
src/views/wallet/walletDetail/index.vue

@@ -1,40 +1,58 @@
 <template>
     <div class="container">
         <div class="userimg">
-            <van-image 
-                round 
-                width="60" 
-                height="60" 
+            <van-image
+                round
+                width="60"
+                height="60"
                 src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
             />
         </div>
-        <div class="username">{{walletStore.username}}</div>
+        <div class="username">{{ currentWallet.username }}</div>
         <div class="useraddress">
-            <span>{{formatAddress(walletStore.account)}}</span>
-            <svg-icon style="width: 18px; height: 18px;" name="copy" />
+            <span>{{ formatAddress(currentWallet.account) }}</span>
+            <svg-icon style="width: 18px; height: 18px" name="copy" />
         </div>
+
         <van-list class="user-bar-list">
-            <van-cell title="錢包名稱" :value="walletStore.username" is-link @click="changePop(1)"></van-cell>
-            <van-cell title="查看私鑰" value="" is-link @click="changePop(2)"></van-cell> 
+            <van-cell
+                title="錢包名稱"
+                :value="currentWallet.username"
+                is-link
+                @click="changePop(1)"
+            ></van-cell>
+            <van-cell
+                title="查看私鑰"
+                value=""
+                is-link
+                @click="changePop(2)"
+            ></van-cell>
         </van-list>
+
         <van-button class="footer-btn" size="large" @click="changePop(3)">删除钱包</van-button>
-        <van-popup v-model:show="show" :style="{ borderRadius:'25px' }">
+
+        <!-- 弹窗:输入名称 / 密码 -->
+        <van-popup v-model:show="show" :style="{ borderRadius: '25px' }">
             <div class="pop-content">
-                <div class="pop-title">{{type == 1?'請輸入錢包名稱':'請輸入密碼'}}</div>
-                <van-field v-model="text" class="pop-input" :type="type == 1?'text':'password'"/>
+                <div class="pop-title">
+                    {{ type == 1 ? '請輸入錢包名稱' : '請輸入密碼' }}
+                </div>
+                <van-field v-model="text" class="pop-input" :type="type == 1 ? 'text' : 'password'"/>
                 <div class="pop-btn">
                     <van-button type="default" class="btn cancel" @click="cancel">取消</van-button>
                     <van-button type="default" class="btn confirm" @click="confirm">確定</van-button>
                 </div>
             </div>
         </van-popup>
+
+        <!-- 弹窗:显示私钥 -->
         <van-popup v-model:show="showkey" position="bottom" round>
             <div>
                 <div class="pop-title-key">
-                    <svg-icon style="width: 24px; height: 24px;" name="left-arrow" />
+                    <svg-icon style="width: 24px; height: 24px" name="left-arrow"/>
                     <div class="title">查看私钥</div>
                 </div>
-                <div class="pop-text">{{walletStore.privateKey}}</div>
+                <div class="pop-text">{{ qrtext }}</div>
                 <div class="qrcode">
                     <qrcode-vue :value="qrtext" :size="156" :margin="1" background="transparent"/>
                 </div>
@@ -47,102 +65,129 @@
 </template>
 
 <script setup>
-import QrcodeVue from 'qrcode.vue'
-import { useWalletStore } from "@/stores/modules/walletStore";
+import { ref, computed } from 'vue';
+import QrcodeVue from 'qrcode.vue';
+import { useWalletStore } from '@/stores/modules/walletStore';
 import { showNotify } from 'vant';
+import { useRoute } from 'vue-router';
+
 const walletStore = useWalletStore();
+const route = useRoute();
+const id = route.query.id;
+
+// 当前显示的钱包对象
+const currentWallet = computed(() => {
+    if (id === walletStore.id) {
+        return walletStore;
+    } else {
+        return walletStore.walletList.find(item => item.id === id) || {};
+    }
+});
+const qrtext = currentWallet.value.privateKey;
 
+// 弹窗控制
 const show = ref(false);
 const showkey = ref(false);
 const text = ref('');
 const type = ref('');
-const qrtext = walletStore.privateKey;
-const changePop = (v) => {
+
+// 弹窗操作
+const changePop = v => {
     show.value = true;
     type.value = v;
-}
+};
+
 const cancel = () => {
-    text.value = ''
+    text.value = '';
     show.value = false;
-}
+};
+
 const confirm = () => {
-    if(type.value == 1){
+    if (type.value == 1) {
         // 修改钱包名称
-        walletStore.updateWalletName(walletStore.id,text.value)
-    }else if(type.value == 3){
+        walletStore.updateWalletName(id, text.value);
+    } else if (type.value == 3) {
         // 删除钱包
-        walletStore.deleteWallet(walletStore.id,text.value)
-    }else if(type.value == 2){
+        walletStore.deleteWallet(id, text.value);
+    } else if (type.value == 2) {
         // 查看私钥
-        if(text.value != walletStore.accountPassword){
+        if (text.value !== currentWallet.value.accountPassword) {
             showNotify({ type: 'warning', message: '请输入正确的密码' });
-        }else{
-            showkey.value = true
+        } else {
+            showkey.value = true;
         }
     }
-    text.value = ''
+    text.value = '';
     show.value = false;
-}
-const formatAddress = (address) => {
+};
+
+// 地址格式化
+const formatAddress = address => {
     if (!address) return '';
     return address.slice(0, 8) + '...' + address.slice(-6);
-  };
+};
 </script>
 
 <style lang="less" scoped>
-.container{
+.container {
     padding: 25px 17px 33px;
     height: calc(100vh - 44px);
     box-sizing: border-box;
     display: flex;
     flex-direction: column;
-    .userimg{
+    .userimg {
         display: flex;
         justify-content: center;
     }
-    .username{
+    .username {
         text-align: center;
         margin: 10px 0 4px;
-        font-family: PingFang SC, PingFang SC;
+        font-family:
+            PingFang SC,
+            PingFang SC;
         font-weight: 500;
         font-size: 17px;
         color: @theme-color1;
     }
-    .useraddress{
+    .useraddress {
         text-align: center;
-        font-family: PingFang SC, PingFang SC;
+        font-family:
+            PingFang SC,
+            PingFang SC;
         font-weight: 400;
         font-size: 12px;
-        color: #8D8D8D;
+        color: #8d8d8d;
         display: flex;
         align-items: center;
         justify-content: center;
     }
-    .van-cell{
+    .van-cell {
         height: 42px;
         background: @bg-color1;
         border-bottom: 1px solid @bg-color1;
-        font-size: 15px ;
-        &::after{
-            border-bottom: 1px solid #F2F2F2;
+        font-size: 15px;
+        &::after {
+            border-bottom: 1px solid #f2f2f2;
         }
     }
-    .user-bar-list-last::after{
+    .user-bar-list-last::after {
         border-bottom: 0;
     }
 
-    .user-bar-list{
+    .user-bar-list {
         margin: 25px 0 37px;
         border-radius: 12px;
         overflow: hidden;
         flex: 1;
     }
-    .footer-btn{
+    .footer-btn {
         border-radius: 28px !important;
         height: 40px !important;
         line-height: 40px !important;
         border: 1px solid @theme-color1 !important;
-        font-family: PingFang SC, PingFang SC;
+        font-family:
+            PingFang SC,
+            PingFang SC;
         font-weight: 500;
         font-size: 15px;
         color: @theme-color1;
@@ -150,90 +195,100 @@ const formatAddress = (address) => {
         padding: 9px 0 !important;
         box-sizing: border-box;
     }
-    .pop-content{
+    .pop-content {
         padding: 27px 35px 25px 34px;
-        .pop-title{
-            font-family: PingFang SC, PingFang SC;
+        .pop-title {
+            font-family:
+                PingFang SC,
+                PingFang SC;
             font-weight: 500;
             font-size: 17px;
             color: #000000;
             text-align: center;
         }
-        .pop-input{
-            background: #F2F2F2;
+        .pop-input {
+            background: #f2f2f2;
             border-radius: 8px;
             height: 40px;
             margin: 21px 0 31px;
         }
-        .pop-btn{
+        .pop-btn {
             display: flex;
             justify-content: center;
-            .btn{
+            .btn {
                 width: 83px;
                 height: 29px;
                 line-height: 29px;
                 padding: 5px 0 !important;
                 border-radius: 6px;
-                font-family: PingFang SC, PingFang SC;
+                font-family:
+                    PingFang SC,
+                    PingFang SC;
                 font-weight: 400;
                 font-size: 15px;
-                box-sizing:border-box;
+                box-sizing: border-box;
             }
-            .cancel{
+            .cancel {
                 margin-right: 17px !important;
-                border: 1px solid #D8D8D8;
+                border: 1px solid #d8d8d8;
                 color: #000 !important;
             }
-            .confirm{
+            .confirm {
                 background: @theme-color1;
-                color: #FFF;
+                color: #fff;
                 font-weight: 500;
             }
         }
     }
-    .pop-title-key{
+    .pop-title-key {
         padding: 17px;
-        border-bottom: 1px solid #F2F2F2;
+        border-bottom: 1px solid #f2f2f2;
         display: flex;
         align-items: center;
-        font-family: PingFang SC, PingFang SC;
+        font-family:
+            PingFang SC,
+            PingFang SC;
         font-weight: 500;
         font-size: 17px;
         color: #000000;
-        .title{
+        .title {
             flex: 1;
             display: flex;
             justify-content: center;
         }
     }
-    .pop-text{
+    .pop-text {
         margin: 17px;
         box-sizing: border-box;
-        background: #F2F2F2;
+        background: #f2f2f2;
         border-radius: 8px;
-        border: 1px solid #D8D8D8;
+        border: 1px solid #d8d8d8;
         padding: 9px 17px;
         word-break: break-word;
-        font-family: PingFang SC, PingFang SC;
+        font-family:
+            PingFang SC,
+            PingFang SC;
         font-weight: 400;
         font-size: 17px;
         color: @font-color2;
     }
-    .qrcode{
+    .qrcode {
         display: flex;
         flex-direction: column;
         align-items: center;
     }
-    .pop-btn-key{
+    .pop-btn-key {
         margin: 17px;
-        .btn-key{
-          height: 40px;
-          line-height: 40px;
-          border-radius: 50px;
-          font-family: PingFang SC, PingFang SC;
-          font-weight: 500;
-          font-size: 15px;
-          color: #FFFFFF;
+        .btn-key {
+            height: 40px;
+            line-height: 40px;
+            border-radius: 50px;
+            font-family:
+                PingFang SC,
+                PingFang SC;
+            font-weight: 500;
+            font-size: 15px;
+            color: #ffffff;
         }
     }
 }
@@ -241,4 +296,4 @@ const formatAddress = (address) => {
     margin: 0 40px !important;
     width: auto !important;
 }
-</style>
+</style>

+ 1 - 2
src/views/wallet/ybExchange/index.vue

@@ -64,7 +64,6 @@
 <script setup>
 import { useWalletStore } from "@/stores/modules/walletStore";
 import { syceeBalance,syceeRecords,wgt2sycee,sycee2wgt } from '@/api/path/exchange.api'
-import { hotTokens } from '@/api/path/login.api'
 import { showToast } from 'vant';
 import { AES_CBC_ENCRYPT,generateSign } from '@/utils/crypto';
 const walletStore = useWalletStore();
@@ -93,7 +92,7 @@ const getbalanceInfo = async () => {
 }
 // 代币数据
 const gethotTokens = async () => {
-    const {data} = await hotTokens({chain: walletStore.accountName,address:walletStore.account});
+    const data =   await walletStore.updateTokenVal() 
     WGTbalance.value = data[2].balance;
 }
 // 取消