瀏覽代碼

no message

USER-20230908AJ\Administrator 6 月之前
父節點
當前提交
b02160cf03
共有 2 個文件被更改,包括 54 次插入36 次删除
  1. 43 36
      App.vue
  2. 11 0
      pages/convert/convert-index.vue

+ 43 - 36
App.vue

@@ -6,30 +6,34 @@ import tools from "@/common/js/tools";
 export default {
   onLaunch: function () {
     console.log("App Launch");
-   let bnbObj= tokenpocketBnb.getProvider()
-    console.log(bnbObj)
-    bnbObj.on('accountsChanged',(accounts)=>{
-      if(accounts.length<=0){
-        uni.reLaunch({
-          'url':'pages/index/error?errorType=2'
-        })
-      }else {
-        uni.clearStorageSync()
-        this.login(accounts[0])
-      }
+    setTimeout(()=>{
+      let bnbObj= tokenpocketBnb.getProvider()
+      console.log(bnbObj)
+      bnbObj.on('accountsChanged',(accounts)=>{
+        console.log('监听成功')
+        if(accounts.length<=0){
+          uni.reLaunch({
+            'url':'pages/index/error?errorType=2'
+          })
+        }else {
+          uni.clearStorageSync()
+          this.login(accounts[0])
+        }
+
+      })
+      bnbObj.on('chainChanged',(chainId)=>{
+        if(chainId!=='0x38'){
+          uni.reLaunch({
+            'url':'pages/index/error?errorType=5'
+          })
+        }else {
+          uni.reLaunch({
+            'url':'pages/index/index'
+          })
+        }
+      })
+    },5000)
 
-    })
-    bnbObj.on('chainChanged',(chainId)=>{
-      if(chainId!=='0x38'){
-        uni.reLaunch({
-          'url':'pages/index/error?errorType=5'
-        })
-      }else {
-        uni.reLaunch({
-          'url':'pages/index/index'
-        })
-      }
-    })
     uni.$on('noBan',()=>{
       console.log(this.$Route)
       if(this.$Route.path!=='/pages/index/error'){
@@ -48,19 +52,22 @@ export default {
   },
   methods:{
     login(Address){
-      login({'address':Address}).then((res)=>{
-        if(res.code===1){
-          tools.setLoginInfo(res.data)
-          setTimeout(()=>{
-            uni.reLaunch({
-              url: '/pages/index/index'
-            })
-          },50)
-        }else {
-          uni.reLaunch({
-            url: 'pages/login/register?address='+Address
-          })
-        }
+      // login({'address':Address}).then((res)=>{
+      //   if(res.code===1){
+      //     tools.setLoginInfo(res.data)
+      //     setTimeout(()=>{
+      //       uni.reLaunch({
+      //         url: '/pages/index/index'
+      //       })
+      //     },50)
+      //   }else {
+      //     uni.reLaunch({
+      //       url: 'pages/login/register?address='+Address
+      //     })
+      //   }
+      // })
+      uni.reLaunch({
+        url: '/pages/login/index'
       })
     }
   }

+ 11 - 0
pages/convert/convert-index.vue

@@ -31,6 +31,8 @@
 				address: '',
 				dealAddress: '',
 				change_num: 0,
+        max_num: 0,
+        userDealNum: 0,
 				list: [],
 				page: 1,
 			};
@@ -44,8 +46,10 @@
 					if (this.type === 2) {
 						this.toNum = this.formNUm * this.price
 					} else {
+            console.log(this.formNUm , this.price);
 						this.toNum = (this.formNUm / this.price).toFixed(6)
 					}
+          console.log('11111',	this.toNum)
 
 				}
 			}
@@ -62,6 +66,8 @@
 					if (res.code === 1) {
 						this.dealAddress = res.data.address
 						this.change_num = res.data.change_num
+						this.max_num = res.data.max_num
+						this.userDealNum = res.data.userDealNum
 					}
 				})
 			},
@@ -70,6 +76,10 @@
 					tools.error("兑换数量异常")
 					return
 				}
+        if(this.formNUm*1+this.userDealNum>this.max_num){
+          tools.error("兑换超限")
+          return
+        }
 				let data = ''
 				let transactionData = ''
 				let formHex = web3.utils.numberToHex(ethers.utils.parseEther(this.formNUm.toString()).toString());
@@ -103,6 +113,7 @@
 								setTimeout(()=>{
                   this.getTotalMoney()
                   this.getIconNum()
+                  this.getAddress()
                   this.page=1
                   this.list=[]
                   this.getDealList()