202 lines
5.7 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('transfer.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=4')"></image>
</nav-bar>
<view style="width: 92%; margin: 10px auto; padding: 15px 10px;">
<uni-forms :modelValue="transferModel" label-position="top" :rules="rules" ref="form">
2025-06-07 23:12:35 +08:00
<uni-forms-item :label="$t('transfer.text7')" name="email" labelWidth="400rpx">
<uni-combox :candidates="formattedItems" :placeholder="$t('transfer.text8')" v-model="transferModel.email"></uni-combox>
2025-06-06 03:08:19 +08:00
</uni-forms-item>
2025-06-07 23:12:35 +08:00
<uni-forms-item :label="$t('transfer.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="transferModel.amount" :placeholder="$t('transfer.text10')">
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; margin-top: 10rpx;">{{$t('transfer.text11')}}
2025-06-06 03:08:19 +08:00
<span style="color: #1D61E7;">{{user.money }} USDT</span></view>
</uni-forms-item>
2025-06-07 23:12:35 +08:00
<uni-forms-item :label="$t('transfer.text3')" name="pincode">
<uni-easyinput type="password" :passwordIcon="true" v-model="transferModel.pincode" :placeholder="$t('transfer.text5')" />
2025-06-06 03:08:19 +08:00
</uni-forms-item>
</uni-forms>
</view>
<view style="bottom: 0px; position: absolute; width:100vw; height: 150px;">
<view class="cell_list">
2025-06-07 23:12:35 +08:00
<view class="cell_left txt">{{$t('transfer.text12')}}</view>
2025-06-06 03:08:19 +08:00
<view class="cell_right" style="font-size: 18px; font-weight: 600;">{{transferModel.amount}} 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 {
mapState,
mapMutations
} from 'vuex';
export default {
data() {
return {
productNameStr: '',
network:'TRC-20',
transferModel:{
email:"",
amount: '',
pincode:"",
},
init:{},
user:{},
rules: {
email: {
rules:[{required: true,errorMessage: this.$t('transfer.text1')}],
},
amount:{
rules:[
{required: true,errorMessage: this.$t('transfer.text2')}],
},
pincode:{
rules:[ {required: true,errorMessage: this.$t('transfer.text5')},
{minLength: 6, maxLength: 6, errorMessage: this.$t('transfer.text6'), }
],
}
},
candidates:[]
};
},
computed: {
...mapState(['userInfo']),
formattedItems() {
return this.candidates.map(item => item.username);
}
},
watch: {
'transferModel.email'(newVal, oldVal) {
let data = {
kw: this.transferModel.email,
lang: this.$i18n.locale,
};
this.$http.get('/api/user/getuserlist', data).then(res => {
if(res.code == 0){
this.candidates = res.data;
}
});
}
},
//第一次加载
onLoad(e) {
this.$http.get('/api/common/init?lang='+this.$i18n.locale).then(res => {
this.init = res.data;
});
this.$http.get('/api/user/profile?nickname='+this.userInfo.nickname+'&lang='+this.$i18n.locale).then(res => {
if(res.code == 0){
this.user = res.data;
this.user.money = parseFloat(this.user.money).toFixed(4);
this.setUserInfo(res.data);
}
});
let data = {
kw: this.transferModel.email,
lang: this.$i18n.locale,
};
this.$http.get('/api/user/getuserlist', data).then(res => {
if(res.code == 0){
this.candidates = res.data;
}
});
},
//页面显示
onShow() {},
//方法
methods: {
...mapMutations(['setUserInfo']),
max(){
this.transferModel.amount = parseFloat(this.user.money == '' ? 0 : this.user.money);
},
onPageJump(url) {
uni.navigateTo({
url: url
});
},
onTokenJump(url) {
this.judgeLogin(() => {
uni.navigateTo({
url: url
});
});
},
submit(form){
if (parseFloat(this.transferModel.amount) > parseFloat(this.user.money)){
uni.showToast({
icon: 'error',
title:this.$t('putforward.text4')
});
return;
}
this.$refs.form.validate().then(res=>{
var data = {
username: this.transferModel.email,
amount: this.transferModel.amount,
trade_password: this.transferModel.pincode,
lang: this.$i18n.locale
};
this.$http.get('/api/user/user_transfer', data).then(res => {
if(res.code == 0){
uni.showToast({
title: res.msg
});
this.transferModel={
email:"",
amount: '',
pincode:"",
};
}
});
}).catch(err =>{console.log(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: 100vh;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>