question_uniapp/pages/wallet/putforward.vue

287 lines
9.1 KiB
Vue
Raw Normal View History

2025-06-06 03:08:19 +08:00
<template>
<view class="page">
2025-06-10 00:51:49 +08:00
<uni-nav-bar @clickLeft="goto(1, 1)" left-icon="back" :border="false" :shadow="false" :fixed="true"
:title="$t('putforward.title')" backgroundColor="#fff">
<template v-slot:right>
<image style="width: 40rpx; height: 40rpx;" src="/static/images/r2.png" mode="cover" @click="onTokenJump('/pages/wallet/fundrecords?id=3')"></image>
</template>
</uni-nav-bar>
<view style="width: 94%; margin: 20rpx auto; padding: 20rpx 10rpx;">
2025-06-06 03:08:19 +08:00
<uni-forms :modelValue="putmodel" label-position="top" :rules="rules" ref="form">
<uni-forms-item name="address">
2025-06-10 00:51:49 +08:00
<view style="padding-bottom: 20rpx;">
<view style="float: left; font-size: 32rpx; color: #333; font-weight: 400;">{{$t('putforward.text7')}}</view>
<view style="float: right; font-size: 28rpx; color: #333; font-weight: 400;" @click="onPageJump('/pages/wallet/switchnetwork')">
<image style="width: 36rpx; height: 36rpx; float: left;" v-if="network=='TRC-20'" src="/static/images/s1.png" mode="cover"></image>
<span style="margin-left: 20rpx; float: left;" v-if="network=='TRC-20'">Tron(TRC20)</span>
<image style="width: 36rpx; height: 36rpx; float: left;" v-if="network=='BEP-20'" src="/static/images/s2.png" mode="cover"></image>
<span style="margin-left: 20rpx; float: left;" v-if="network=='BEP-20'">BSC-BNB(BEP20)</span>
<uni-icons size="20" type="down" style=" margin-left: 20rpx;"></uni-icons>
2025-06-06 03:08:19 +08:00
</view>
<view style="clear: both;"></view>
</view>
<view>
2025-06-07 23:12:35 +08:00
<uni-easyinput type="text" v-model="putmodel.address" :placeholder="$t('putforward.text8')">
2025-06-06 03:08:19 +08:00
<template #right>
<picker :range="formattedItems" mode="selector" @change="onPickerChange">
2025-06-09 00:34:46 +08:00
<image src="/static/images/5.png" style="float: left; width: 40rpx; height: 40rpx; margin-right: 20rpx;"></image>
2025-06-06 03:08:19 +08:00
</picker>
</template>
</uni-easyinput>
</view>
</uni-forms-item>
2025-06-07 23:12:35 +08:00
<uni-forms-item :label="$t('putforward.text9')" labelWidth="400rpx" name="amount">
2025-06-06 03:08:19 +08:00
<view>
2025-06-07 23:12:35 +08:00
<uni-easyinput type="number" v-model="putmodel.amount" :placeholder="$t('putforward.text10', {par: withdrawlminimum})">
2025-06-06 03:08:19 +08:00
<template #right>
2025-06-10 00:51:49 +08:00
<view style="float: left; font-size: 24rpx;">USDT</view>
2025-06-06 03:08:19 +08:00
<view style="margin:20rpx; float: right;">
<span class="s" @click="max">Max</span></view>
</template>
</uni-easyinput>
</view>
2025-06-10 00:51:49 +08:00
<view style="font-size: 28rpx; color: #999; font-weight: 500; line-height: 50upx;">{{$t('putforward.text11')}}
2025-06-09 00:34:46 +08:00
<span style="color: #1D61E7;">{{parseFloat(user.money).toFixed(2)}} USDT</span></view>
2025-06-06 03:08:19 +08:00
</uni-forms-item>
<uni-forms-item label="PIN code" name="pincode">
2025-06-07 23:12:35 +08:00
<uni-easyinput type="password" :passwordIcon="true" v-model="putmodel.pincode" :placeholder="$t('putforward.text12')" />
2025-06-06 03:08:19 +08:00
</uni-forms-item>
</uni-forms>
</view>
2025-06-10 00:51:49 +08:00
<view style="bottom: 0rpx; position: absolute; width:100vw; height: 360rpx;">
2025-06-06 03:08:19 +08:00
<view class="cell_list">
2025-06-07 23:12:35 +08:00
<view class="cell_left txt">{{$t('putforward.text13')}}</view>
2025-06-09 00:34:46 +08:00
<view class="cell_right " v-if="showCosts">{{costs}} USDT</view>
<view class="cell_right " v-else>0 USDT</view>
2025-06-06 03:08:19 +08:00
</view>
<view class="cell_list">
2025-06-07 23:12:35 +08:00
<view class="cell_left txt">{{$t('putforward.text14')}}</view>
2025-06-10 00:51:49 +08:00
<view class="cell_right" style="font-size: 36rpx; font-weight: 600;">{{totalAmount}} USDT</view>
2025-06-06 03:08:19 +08:00
</view>
<view class="cell_list">
2025-06-07 23:12:35 +08:00
<button type="primary" round style="width: 100%;" @click="submit">{{$t('buttonSubmit')}}</button>
2025-06-06 03:08:19 +08:00
</view>
</view>
</view>
</template>
<script>
import { getUserInfo } from '@/config/utils';
import {
mapState,
mapMutations
} from 'vuex';
export default {
data() {
return {
network:'TRC-20',
2025-06-09 00:34:46 +08:00
showCosts: false,
2025-06-06 03:08:19 +08:00
costs: 0.00,
totalAmount: 0.00,
withdrawlminimum: 1,
putmodel: {
address: '',
addressId: '',
amount: '',
pincode: '',
},
init:{},
user:{},
addressList: [],
rules: {
address: {
rules:[{required: true,errorMessage: this.$t('putforward.text1')}],
},
amount:{
rules:[
{required: true,errorMessage: this.$t('putforward.text2')},
// {validateFunction:function(rule, value, data, callback){
// if (parseFloat(value) < parseFloat(_this.init.withdrawl_minimum[_this.network])) {
// callback(Error(_this.$t('putforward.text3', {par: _this.init.withdrawl_minimum[_this.network]})))
// }
// return;
// }}
],
},
pincode:{
rules:[ {required: true,errorMessage: this.$t('putforward.text5')},
{minLength: 6, maxLength: 6, errorMessage: this.$t('putforward.text6'), }
],
}
},
};
},
computed: {
...mapState(['userInfo']),
formattedItems() {
return this.addressList.map(item => `${item.title} (${item.network})`);
}
},
watch: {
'putmodel.amount'(newVal, oldVal) {
2025-06-09 00:34:46 +08:00
if(newVal != ''){
this.showCosts = true;
}else{
this.showCosts = false;
}
this.totalAmount = parseFloat(newVal == '' ? 0 : newVal) - parseFloat(this.costs);
if(this.totalAmount < 0){
this.totalAmount = 0;
}
2025-06-06 03:08:19 +08:00
}
},
//第一次加载
2025-06-09 00:34:46 +08:00
onLoad(e) {
uni.showLoading({
title: this.$t('loading')
});
2025-06-06 03:08:19 +08:00
this.$http.get('/api/common/init?lang='+this.$i18n.locale).then(res => {
this.init = res.data;
if(e.network != typeof(undefined) && e.network != undefined){
if(e.network != this.neetwork){
this.network=e.network;
}
};
this.costs = this.init.withdrawl_fee[this.network];
this.withdrawlminimum = this.init.withdrawl_minimum[this.network];
2025-06-09 00:34:46 +08:00
//this.totalAmount = parseFloat(this.putmodel.amount == '' ? 0 : this.putmodel.amount) + parseFloat(this.costs);
2025-06-06 03:08:19 +08:00
let data = {
lang: this.$i18n.locale,
network: this.network,
page: 1,
limit: 100
};
this.$http.post('/api/address/list', data).then(res => {
if(res.code == 0){
this.addressList = res.data.data;
}
2025-06-09 00:34:46 +08:00
uni.hideLoading();
}).catch(err => {
uni.hideLoading();
2025-06-06 03:08:19 +08:00
});
});
2025-06-09 00:34:46 +08:00
getUserInfo(this.$i18n.locale).then(res => {
this.user = res;
});
2025-06-06 03:08:19 +08:00
this.user.money = parseFloat(this.user.money).toFixed(4);
},
//页面显示
onShow() {},
//方法
methods: {
...mapMutations(['setUserInfo']),
max(){
2025-06-09 00:34:46 +08:00
this.putmodel.amount = parseFloat(this.user.money) ;
2025-06-06 03:08:19 +08:00
},
2025-06-10 00:51:49 +08:00
goto(url, type) {
if (type == 2) {
return uni.switchTab({ url: url })
}
if (type == 1) {
return uni.navigateBack({ delta: url });
}
uni.navigateTo({
url: url
})
},
2025-06-06 03:08:19 +08:00
onPickerChange(e) {
let address = this.addressList[e.detail.value];
this.putmodel.address = address.address;
this.putmodel.addressId = address.id;
},
onPageJump(url) {
uni.navigateTo({
url: url.indexOf('switchnetwork') > 0 ? url + "?network="+this.network+"&page=putforward" : url+"?page=putforward"
});
},
onTokenJump(url) {
this.judgeLogin(() => {
uni.navigateTo({
url: url
});
});
},
submit(form){
if (parseFloat(this.putmodel.amount) < parseFloat(this.withdrawlminimum)) {
uni.showToast({
icon: 'error',
title:this.$t('putforward.text3', {par: this.withdrawlminimum})
});
return;
}
2025-06-09 00:34:46 +08:00
if (parseFloat(this.putmodel.amount) > parseFloat(this.user.money)){
uni.showToast({
icon: 'error',
title:this.$t('putforward.text4')
});
return;
}
if (parseFloat(this.putmodel.amount) <= this.costs){
2025-06-06 03:08:19 +08:00
uni.showToast({
icon: 'error',
title:this.$t('putforward.text4')
});
return;
}
this.$refs.form.validate().then(res=>{
var data = {
2025-06-09 00:34:46 +08:00
amount: this.putmodel.amount,
2025-06-06 03:08:19 +08:00
address_id: this.putmodel.addressId,
trade_password: this.putmodel.pincode,
lang: this.$i18n.locale
};
this.$http.post('/api/withdrawl/create', data).then(res => {
if(res.code == 0){
uni.showToast({
title: res.msg
});
this.putmodel= {
address: '',
addressId: '',
amount: '',
pincode: '',
}
setTimeout(() => {
uni.navigateTo({
url: '/pages/wallet/ExtractResults?id='+res.data.id
});
}, 1000);
}
});
}).catch(err =>{})
}
},
//页面隐藏
onHide() {},
//页面卸载
onUnload() {},
//页面下来刷新
onPullDownRefresh() {},
//页面上拉触底
onReachBottom() {},
//用户点击分享
onShareAppMessage(e) {
return this.wxShare();
}
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
body{background-color: #fff;}
.page{min-height: 96vh;position: relative;}
.rechargeTitle{
2025-06-10 00:51:49 +08:00
font-weight: 400;font-size: 32rpx;color: #999999;line-height: 46rpx; text-align: center; margin-top: 60rpx;
2025-06-06 03:08:19 +08:00
}
.rechargeNet{
2025-06-10 00:51:49 +08:00
font-weight: 600;font-size: 40rpx;color: #333;line-height: 46rpx; text-align: center; margin-top: 40rpx;
2025-06-06 03:08:19 +08:00
}
.txt{
2025-06-10 00:51:49 +08:00
font-size: 28rpx; color:#999; font-weight: 500;
2025-06-06 03:08:19 +08:00
}
.cell_right{
2025-06-10 00:51:49 +08:00
font-size: 28rpx; color:#333; font-weight: 500;
2025-06-06 03:08:19 +08:00
}
.s{
2025-06-10 00:51:49 +08:00
border-radius: 20rpx; border: 2rpx solid #1D61E7; padding: 4rpx 16rpx; color: #1D61E7; font-size: 28rpx; font-weight: 600;
2025-06-06 03:08:19 +08:00
}
</style>