123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <template>
- <view class="contract-box">
- <view class="contract-top">
- <top-head :top-type="2"></top-head>
- </view>
- <view class="contract-data">
- <view class="data-input">
- <view class="input-item">
- <view class="item-detail">{{$t('index.contract.num')}}</view>
- <view class="item-detail" @click="getBnbNum">{{$t('index.contract.money')}}:{{bnbNum}}</view>
- </view>
- <view class="input-item">
- <view class="item-detail">{{investData.invest_money}}</view>
- <view class="item-detail item-img">
- <view class="text-img">
- <image src="@/static/img/index/bnb.png"></image>
- </view>
- <view class="text">BNB</view>
- </view>
- </view>
- </view>
- <view class="data-but">
- <button @click="setInvest">{{$t('index.index.pay')}}</button>
- </view>
- <view v-if="false" class="data-button" @click="goToUrl(1)">
- <image src="@/static/img/index/msg.svg"></image>
- <view>{{$t('index.contract.word')}}>></view>
- </view>
- </view>
- <view class="contract-list">
- <view class="list-title">
- <view class="title-img">
- <image src="@/static/img/index/bnb2.png" mode="aspectFill"></image>
- </view>
- <view class="title-text">{{$t('index.contract.list.title')}}({{total}})</view>
- </view>
- <division></division>
- <contract-list ref="contractListObj" @setTotal="setTotal"></contract-list>
- </view>
- <view class="contract-bottom"></view>
- </view>
- </template>
- <script>
- 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",
- components: { ContractList, Division, TopHead},
- props: {},
- data() {
- return {
- total:0,
- bnbNum:0,
- investData: {
- id: 1,
- invest_money: '',
- sysAddress: "",
- sendNum: "",
- },
- }
- },
- watch: {},
- async mounted() {
- this.getInvestData()
- this.bnbNum = await tokenpocketBnb.getBalance();
- this.bnbNum=(this.bnbNum*1).toFixed(6)*1
- },
- methods: {
- async getBnbNum(){
- this.bnbNum = await tokenpocketBnb.getBalance();
- },
- 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, this.investData.invest_money).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
- },
- goToUrl(type) {
- switch (type) {
- case 1:
- uni.navigateTo({
- 'url': 'pages/index/intro'
- })
- break
- }
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .contract-box {
- padding-top: 124rpx;
- box-shadow: 0 0 24rpx 0 rgba(0, 0, 0, 0.16);
- min-height: 100vh;
- .contract-top {
- //padding: 20rpx 0;
- background: #fff;
- }
- .contract-data {
- background: #fff;
- width: 90%;
- margin: 60rpx auto 0;
- border-radius: 20rpx;
- padding: 40rpx 20rpx;
- font-size: 36rpx;
- box-shadow: 0 8rpx 16rpx 0 rgba(0, 0, 0, 0.08);
- .data-input {
- border: 1rpx solid #000;
- overflow: hidden;
- border-radius: 10rpx;
- padding: 20rpx;
- .input-item {
- display: flex;
- justify-content: space-between;
- .item-detail {
- font-size: 26rpx;
- }
- }
- .item-img {
- display: flex;
- justify-content: right;
- .text-img {
- display: inline-block;
- border-radius: 50%;
- height: 60rpx;
- width: 60rpx;
- box-sizing: border-box;
- margin-right: 10rpx;
- image {
- width: 60rpx;
- height: 60rpx;
- z-index: 100;
- }
- }
- .text {
- line-height: 60rpx;
- }
- }
- .input-item:first-child {
- margin-bottom: 40rpx;
- }
- .input-item:last-child {
- height: 60rpx;
- .item-detail {
- font-size: 32rpx;
- line-height: 60rpx;
- }
- }
- }
- .data-but {
- border-radius: 20rpx;
- margin-top: 60rpx;
- button {
- height: 90rpx;
- line-height: 90rpx;
- text-align: center;
- background: rgb(0, 87, 255);
- color: #fff;
- font-size: 26rpx;
- }
- }
- .data-button {
- margin-top: 40rpx;
- display: flex;
- justify-content: right;
- image {
- width: 40rpx;
- height: 40rpx;
- }
- view {
- font-size: 26rpx;
- margin-left: 10rpx;
- color: rgb(0, 87, 255);
- line-height: 40rpx;
- }
- }
- }
- .contract-list {
- background: #fff;
- width: 90%;
- margin: 40rpx auto;
- border-radius: 10px;
- padding: 20px 10px;
- overflow: hidden;
- font-size: 13px;
- box-shadow: 0 8rpx 16rpx 0 rgba(0, 0, 0, 0.08);
- .list-title {
- display: flex;
- justify-content: left;
- .title-img {
- background: rgb(0, 87, 255);
- padding: 10rpx;
- border-radius: 20rpx;
- image {
- width: 80rpx;
- height: 80rpx;
- }
- }
- .title-text {
- margin-left: 20rpx;
- line-height: 100rpx;
- font-size: 34rpx;
- font-weight: bold;
- }
- }
- }
- .contract-bottom {
- height: 50rpx;
- }
- }
- </style>
|