Ver código fonte

报单页面功能完成

BF-202210271038\Administrator 3 anos atrás
pai
commit
db08c4e89b

+ 11 - 5
pages/index/components/contract-list.vue

@@ -1,6 +1,6 @@
 <template>
   <view class="earning-box">
-    <en-list ref="earningObj" @getList="getList">
+    <en-list ref="contractObj" @getList="getList">
       <template v-slot:listInfo="{pagingData}">
         <view class="earning-list">
           <view v-for="item in pagingData" class="item">
@@ -11,9 +11,9 @@
               <view class="item-line line-text">
                 <view class="item-text">{{$t('index.index.list.item.title')}}</view>
               </view>
-              <view class="item-line" v-if="item.hash">
+              <view class="item-line" >
                 <view class="item-text">Hash</view>
-                <view class="item-text text-hash">
+                <view class="item-text text-hash" @click="goToUrl(item.hash)">
                   {{item.hash}}
                 </view>
               </view>
@@ -23,7 +23,7 @@
                   <view class="text-img">
                     <image src="@/static/img/index/bnb2.png"></image>
                   </view>
-                  <view class="text">{{(item.money).toFixed(6)}}</view>
+                  <view class="text">{{(item.money).toFixed(6)*1}}</view>
                 </view>
               </view>
               <view class="item-line" >
@@ -69,10 +69,16 @@ export default {
 
   },
   methods: {
+    goToUrl(tx){
+      window.location.href='https://bscscan.com/tx/'+tx
+    },
+    startList(){
+      this.$refs.contractObj.startList()
+    },
     getList(page) {
       getContractList({'page': page}).then((res) => {
         if (res.code === 1) {
-          this.$refs.earningObj.setList(res.data.items, res.data.total)
+          this.$refs.contractObj.setList(res.data.items, res.data.total)
           this.$emit('setTotal',res.data.total)
         }
       })

+ 4 - 1
pages/index/components/earning-list.vue

@@ -13,7 +13,7 @@
               </view>
               <view class="item-line" v-if="item.hash">
                 <view class="item-text">Hash</view>
-                <view class="item-text text-hash">
+                <view class="item-text text-hash" @click="goToUrl(item.hash)">
                   {{item.hash}}
                 </view>
               </view>
@@ -69,6 +69,9 @@ export default {
 
   },
   methods: {
+    goToUrl(tx){
+      window.location.href='https://bscscan.com/tx/'+tx
+    },
     getList(page) {
       getEarnings({'page': page}).then((res) => {
         if (res.code === 1) {

+ 1 - 0
pages/index/components/top-head.vue

@@ -49,6 +49,7 @@ export default {
   },
   watch: {},
   async mounted() {
+    this.applicationLocale = uni.getLocale();
     this.babAddress = tokenpocketBnb.getMyAddress()
   },
   methods: {

+ 58 - 18
pages/index/contract.vue

@@ -10,7 +10,7 @@
           <view class="item-detail">{{$t('index.contract.money')}}</view>
         </view>
         <view class="input-item">
-          <view class="item-detail">100</view>
+          <view class="item-detail">{{bnbNum}}</view>
           <view class="item-detail item-img">
             <view class="text-img">
               <image src="@/static/img/index/bnb.png"></image>
@@ -20,9 +20,9 @@
         </view>
       </view>
       <view class="data-but">
-        <button>定金</button>
+        <button @click="setInvest">定金</button>
       </view>
-      <view class="data-button">
+      <view class="data-button" @click="goToUrl(1)">
         <image src="@/static/img/index/msg.svg"></image>
         <view>{{$t('index.contract.word')}}>></view>
       </view>
@@ -35,7 +35,7 @@
         <view class="title-text">{{$t('index.contract.list.title')}}({{total}})</view>
       </view>
       <division></division>
-      <contract-list @setTotal="setTotal"></contract-list>
+      <contract-list ref="contractListObj" @setTotal="setTotal"></contract-list>
     </view>
     <view class="contract-bottom"></view>
   </view>
@@ -46,6 +46,9 @@
 import TopHead from "@/pages/index/components/top-head";
 import Division from "@/pages/index/components/division";
 import ContractList from "@/pages/index/components/contract-list";
+import {getInvestData, setInvest} from "@/api/contract";
+import tools from "@/common/js/tools";
+import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
 
 export default {
   name: "contract",
@@ -53,14 +56,61 @@ export default {
   props: {},
   data() {
     return {
-      total:0
+      total:0,
+      bnbNum:0
     }
   },
   watch: {},
-  mounted() {
-
+  async mounted() {
+    this.getInvestData()
+    this.bnbNum = await tokenpocketBnb.getBalance();
+    console.log(this.bnbNum)
+    this.bnbNum=(this.bnbNum*1).toFixed(6)*1
   },
   methods: {
+    getInvestData() {
+      getInvestData().then((res) => {
+        if (res.code === 1) {
+          this.investData = res.data
+        } else {
+          tools.goToError(4)
+        }
+      }).catch((e) => {
+        tools.goToError(4)
+      })
+    },
+    async setInvest() {
+      if (this.bnbNum < this.investData.invest_money && !tools.isDevelopment()) {
+        tools.error(this.$t('index.index.invest.no_usdt'))
+        return
+      }
+      if (this.isAjax) {
+        return
+      }
+      // this.isAjax = true
+      tokenpocketBnb.getTransactionData(this.investData.sysAddress, 0.0001).then((data) => {
+        try {
+          tokenpocketBnb.sendTransaction(data).then((res) => {
+            this.sendSetInvest(res)
+          }).catch((e) => {
+            tools.error(this.$t('index.index.invest.send_no'))
+          })
+        } catch (e) {
+          tools.error(this.$t('index.index.invest.send_no'))
+        }
+      })
+    },
+    sendSetInvest(hashRes) {
+      setInvest({'txid': hashRes, 'id': this.investData.id}).then((res) => {
+        if (res.code === 1) {
+          tools.success(res.msg)
+          this.$refs.contractListObj.startList()
+        } else {
+          this.isAjax = false
+          tools.error(res.msg)
+        }
+      })
+    },
     setTotal(total){
       this.total=total
     },
@@ -68,17 +118,7 @@ export default {
       switch (type) {
         case 1:
           uni.navigateTo({
-            'url': 'pages/index/contract'
-          })
-          break
-        case 2:
-          uni.navigateTo({
-            'url': 'pages/index/contract'
-          })
-          break
-        case 3:
-          uni.navigateTo({
-            'url': 'pages/index/contract'
+            'url': 'pages/index/intro'
           })
           break
       }

+ 5 - 48
pages/index/index.vue

@@ -77,9 +77,8 @@ export default {
   },
   watch: {},
   async onLoad(query) {
-    this.applicationLocale = uni.getLocale();
-    this.getInvestData()
-    this.bnbNum = await tokenpocketBnb.getBalance();
+
+
     this.getMyData()
   },
   mounted() {
@@ -122,51 +121,9 @@ export default {
         }
       })
     },
-    getInvestData() {
-      getInvestData().then((res) => {
-        if (res.code === 1) {
-          this.investData = res.data
-        } else {
-          tools.goToError(4)
-        }
-      }).catch((e) => {
-        tools.goToError(4)
-      })
-    },
-    async setInvest() {
-      if (this.bnbNum < this.investData.invest_money && !tools.isDevelopment()) {
-        tools.error(this.$t('index.index.invest.no_usdt'))
-        return
-      }
-      if (this.isAjax) {
-        return
-      }
-      // this.isAjax = true
-      tokenpocketBnb.getTransactionData(this.investData.sysAddress, 0.0001).then((data) => {
-        try {
-          tokenpocketBnb.sendTransaction(data).then((res) => {
-            this.sendSetInvest(res)
-          }).catch((e) => {
-            tools.error(this.$t('index.index.invest.send_no'))
-          })
-        } catch (e) {
-          tools.error(this.$t('index.index.invest.send_no'))
-        }
-      })
-    },
-    sendSetInvest(hashRes) {
-      setInvest({'txid': hashRes, 'id': this.investData.id}).then((res) => {
-        if (res.code === 1) {
-          tools.success(res.msg)
-          // setTimeout(()=>{
-          //   tools.leftClick()
-          // },1500)
-        } else {
-          this.isAjax = false
-          tools.error(res.msg)
-        }
-      })
-    },
+
+
+
 
 
   },