Răsfoiți Sursa

添加修改钱包名称方法

wkw 3 săptămâni în urmă
părinte
comite
52f0d31e42

+ 16 - 0
src/api/path/exchange.api.js

@@ -0,0 +1,16 @@
+import service from '../axios'
+
+// 查询用户元宝
+export function syceeBalance(param) {
+    return service.get('sycee/balance', { params: param });
+}
+
+// 流水记录表
+export function syceeRecords(param) {
+    return service.get('sycee/records', { params: param });
+}
+
+// // 资产增减接口
+// export function changeBalanceNew(param) {
+//     return service.post('playerStore/changeBalanceNew', param);
+// }

+ 10 - 0
src/stores/modules/walletStore.js

@@ -141,5 +141,15 @@ export const useWalletStore = defineStore("useWalletStore", {
       })
       this.$persist()
     },
+    // 修改钱包名称
+    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
+      }
+    }
   },
 });

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

@@ -93,7 +93,9 @@
             <div class="tree-ri">
               <div class="tree-ri-title">{{networkList[netWorkIndex].name}}</div>
               <div class="tree-ul">
-                <div class="tree-li" v-for="(item,i) in currentWallets" :class="i == 0?'tree-active':''">
+                <div class="tree-li" 
+                  v-for="(item,i) in currentWallets" 
+                  :class="item.id == walletStore.id?'tree-active':''" @click="changeWallet(item)">
                   <van-image
                     width="37px"
                     height="37px"
@@ -229,6 +231,12 @@
   const changeNetwork = (i) => {
     netWorkIndex.value = i;
   }
+  // 切换钱包
+  const changeWallet = (item) => {
+    walletStore.switchWallet(item.id);
+    showWallet.value = false;
+    gethotTokens();
+  }
   // 代币数据
   const gethotTokens = async () => {
     const {data} = await hotTokens({chain: walletStore.accountName,address:walletStore.account});

+ 13 - 3
src/views/wallet/walletDetail/index.vue

@@ -8,13 +8,13 @@
                 src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
             />
         </div>
-        <div class="username">Wallet</div>
+        <div class="username">{{walletStore.username}}</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">
-            <van-cell title="錢包名稱" value="Wallet" is-link @click="changePop(1)"></van-cell>
+            <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-list>
         <van-button class="footer-btn" size="large" @click="changePop(3)">删除钱包</van-button>
@@ -48,6 +48,9 @@
 
 <script setup>
 import QrcodeVue from 'qrcode.vue'
+import { useWalletStore } from "@/stores/modules/walletStore";
+const walletStore = useWalletStore();
+
 const show = ref(false);
 const showkey = ref(false);
 const text = ref('');
@@ -62,10 +65,17 @@ const cancel = () => {
     show.value = false;
 }
 const confirm = () => {
+    if(type.value == '1'){
+        walletStore. updateWalletName(walletStore.id,text.value)
+    }
     text.value = ''
     show.value = false;
     if(type.value == 2) showkey.value = true;
 }
+const formatAddress = (address) => {
+    if (!address) return '';
+    return address.slice(0, 8) + '...' + address.slice(-6);
+  };
 </script>
 
 <style lang="less" scoped>

+ 47 - 12
src/views/wallet/ybExchange/index.vue

@@ -11,7 +11,7 @@
                     />
                     <div class="card-text">
                         <div>元宝总额</div>
-                        <div class="balance">245.53</div>
+                        <div class="balance">{{ybbalance}}</div>
                     </div>
                 </div>
             </div>
@@ -19,23 +19,23 @@
             <div class="tab-box">
                 <div class="tab-item lf-bg">
                     <div>可用元宝</div>
-                    <div class="lf-balance">245.53</div>
-                    <van-button class="tab-lf-btn" type="primary" @click="show = true">兑换元宝</van-button>
+                    <div class="lf-balance">{{ ybbalance }}</div>
+                    <van-button class="tab-lf-btn" type="primary" @click="changePop(1)">兑换元宝</van-button>
                 </div>
                 <div class="tab-item ri-bg">
                     <div>冻结元宝</div>
-                    <div class="lf-balance">245.53</div>
-                    <van-button class="tab-ri-btn" type="primary" @click="show = true">取款(转出)</van-button>
+                    <div class="lf-balance">0</div>
+                    <van-button class="tab-ri-btn" type="primary" @click="changePop(2)">取款(转出)</van-button>
                 </div>
             </div>
             <div class="list-box">
                 <div>明细</div>
                 <div class="list-box-ul">
-                    <div class="list-box-li" v-for="(item,i) in 10">
-                        <div>购买商品</div>
+                    <div class="list-box-li" v-for="(item,i) in list" :key="i">
+                        <div>{{item.reason}}</div>
                         <div class="list-box-li-text">
-                            <div>2023-09-08 18:23:13</div>
-                            <div :class="i == 0?'red':'green'">{{i == 0?'-':'+'}}1400.00</div>
+                            <div>{{item.CreateTime}}</div>
+                            <div :class="item.amount < 0 ? 'red' : 'green'">{{ item.amount > 0 ? '+' + item.amount : item.amount }}</div>
                         </div>
                     </div>
                 </div>
@@ -44,11 +44,11 @@
         <van-popup v-model:show="show" :style="{ borderRadius:'25px' }">
             <div class="pop-content">
                 <div class="pop-title">兑换元宝</div>
-                <div class="pop-balance">当前WGT-ACC钱包余额1.139101703592472754</div>
-                <van-field v-model="text" class="pop-input" placeholder="请输入wgt数量"/>
+                <div class="pop-balance">{{selectIndex == 1?`当前WGT钱包余额 ${WGTbalance}`:`当前元宝总额 ${ybbalance}`}}</div>
+                <van-field v-model="text" class="pop-input" :placeholder="selectIndex == 1?'请输入wgt数量':'请输入元宝数量'"/>
                 <div class="pop-state">
                     <div style="margin-bottom: 4px;">说明</div>
-                    <div>兑换的币种数量,将按照当前价值转换成对应元宝实时到账</div>
+                    <div>{{selectIndex == 1?'兑换的币种数量,将按照当前价值转换成对应元宝实时到账':'取款的元宝数量,按照当前价值转换成兑换的币种实时到账'}}</div>
                 </div>
                 <div class="pop-btn">
                     <van-button type="default" class="btn cancel" @click="show = false">取消</van-button>
@@ -60,7 +60,42 @@
 </template>
 
 <script setup>
+import { useWalletStore } from "@/stores/modules/walletStore";
+import { syceeBalance,syceeRecords } from '@/api/path/exchange.api'
+import { hotTokens } from '@/api/path/login.api'
+const walletStore = useWalletStore();
+
+const list = ref([]);
+const ybbalance = ref(0);
+const text = ref('')
 const show = ref(false);
+const selectIndex = ref(1);
+const WGTbalance = ref(0);
+
+const changePop = (i) => {
+    selectIndex.value = i;
+    show.value = true;
+}
+
+const getList = async () => {
+    const { data } = await syceeRecords({dapp_id:0,game_id:0,address:walletStore.account})
+    list.value = data.records;
+}
+const getbalanceInfo = async () => {
+    const { data } = await syceeBalance({address:walletStore.account})
+    ybbalance.value = data.balance
+}
+// 代币数据
+const gethotTokens = async () => {
+    const {data} = await hotTokens({chain: walletStore.accountName,address:walletStore.account});
+    WGTbalance.value = data[2].balance;
+}
+onMounted(async ()=>{
+    getList();
+    getbalanceInfo();
+    gethotTokens();
+})
+
 </script>
 
 <style lang="less" scoped>