question_uniapp/pages/wallet/putforward.vue

249 lines
8.2 KiB
Vue
Raw Normal View History

2025-06-06 03:08:19 +08:00
<template>
<view class="page">
2025-06-07 23:12:35 +08:00
<nav-bar :title="$t('putforward.title')" bgColor="#fff">
2025-06-06 03:08:19 +08:00
<image slot="right" style="width: 40rpx; height: 40rpx; margin-right: 20px;" src="/static/images/r2.png" mode="cover" @click="onTokenJump('/pages/wallet/fundrecords?id=3')"></image>
</nav-bar>
<view style="width: 92%; margin: 10px auto; padding: 15px 10px;">
<uni-forms :modelValue="putmodel" label-position="top" :rules="rules" ref="form">
<uni-forms-item name="address">
<view style="padding-bottom: 10px;">
2025-06-07 23:12:35 +08:00
<view style="float: left; font-size: 16px; color: #333; font-weight: 400;">{{$t('putforward.text7')}}</view>
2025-06-06 03:08:19 +08:00
<view style="float: right; font-size: 14px; color: #333; font-weight: 400;" @click="onPageJump('/pages/wallet/switchnetwork')">
<image style="width: 18px; height: 18px; float: left;" v-if="network=='TRC-20'" src="/static/images/s1.png" mode="cover"></image>
<span style="margin-left: 10px; float: left;" v-if="network=='TRC-20'">Tron(TRC20)</span>
<image style="width: 18px; height: 18px; float: left;" v-if="network=='BEP-20'" src="/static/images/s2.png" mode="cover"></image>
<span style="margin-left: 10px; float: left;" v-if="network=='BEP-20'">BSC-BNB(BEP20)</span>
<uni-icons size="20" type="down" style=" margin-left: 10px;"></uni-icons>
</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">
<image src="/static/images/r4.png" style="float: left; width: 40rpx; height: 40rpx; margin-right: 20rpx;"></image>
</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>
<view style="float: left; font-size: 12px;">USDT</view>
<view style="margin:20rpx; float: right;">
<span class="s" @click="max">Max</span></view>
</template>
</uni-easyinput>
</view>
2025-06-07 23:12:35 +08:00
<view style="font-size: 14px; color: #999; font-weight: 500; line-height: 50upx;">{{$t('putforward.text11')}}
2025-06-06 03:08:19 +08:00
<span style="color: #1D61E7;">{{user.money }} USDT</span></view>
</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>
<view style="bottom: 0px; position: absolute; width:100vw; height: 180px;">
<view class="cell_list">
2025-06-07 23:12:35 +08:00
<view class="cell_left txt">{{$t('putforward.text13')}}</view>
2025-06-06 03:08:19 +08:00
<view class="cell_right ">{{costs}} USDT</view>
</view>
<view class="cell_list">
2025-06-07 23:12:35 +08:00
<view class="cell_left txt">{{$t('putforward.text14')}}</view>
2025-06-06 03:08:19 +08:00
<view class="cell_right" style="font-size: 18px; font-weight: 600;">{{totalAmount}} USDT</view>
</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',
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) {
this.totalAmount = parseFloat(newVal == '' ? 0 : newVal) + parseFloat(this.costs);
}
},
//第一次加载
2025-06-07 23:12:35 +08:00
async onLoad(e) {
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];
this.totalAmount = parseFloat(this.putmodel.amount == '' ? 0 : this.putmodel.amount) + parseFloat(this.costs);
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;
}
});
});
this.user = await getUserInfo(this.$i18n.locale);
this.user.money = parseFloat(this.user.money).toFixed(4);
},
//页面显示
onShow() {},
//方法
methods: {
...mapMutations(['setUserInfo']),
max(){
let money = (parseFloat(this.user.money) - parseFloat(this.costs));
this.putmodel.amount = money < 0 ? 0 : money;
},
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;
}
if (parseFloat(this.putmodel.amount)+parseFloat(this.costs) > parseFloat(this.user.money)){
uni.showToast({
icon: 'error',
title:this.$t('putforward.text4')
});
return;
}
this.$refs.form.validate().then(res=>{
var data = {
amount: this.totalAmount,
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{
font-weight: 400;font-size: 16px;color: #999999;line-height: 23px; text-align: center; margin-top: 30px;
}
.rechargeNet{
font-weight: 600;font-size: 20px;color: #333;line-height: 23px; text-align: center; margin-top: 20px;
}
.txt{
font-size: 14px; color:#999; font-weight: 500;
}
.cell_right{
font-size: 14px; color:#333; font-weight: 500;
}
.s{
border-radius: 10px; border: 1px solid #1D61E7; padding: 2px 8px; color: #1D61E7; font-size: 28rpx; font-weight: 600;
}
</style>