|
@@ -10,7 +10,7 @@
|
|
|
<view class="item-detail">{{$t('index.contract.money')}}</view>
|
|
<view class="item-detail">{{$t('index.contract.money')}}</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="input-item">
|
|
<view class="input-item">
|
|
|
- <view class="item-detail">100</view>
|
|
|
|
|
|
|
+ <view class="item-detail">{{bnbNum}}</view>
|
|
|
<view class="item-detail item-img">
|
|
<view class="item-detail item-img">
|
|
|
<view class="text-img">
|
|
<view class="text-img">
|
|
|
<image src="@/static/img/index/bnb.png"></image>
|
|
<image src="@/static/img/index/bnb.png"></image>
|
|
@@ -20,9 +20,9 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="data-but">
|
|
<view class="data-but">
|
|
|
- <button>定金</button>
|
|
|
|
|
|
|
+ <button @click="setInvest">定金</button>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="data-button">
|
|
|
|
|
|
|
+ <view class="data-button" @click="goToUrl(1)">
|
|
|
<image src="@/static/img/index/msg.svg"></image>
|
|
<image src="@/static/img/index/msg.svg"></image>
|
|
|
<view>{{$t('index.contract.word')}}>></view>
|
|
<view>{{$t('index.contract.word')}}>></view>
|
|
|
</view>
|
|
</view>
|
|
@@ -35,7 +35,7 @@
|
|
|
<view class="title-text">{{$t('index.contract.list.title')}}({{total}})</view>
|
|
<view class="title-text">{{$t('index.contract.list.title')}}({{total}})</view>
|
|
|
</view>
|
|
</view>
|
|
|
<division></division>
|
|
<division></division>
|
|
|
- <contract-list @setTotal="setTotal"></contract-list>
|
|
|
|
|
|
|
+ <contract-list ref="contractListObj" @setTotal="setTotal"></contract-list>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="contract-bottom"></view>
|
|
<view class="contract-bottom"></view>
|
|
|
</view>
|
|
</view>
|
|
@@ -46,6 +46,9 @@
|
|
|
import TopHead from "@/pages/index/components/top-head";
|
|
import TopHead from "@/pages/index/components/top-head";
|
|
|
import Division from "@/pages/index/components/division";
|
|
import Division from "@/pages/index/components/division";
|
|
|
import ContractList from "@/pages/index/components/contract-list";
|
|
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 {
|
|
export default {
|
|
|
name: "contract",
|
|
name: "contract",
|
|
@@ -53,14 +56,61 @@ export default {
|
|
|
props: {},
|
|
props: {},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- total:0
|
|
|
|
|
|
|
+ total:0,
|
|
|
|
|
+ bnbNum:0
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
watch: {},
|
|
watch: {},
|
|
|
- mounted() {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ async mounted() {
|
|
|
|
|
+ this.getInvestData()
|
|
|
|
|
+ this.bnbNum = await tokenpocketBnb.getBalance();
|
|
|
|
|
+ console.log(this.bnbNum)
|
|
|
|
|
+ this.bnbNum=(this.bnbNum*1).toFixed(6)*1
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
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){
|
|
setTotal(total){
|
|
|
this.total=total
|
|
this.total=total
|
|
|
},
|
|
},
|
|
@@ -68,17 +118,7 @@ export default {
|
|
|
switch (type) {
|
|
switch (type) {
|
|
|
case 1:
|
|
case 1:
|
|
|
uni.navigateTo({
|
|
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
|
|
break
|
|
|
}
|
|
}
|