|
|
@@ -3,10 +3,14 @@
|
|
|
import {
|
|
|
getTotalMoney
|
|
|
} from "@/api/money";
|
|
|
- import {
|
|
|
- getDividendList
|
|
|
- } from "@/api/pledge";
|
|
|
+ import {
|
|
|
+ addPledge,
|
|
|
+ getDividendList, getPledgeConfig
|
|
|
+ } from "@/api/pledge";
|
|
|
import blank from "@/components/en-utils/en-blank/en-blank.vue"
|
|
|
+ import web3 from "web3";
|
|
|
+ import {ethers} from "ethers";
|
|
|
+ import tools from "@/common/js/tools";
|
|
|
export default {
|
|
|
name: "home-index",
|
|
|
props: {
|
|
|
@@ -20,7 +24,22 @@
|
|
|
watch: {
|
|
|
'address': function() {
|
|
|
this.getIconNum()
|
|
|
- }
|
|
|
+ },
|
|
|
+ 'pledgeNUm':function () {
|
|
|
+ console.log(this.pledgeNUm)
|
|
|
+ if(this.pledgeNUm===''){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.listTab===1){
|
|
|
+ if(this.coinNum<this.pledgeNUm){
|
|
|
+ this.pledgeNUm=this.coinNum
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(this.pledgeTotal<this.pledgeNUm){
|
|
|
+ this.pledgeNUm=this.pledgeTotal
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -32,18 +51,31 @@
|
|
|
page: 1,
|
|
|
total: '',
|
|
|
pledgeNUm: '',
|
|
|
+ bnb_num: '',
|
|
|
+ pledgeAddress: '',
|
|
|
list: []
|
|
|
};
|
|
|
},
|
|
|
+
|
|
|
mounted() {
|
|
|
this.getIconNum()
|
|
|
this.getTotalMoney()
|
|
|
this.getDividendList()
|
|
|
+ this.getPledgeConfig()
|
|
|
},
|
|
|
methods: {
|
|
|
+ getPledgeConfig(){
|
|
|
+ getPledgeConfig().then(res=>{
|
|
|
+ if(res.code===1){
|
|
|
+ this.bnb_num=res.data.bnb_num
|
|
|
+ this.pledgeAddress=res.data.address
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
setListTab(listTab) {
|
|
|
if (this.listTab !== listTab) {
|
|
|
this.listTab = listTab
|
|
|
+ this.pledgeNUm=''
|
|
|
}
|
|
|
},
|
|
|
getDividendList() {
|
|
|
@@ -56,6 +88,53 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ async addPledge(){
|
|
|
+ if(this.listTab===1){
|
|
|
+ if(this.coinNum<this.pledgeNUm){
|
|
|
+ tools.error('DAO不足')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(this.pledgeTotal<this.pledgeNUm){
|
|
|
+ tools.error('贡献不足')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let bnbNUm=tokenpocketBnb.getBalance(this.address)
|
|
|
+ if (bnbNUm<this.bnb_num){
|
|
|
+ tools.error('BNB不足')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let data=''
|
|
|
+ let transactionData
|
|
|
+ if(this.listTab===1){
|
|
|
+ data='0xa9059cbb'
|
|
|
+ //icon转账
|
|
|
+ let formHex=web3.utils.numberToHex(ethers.utils.parseEther(this.pledgeNUm.toString()).toString());
|
|
|
+ data=data+tools.replenishZero(this.pledgeAddress)+tools.replenishZero(formHex)
|
|
|
+ transactionData=await tokenpocketBnb.getContractTransaction(data, 0);
|
|
|
+ }else {
|
|
|
+ //bnb转账
|
|
|
+ transactionData=await tokenpocketBnb.getTransactionData(this.pledgeAddress, this.bnb_num);
|
|
|
+ }
|
|
|
+ tokenpocketBnb.sendTransaction(transactionData).then(res=>{
|
|
|
+ if(res){
|
|
|
+ addPledge({'type':this.listTab,'money':this.pledgeNUm,'hash':res}).then(res=>{
|
|
|
+ if(res.code===0){
|
|
|
+ this.pledgeNUm=''
|
|
|
+ tools.success(res.msg)
|
|
|
+ this.getTotalMoney()
|
|
|
+ }else {
|
|
|
+ tools.error(res.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ tools.error('发起失败')
|
|
|
+ }
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
scrolltolower() {
|
|
|
if (this.list.length < this.total) {
|
|
|
++this.page
|
|
|
@@ -84,10 +163,10 @@
|
|
|
|
|
|
},
|
|
|
setMax(){
|
|
|
- if(this.type===1){
|
|
|
- this.formNUm=this.usdtNum
|
|
|
+ if(this.listTab===1){
|
|
|
+ this.pledgeNUm=this.coinNum
|
|
|
}else {
|
|
|
- this.formNUm=this.iconNum
|
|
|
+ this.pledgeNUm=this.pledgeTotal
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
@@ -156,10 +235,10 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view>
|
|
|
- <input v-model="pledgeNUm" :placeholder="'输入要'+(listTab===1 ?'质押':'解压')+'的DAO数量'" placeholder-class="fs-28"></input>
|
|
|
+ <input v-model="pledgeNUm" :placeholder="'输入要'+(listTab===1 ?'质押':'解压')+'的DAO数量'" placeholder-class="fs-28"></input>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="convent-but b-rad-20 text-align-center fs-28 fc-f" @click="">
|
|
|
+ <view class="convent-but b-rad-20 text-align-center fs-28 fc-f" @click="addPledge">
|
|
|
确定
|
|
|
</view>
|
|
|
</view>
|