USER-20230908AJ\Administrator před 6 měsíci
rodič
revize
ed53480222

+ 2 - 1
common/wallet/tokenpocket-wallet/tokenpocket-bnb.js

@@ -120,7 +120,8 @@ tokenpocketBnb.getTokenBalance=async function (selectedAddress,contractType) {
         let data='0x70a08231000000000000000000000000'+(selectedAddress.substring(2))
         console.log([{'to':contractArr[contractType],'data':data}, "latest"],data)
         tokenpocketBnb.getProvider().request({method: 'eth_call',params:[{'to':contractArr[contractType],'data':data}, "latest"]}).then((balance)=>{
-            balance= (web3.utils.hexToNumberString(balance)/(contractType===1?1000000:1000000000000000000)).toString()
+            // balance= (web3.utils.hexToNumberString(balance)/(contractType===1?1000000:1000000000000000000)).toString()
+            balance= (web3.utils.hexToNumberString(balance)/1000000000000000000).toString()
             if(balance<0.000001){
                 balance=0
             }

+ 49 - 7
pages/convert/convert-index.vue

@@ -1,23 +1,65 @@
 <script>
+import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
+import {getTotalMoney} from "@/api/money";
+
 export default {
   name: "convert-index",
   components: {},
   data() {
     return {
-      input: '',
       usdtNum:'',
       iconNum:'',
       type:1,
       toNum:'',
-      formNUm:''
+      formNUm:'',
+      price:'',
+      address:''
     };
   },
+  watch:{
+    'formNUm':function () {
+      if(this.formNUm===''){
+        this.toNum=''
+      }else {
+        this.toNum=this.formNUm*this.price
+      }
+    }
+  },
   mounted() {
+    this.getIconNum()
+    this.getTotalMoney()
   },
   methods: {
+    setMax(){
+      if(this.type===1){
+        this.formNUm=this.usdtNum
+      }else {
+        this.formNUm=this.iconNum
+      }
+    },
+    getTotalMoney(){
+      getTotalMoney().then(res=>{
+        if (res.code===1){
+          this.price=res.data.price
+
+        }
+      })
+    },
+    async  getIconNum(){
+      this.address=tokenpocketBnb.getMyAddress()
+      if(this.address===''){
+        return
+      }
+      setTimeout(async ()=>{
+        this.iconNum= await tokenpocketBnb.getTokenBalance(this.address,0)
+        this.usdtNum= await tokenpocketBnb.getTokenBalance(this.address,1)
+        console.log(this.coinNum,"icon-num----------------------")
+      },100)
+
+    },
     setType(){
       this.type=(this.type===1?2:1)
-      console.log(' this.type', this.type)
+      this.formNUm=''
     }
   },
 }
@@ -35,8 +77,8 @@ export default {
             ></image>
             <view class="fs-28">USDT</view>
           </view>
-          <view class="max-box b-rad-20 fs-28">
-            Max 0.01
+          <view class="max-box b-rad-20 fs-28" @click="setMax">
+            Max {{usdtNum}}
           </view>
         </view>
         <view>
@@ -52,8 +94,8 @@ export default {
             ></image>
             <view class="fs-28">DAO</view>
           </view>
-          <view class="max-box b-rad-20 fs-28">
-            Max 0.01
+          <view class="max-box b-rad-20 fs-28" @click="setMax">
+            Max {{iconNum}}
           </view>
         </view>
         <view>