Jelajahi Sumber

优化地址簿

wkw 3 minggu lalu
induk
melakukan
8aee400a28

+ 6 - 1
src/common/login.js

@@ -42,11 +42,16 @@ export async function sysLogin(address) {
 }
 
 // 更新用户信息
-export async function updateUserInfo(address) {
+export async function updateUserInfo(address,id) {
   const walletStore = useWalletStore();
  
 
   const res = await imLogin({ uuid: address });
   walletStore.avatar = imgHost + res.data.avatar;
   walletStore.username = res.data.nickname;
+  const index = walletStore.walletList.findIndex(item => item.id === id);
+  if (index !== -1) {
+    walletStore.walletList[index].username = res.data.nickname;
+    walletStore.walletList[index].avatar = imgHost + res.data.avatar;
+  }
 }

+ 9 - 3
src/router/system.js

@@ -68,9 +68,15 @@ export const systemRoutes = [
         component: () => import("@/views/wallet/transferDetail/index.vue"),
       },
       {
-        path: "addressManagement",
-        name: "addressManagement",
-        meta: { title: "router.addressBook", keepAlive: false, navbar: true, leftArrow: true }, // 地址管理
+        path: "transferAddressManagement",
+        name: "transferAddressManagement",
+        meta: { title: "router.addressBook", keepAlive: false, navbar: true, leftArrow: true, to: "transferDetail" }, // 地址管理
+        component: () => import("@/views/me/addressManagement/index.vue"),
+      },
+      {
+        path: "meAddressManagement",
+        name: "meAddressManagement",
+        meta: { title: "router.addressBook", keepAlive: false, navbar: true, leftArrow: true, to: "me" }, // 地址管理
         component: () => import("@/views/me/addressManagement/index.vue"),
       },
       {

+ 8 - 2
src/views/me/addAddress/index.vue

@@ -55,12 +55,13 @@
 </template>
 
 <script setup>
-import { useRouter } from 'vue-router'
+import { useRouter,useRoute } from 'vue-router'
 import { useWalletStore } from "@/stores/modules/walletStore";
 import { useSystemStore } from "@/stores/modules/systemStore";
 const systemStore = useSystemStore();
 const walletStore = useWalletStore();
 const router = useRouter();
+const route = useRoute()
 
 let hotTokensList = walletStore.tokenList;
 let selectTokenInfo = ref(walletStore.tokenList[0]);
@@ -84,7 +85,12 @@ const confirm = () => {
         walletAddress:walletAddress.value
     }
     systemStore.AddressList.push(item);
-    router.push('addressManagement')
+    if(route.query.type == 'transfer'){
+        router.push('transferAddressManagement')
+    }else{
+        router.push('meAddressManagement')
+    }
+    
 }
 </script>
 

+ 30 - 10
src/views/me/addressManagement/index.vue

@@ -18,7 +18,7 @@
                         </div>
                     </div>
                     <template #right>
-                        <div class="delete" @click.stop="changeDelete(i)">删除</div>
+                        <svg-icon class="delete" name="del-icon" @click.stop="changeDelete(i)"/>
                     </template>
                 </van-swipe-cell>
             </div>
@@ -32,22 +32,41 @@
 </template>
 
 <script setup>
-import { useRouter } from 'vue-router'
+import { useRouter,useRoute } from 'vue-router'
 import { useSystemStore } from "@/stores/modules/systemStore";
 const systemStore = useSystemStore();
 const router = useRouter();
+const route = useRoute()
 
 let list = ref(systemStore.AddressList);
 const goToAdd = () => {
-    router.push('addAddress')
+    if (route.name === 'transferAddressManagement') {
+        router.push({
+            path: 'addAddress',
+            query:{
+                type:'transfer'
+            }
+        })
+    } else if (route.name === 'meAddressManagement') {
+        router.push({
+            path: 'addAddress',
+            query:{
+                type:'me'
+            }
+        })
+    }
+    
 }
 const gotoPage = (val) => {
-    router.push({
-        path: 'transferDetail',
-        query:{
-            address:val
-        }
-    })
+    if (route.name === 'transferAddressManagement') {
+        router.push({
+            path: 'transferDetail',
+            query:{
+                address:val
+            }
+        })
+    }
+    
 }
 const changeDelete = (index) => {
     list.value.splice(index,1);
@@ -96,9 +115,10 @@ const changeDelete = (index) => {
                 border-bottom: 0;
             }
             .delete{
-                height: 100%;
                 color: red;
                 margin-left: 15px;
+                width: 20px; 
+                height: 20px;
             }
         }
         .card-box::-webkit-scrollbar{

+ 1 - 1
src/views/me/index.vue

@@ -22,7 +22,7 @@
       <van-row justify="end" class="user-info-row">
         <van-col span="6"  >
           <div class="user-bar-icon-box">
-            <svg-icon class="user-bar-icon"  name="address-book" @click="goToaPage('addressManagement')"/> 
+            <svg-icon class="user-bar-icon"  name="address-book" @click="goToaPage('meAddressManagement')"/> 
             <span class="user-info-text">地址薄</span> 
           </div>
         </van-col>

+ 7 - 4
src/views/me/personalInformation/index.vue

@@ -5,7 +5,7 @@
     </div>
     <div class="username">{{ walletStore.username || "Angel Token" }}</div>
     <div class="useraddress">
-      <span>0xF3fefE…EcaB</span>
+      <span>{{formatAddress(walletStore.account)}}</span>
       <svg-icon style="width: 18px; height: 18px" name="copy" />
     </div>
     <van-list class="user-bar-list">
@@ -51,7 +51,6 @@
 
 <script setup> 
 import QrcodeVue from "qrcode.vue";
-import { useSystemStore } from "@/stores/modules/systemStore";
 import { useWalletStore } from "@/stores/modules/walletStore";
 import { uploadFile, userInfoEdit } from "@/api/path/im.api";
 import { updateUserInfo } from "@/common/login";
@@ -68,7 +67,7 @@ const afterRead = async (file) => {
   formData.append("file", file.file);
   const { code, data } = await uploadFile(formData);
   if (code === 200) {
-    await updateUserInfo(walletStore.account);
+    await updateUserInfo(walletStore.account,walletStore.id);
   }
 };
 
@@ -78,10 +77,14 @@ const updateUserName = async () => {
     nickname:  nickname.value,
   });
   if (code === 200) {
-    await updateUserInfo(walletStore.account);
+    await updateUserInfo(walletStore.account,walletStore.id);
   }
   show.value = false;
 };
+const formatAddress = (address) => {
+  if (!address) return '';
+  return address.slice(0, 8) + '...' + address.slice(-6);
+};
 </script>
 
 <style lang="less" scoped>

+ 1 - 1
src/views/me/walletManagement/index.vue

@@ -66,7 +66,7 @@ const items = computed({
       .map(w => ({
         id: w.id,
         name: w.username,
-        img: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg',
+        img: w.avatar,
         address: short(w.account),
         _raw: w,            // 保留原始对象引用,更新时用
       }));

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

@@ -22,7 +22,7 @@
         </div>
         <div class="network">
           <van-image width="20px" height="20px" round :src="walletStore.accountIcon"/>
-          <div class="network-name">{{ walletStore.username  }}</div>
+          <div class="network-name">{{ walletStore.accountName  }}</div>
         </div>
       </div>
       <div class="amount">

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

@@ -134,7 +134,7 @@ const isDisabled = computed(() => {
 });
 
 const goToAddress = () => {
-    router.push('addressManagement')
+    router.push('transferAddressManagement')
 }
 const selectPop = (type) => {
     showWallet.value = true;

+ 1 - 1
src/views/wallet/walletDetail/index.vue

@@ -5,7 +5,7 @@
                 round
                 width="60"
                 height="60"
-                src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
+                :src="currentWallet.avatar"
             />
         </div>
         <div class="username">{{ currentWallet.username }}</div>