123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <template>
- <view class="container" style="padding-top: 100rpx;">
- <topView :backg="'#1A1A17'"></topView>
- <view class="infoBox">
- <view class="navBack" @click="navTo('/pages/index/property')">
- <u-icon name="arrow-left" size="25" color="#fff" style="position: absolute;left: 0;top: 0;font-weight: bold;"></u-icon>
- <view class="title">{{$t("property.充值")}}</view>
- </view>
- <view class="infoTpl">
- <view class="flex tplTop">
- <view class="name">{{$t("recharge.充值数量")}}</view>
- <view class="tip">{{$t("recharge.可用")}}{{userInfo.NUSD * 1}}NUSD</view>
- </view>
- <view class="flex inputBox">
- <input type="number" v-model="money" :placeholder='$t("recharge.请输入充值数量")'/>
- <!-- <view class="clickAll" @click="money = userInfo.NUSD * 1">NUSD 全部</view> -->
- </view>
- <!-- <view class="name">手续费</view>
- <view class="flex inputBox">
- <input v-model="free"/>
- <view class="freeTip">USTD</view>
- </view> -->
- </view>
- </view>
- <view class="footBox">
- <!-- <view class="flex numBox">
- <view class="numName">实际到账</view>
- <view class="num">{{num}}</view>
- </view> -->
- <view class="btnBox">
- <view class="submitBtn" :class="{ submitNo: !payOn }" @click="payOn ? recharge() : ''">{{$t("property.充值")}}</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import topView from '../components/topView.vue';
- import {mapState,mapActions,mapMutations} from "vuex";
- import {charge,chargeCalculator} from "@/api/index.js";
- export default {
- components: {
- topView
- },
- data () {
- return {
- money:"",
- free:"--",
- payOn:true
- }
- },
- onLoad () {
-
- },
- computed: {
- ...mapState('user', ['userInfo']),
- },
- methods: {
- async recharge(){
- let obj = this;
- if (obj.money == '') {
- uni.showToast({
- title: obj.$t("recharge.请输入充值数量"),
- icon: "none",
- });
- return;
- }
- obj.payOn = false
- try {
- const res = await chargeCalculator({
- token: 'NUSD',
- num: obj.money,
- });
- uni.showLoading({
- title: "loading...",
- mask: true,
- });
- const txHash = await ethereum.request({
- method: "eth_sendTransaction",
- params: [{
- from: obj.userInfo.address,
- to: res.data.data.to,
- value: 0,
- data: res.data.data.data,
- }, ],
- });
- const req = await charge({
- token: 'NUSD',
- num: obj.money,
- transactionHash: txHash
- });
- obj.payOn = true
- uni.showToast({
- title:obj.$t("recharge.请等待审核"),
- icon:'success'
- });
- obj.money = ''
- // setTimeout(function () {
- // obj.$router.go(0)
- // }, 1000);
- } catch (e) {
- obj.payOn = true
- uni.showToast({
- title: obj.$t("recharge.充值成功"),
- icon:"error"
- });
- }
- },
- navTo(url){
- uni.navigateTo({
- url:url
- })
- },
- },
- }
- </script>
- <style lang="scss">
- page {
- width: 100%;
- min-height: 100vh;
- .container {
- width: 100%;
- min-height: 100vh;
- }
- }
- .topBox {
- color: #FFE0BD;
- padding: 25rpx 27rpx;
- background: #1A1A17;
- .topTpl {
- .addr {
- padding: 6rpx 25rpx;
- background: linear-gradient(-74deg, #CE9C6D, #FFECD6);
- box-shadow: 3rpx 4rpx 5rpx 0rpx rgba(151, 118, 74, 0.5);
- border-radius: 21rpx;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #986629;
- }
- }
- }
- .infoBox{
- padding: 0rpx 30rpx;
- color: #fff;
- }
- .navBack{
- position: relative;
- color: #fff;
- text-align: center;
- margin: 30rpx 0rpx 40rpx 0rpx;
- .title{
- font-weight: bold;
- font-size: 34rpx;
- }
- }
- .infoTpl{
- background: #1A1A17;
- padding: 85rpx 25rpx;
- border-radius: 25rpx;
- .tplTop{
- .tip{
- font-size: 20rpx;
- }
- }
- .inputBox{
- background: #2F2F2D;
- padding: 25rpx 25rpx;
- border-radius: 25rpx;
- margin-bottom: 61rpx;
- .clickAll{
- font-size: 26rpx;
- }
- .freeTip{
- font-size: 30rpx;
- color: #888785;
- }
- }
- }
- .footBox{
- position: fixed;
- bottom: 0;
- width: 100%;
- background: #1A1A17;
- color: #fff;
- padding: 50rpx 42rpx;
- .numBox{
- .numName{
- font-weight: 500;
- font-size: 26rpx;
- color: #888785;
- }
- }
- .btnBox{
- // margin-top: 50rpx;
- .submitBtn{
- background: linear-gradient(258deg, #FFF0CF, #CBA16B, #FCE9CF, #C29963);
- border-radius: 10rpx;
- font-weight: bold;
- font-size: 32rpx;
- color: #31190B;
- text-align: center;
- padding: 20rpx 0rpx;
- }
- .submitNo {
- background: #999999 !important;
- color: #fff !important;
- }
- }
- }
- .name{
- font-size: 32rpx;
- font-weight: bold;
- padding-bottom: 35rpx;
- }
- </style>
|