235 lines
6.7 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"
2025-06-10 17:10:40 +08:00
:title="$t('transfer.title')" backgroundColor="#fff" :statusBar="true">
2025-06-10 00:51:49 +08:00
<template v-slot:right>
<image style="width: 40rpx; height: 40rpx;" src="/static/images/r2.png" mode="cover" @click="onTokenJump('/pages/wallet/fundrecords?id=4')"></image>
</template>
</uni-nav-bar>
<view style="width: 94%; margin: 20rpx auto; padding: 30rpx 10rpx;">
2025-06-06 03:08:19 +08:00
<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>
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; 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>
2025-06-10 00:51:49 +08:00
<view style="bottom: 0rpx; position: absolute; width:100vw; height: 300rpx;">
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('transfer.text12')}}</view>
2025-06-10 00:51:49 +08:00
<view class="cell_right" style="font-size: 36rpx; font-weight: 600;">{{transferModel.amount}} 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 {
mapState,
mapMutations
} from 'vuex';
2025-06-10 00:51:49 +08:00
import { getUserInfo } from '@/config/utils';
2025-06-06 03:08:19 +08:00
export default {
data() {
return {
productNameStr: '',
network:'TRC-20',
2025-06-10 17:10:40 +08:00
isSubmitting: false,
2025-06-06 03:08:19 +08:00
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;
});
2025-06-10 00:51:49 +08:00
getUserInfo(this.$i18n.locale).then(res => {
this.user = res;
2025-06-06 03:08:19 +08:00
});
2025-06-10 00:51:49 +08:00
2025-06-06 03:08:19 +08:00
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);
},
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
onPageJump(url) {
uni.navigateTo({
url: url
});
},
onTokenJump(url) {
2025-06-10 17:10:40 +08:00
if(this.userInfo.token === typeof(undefined) || this.userInfo.token === undefined){
uni.showModal({
title: this.$t('gotoLogin.title'),
content: this.$t('gotoLogin.content'),
confirmText: this.$t('gotoLogin.login'),
cancelText: this.$t('gotoLogin.cancel'),
success: (res) => {
if (res.confirm) {
uni.navigateTo({
url: "/pages/mine/login"
});
}
}
});
}else{
2025-06-06 03:08:19 +08:00
uni.navigateTo({
url: url
});
2025-06-10 17:10:40 +08:00
}
2025-06-06 03:08:19 +08:00
},
submit(form){
2025-06-10 17:10:40 +08:00
if (this.isSubmitting) return; // 如果正在提交,则不执行任何操作
this.isSubmitting = true; // 设置正在提交的标志位为true
2025-06-06 03:08:19 +08:00
if (parseFloat(this.transferModel.amount) > parseFloat(this.user.money)){
uni.showToast({
icon: 'error',
title:this.$t('putforward.text4')
});
2025-06-10 17:10:40 +08:00
this.isSubmitting = false;
2025-06-06 03:08:19 +08:00
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:"",
};
2025-06-10 17:10:40 +08:00
this.isSubmitting = false;
}else{
this.isSubmitting = false;
2025-06-06 03:08:19 +08:00
}
});
2025-06-10 17:10:40 +08:00
}).catch(err =>{
this.isSubmitting = false;
})
2025-06-06 03:08:19 +08:00
}
},
//页面隐藏
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{
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>