feat: 优化代码

This commit is contained in:
2025-08-06 20:25:41 +08:00
parent 5f7d0ceb79
commit 73823c50fd
1179 changed files with 42944 additions and 189654 deletions
File diff suppressed because one or more lines are too long
+186
View File
@@ -0,0 +1,186 @@
<template>
<view class="rwa_add_warp">
<Header leftTitle="注册交易所账户" left-path-type="navigateTo" left-path="/pages/rwa_package/rwa/rwa" />
<view class="rwa_add_content">
<view class="rwa_add_form">
<view class="rwa_add_item">
<view class="rwa_add_item_title">交易所名称,示例值(ALPHACEX)</view>
<up-input placeholder="请输入交易所名称" border="surround" v-model="form.name" :customStyle="inputCss"
disabled></up-input>
</view>
<view class="rwa_add_item">
<view class="rwa_add_item_title">输入邮箱</view>
<up-input placeholder="请输入邮箱账户" border="surround" v-model="form.email" :customStyle="inputCss"
disabled></up-input>
</view>
<view class="rwa_add_item">
<view class="rwa_add_item_title">验证码</view>
<up-input placeholder="请输入邮箱验证码" border="surround" v-model="form.emailCode" :customStyle="inputCss">
<template #suffix style="margin-right: 10rpx;">
<view v-if="countdown" class="code-warp">
<up-count-down :time="60 * 1000" format="ss" @finish="countdown = false"></up-count-down>
<text style="margin-left: 10rpx;">s</text>
</view>
<view v-else @click="getMobileCode" class="code_msg">
获取验证码
</view>
</template>
</up-input>
</view>
<view class="rwa_add_item">
<view class="rwa_add_item_title">登录密码</view>
<up-input placeholder="请输入登录密码" border="surround" v-model="form.password" :customStyle="inputCss"></up-input>
<view class="rwa_add_item_msg">注:密码只能8-20位,数字+英文组合</view>
</view>
</view>
<view class="add_but_css" @click="addRwa">
创建
</view>
</view>
<up-toast ref="uToastRef"></up-toast>
</view>
</template>
<script>
import Header from '@/components/header.vue';
import { registerExchUser, sentEmailCode } from '@/api/finance.js';
import { SMS_TYPE } from '@/utils/enumUtils.js';
export default {
components: { Header },
data() {
return {
inputCss: {
"height": '80rpx',
"background": "#F5F5F5",
"border-radius": "20rpx",
"border": "0rpx",
"padding-left": "16px",
},
form: {
email: null,
emailCode: null,
password: null,
name: null,
},
countdown: false,// 清空倒计时
};
},
onLoad(option) {
const email = option.email;
if (email) {
this.form.email = email;
}
const name = option.name;
if (name) {
this.form.name = name;
}
},
methods: {
async addRwa() {
const params = this.form;
if (!params.emailCode) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入邮箱账户验证码",
});
return;
}
if (!params.password) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入登录密码",
});
return;
} else {
const regex = /^[a-zA-Z0-9]{8,20}$/;
if (!regex.test(params.password)) {
this.$refs.uToastRef.show({
type: 'error',
message: "登录密码只能8-20位,数字+英文组合",
});
return;
}
}
const resp = await registerExchUser(params);
if (resp.bizcode === 100) {
this.$refs.uToastRef.show({
type: 'success',
message: "添加成功",
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/rwa_package/rwa/rwa',
})
}, 2000)
}
},
/**
* 获取手机验证码
*/
async getMobileCode() {
const form = this.form;
if (!form.email) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入账号",
});
return;
}
this.countdown = true;
const params = {
email: form.email,
}
const response = await sentEmailCode(params);
console.log("responseresponseresponse", response);
if (response && response.bizcode === 100) {
this.$refs.uToastRef.show({
type: 'success',
message: response.msg,
});
} else {
this.countdown = false;
}
},
}
}
</script>
<style lang="less">
.rwa_add_warp {
background: #F5F5F5;
.rwa_add_content {
padding: 20rpx;
height: calc(100vh - 198rpx);
}
.rwa_add_form {
background: #FFFFFF;
border-radius: 24rpx;
padding: 30rpx;
margin-bottom: 60rpx;
.rwa_add_item {
margin-bottom: 20rpx;
.rwa_add_item_title {
margin-bottom: 10rpx;
font-weight: bold;
font-size: 30rpx;
color: #333333;
}
.rwa_add_item_msg {
font-size: 20rpx;
margin-top: 10rpx;
color: red;
}
}
}
}
</style>
@@ -0,0 +1,146 @@
<template>
<view class="rwa_add_warp">
<Header leftTitle="绑定交易所账户" left-path-type="navigateTo" left-path="/pages/rwa_package/rwa/rwa" />
<view class="rwa_add_content">
<view class="rwa_add_form">
<view class="rwa_add_item">
<view class="rwa_add_item_title">交易所名称,示例值(ALPHACEX)</view>
<up-input placeholder="请输入交易所名称" border="surround" v-model="form.name" :customStyle="inputCss"
disabled></up-input>
</view>
<view class="rwa_add_item">
<view class="rwa_add_item_title">输入邮箱</view>
<up-input placeholder="请输入邮箱账户" border="surround" v-model="form.email" :customStyle="inputCss"></up-input>
</view>
</view>
<view class="add_but_css" @click="bindingRwa">
绑定
</view>
</view>
<up-toast ref="uToastRef"></up-toast>
</view>
</template>
<script>
import Header from '@/components/header.vue';
import { bindExchUsers } from '@/api/finance.js';
import { getUserList } from '@/api/common.js';
import { SMS_TYPE } from '@/utils/enumUtils.js';
export default {
components: { Header },
data() {
return {
inputCss: {
"height": '80rpx',
"background": "#F5F5F5",
"border-radius": "20rpx",
"border": "0rpx",
"padding-left": "16px",
},
form: {
name: "ALPHACEX",
email: '',
},
countdown: false,// 清空倒计时
};
},
methods: {
async bindingRwa() {
const params = this.form;
if (!params.email) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入邮箱账户",
});
return;
}
const resp = await bindExchUsers(params);
if (resp.bizcode === 100) {
const data = resp.data;
if (data && data.status === 0) {
this.$refs.uToastRef.show({
type: 'success',
message: "绑定成功",
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/rwa_package/rwa/rwa',
})
}, 2000)
} else {
this.$refs.uToastRef.show({
type: 'error',
message: "账号不存在,立即前往注册页面",
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/rwa_package/rwa_add/rwa_add?email=' + params.email + "&name=" + params.name,
})
}, 2000)
}
}
},
/**
* 获取手机验证码
*/
async getMobileCode() {
const form = this.form;
if (!form.name) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入账号",
});
return;
}
this.countdown = true;
const params = {
mobile: form.name,
type: SMS_TYPE.LOGIN,
}
const response = await getUserList(params);
console.log("responseresponseresponse", response);
if (response && response.bizcode === 100) {
this.$refs.uToastRef.show({
type: 'success',
message: response.msg,
});
} else {
this.countdown = false;
}
},
}
}
</script>
<style lang="less">
.rwa_add_warp {
background: #F5F5F5;
.rwa_add_content {
padding: 20rpx;
height: calc(100vh - 198rpx);
}
.rwa_add_form {
background: #FFFFFF;
border-radius: 24rpx;
padding: 30rpx;
margin-bottom: 60rpx;
.rwa_add_item {
margin-bottom: 30rpx;
.rwa_add_item_title {
margin-bottom: 20rpx;
font-weight: bold;
font-size: 30rpx;
color: #333333;
}
}
}
}
</style>
@@ -0,0 +1,244 @@
<template>
<view class="rwa_withdrawal">
<Header leftTitle="提现" left-path-type="navigateTo" left-path="/pages/rwa_package/rwa/rwa" rightTitle="记录"
rightPath="/pages/rwa_package/rwa_withdrawal_log/rwa_withdrawal_log?back=withdrawal" rightPathType="navigateTo" />
<view class="rwa_withdrawal_content">
<view class="_content">
<view class="_content_usdt">
<view>{{ categotyObj.name || 'USDT' }}</view>
<view>{{ categotyObj.curAmount || 0 }}</view>
</view>
<view class="_content_item">
<view class="_content_item_title">提现金额</view>
<up-input placeholder="请输入提现金额" border="surround" v-model="form.amount" :customStyle="inputCss"></up-input>
<view class="_content_item_msg">当前可提现余额 {{ categotyObj.curAmount || 0 }} {{ categotyObj.name || 'USDT' }}
</view>
</view>
<view class="_content_item" @click="accountShowCheck(true)">
<view class="_content_item_title">提现账户</view>
<view class="_content_item_account">
<view v-if="accountName">{{ accountName }}</view>
<view v-else style="color: #30313363;">请选择提现账户</view>
<up-image src="/static/common/right.png" width="20" height="20" bgColor="#f1f6ff00" />
</view>
</view>
<view class="_content_item">
<view class="_content_item_title">交易密码<text class="_content_item_setting_pwd"
@click="jumpSettingPwd">(前往设置交易密码)</text></view>
<up-input placeholder="请输入交易密码" border="surround" v-model="form.password" :customStyle="inputCss"></up-input>
</view>
<view class="_content_item">
<view class="_content_item_title">备注</view>
<up-input placeholder="请输入备注(可选)" border="surround" v-model="form.remark" :customStyle="inputCss"></up-input>
</view>
</view>
<view class="add_but_css" @click="addWithdrawal">
提交
</view>
</view>
<up-picker :show="accountShow" :columns="accountOption" keyName="account" itemHeight="34" @confirm="accountConfirm"
:loading="accountLoading" @close="accountShowCheck(false)" @cancel="accountShowCheck(false)"></up-picker>
<up-toast ref="uToastRef"></up-toast>
</view>
</template>
<script>
import Header from '@/components/header.vue';
import { getSupportBank } from '@/api/common.js';
import { getAcctBalance, exchTransfer, getExchUsers } from '@/api/finance.js';
export default {
components: { Header },
data() {
return {
categotyObj: {},// 可提现金额
inputCss: {
"height": '80rpx',
"background": "#F5F5F5",
"border-radius": "20rpx",
"border": "0rpx",
"padding-left": "16px",
},
form: {
category: "vcoin",
amount: '',
password: '',
acctId: '',
remark: '',
},
accountName: null,
accountShow: false,
accountOption: [],
accountLoading: false,
};
},
onShow() {
this.getAcctBalance();
},
methods: {
// 查询余额
async getAcctBalance() {
const resp = await getAcctBalance();
let data = {};
if (resp && resp.bizcode === 100) {
if (resp.data) {
resp.data.map(item => {
// 交易币
if (item.categoty === "vcoin") {
data = item;
}
})
}
}
this.categotyObj = data;
},
async addWithdrawal() {
const params = this.form;
if (!params.amount) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入提现金额",
});
return;
}
if (!params.acctId) {
this.$refs.uToastRef.show({
type: 'error',
message: "请选择提现账户",
});
return;
}
if (!params.password) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入交易密码",
});
return;
}
console.log("params", params);
const resp = await exchTransfer(params);
if (resp && resp.bizcode === 100) {
this.$refs.uToastRef.show({
type: 'success',
message: "提交成功",
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/rwa_package/rwa/rwa',
})
}, 2000)
}
},
// 选择账户的弹框
async accountShowCheck(status) {
if (status) {
this.accountLoading = true;
const params = {
page: 1,
pageSize: 99,
}
const resp = await getExchUsers(params);
if (resp && resp.bizcode === 100) {
this.accountOption = [resp.data.entitys] || [];
}
this.accountLoading = false;
} else {
this.accountOption = [[]];
}
this.accountShow = status;
},
// 提交
accountConfirm(e) {
const {
columnIndex,
value,
values,
index,
} = e;
if (!value || value.length === 0) {
this.$refs.uToastRef.show({
type: 'error',
message: "请先选择账户",
});
return;
}
const data = value[0];
this.form.acctId = data.id;
this.accountName = data.account;
this.accountShowCheck(false);
},
// 设置交易密码
jumpSettingPwd() {
uni.navigateTo({
url: '/pages/mine/mine_transaction_password/mine_transaction_password',
})
}
}
}
</script>
<style lang="scss">
.rwa_withdrawal {
background: #F5F5F5;
.rwa_withdrawal_content {
padding: 20rpx;
height: calc(100vh - 198rpx);
._content {
padding: 30rpx;
background: #FFFFFF;
border-radius: 24rpx;
margin-bottom: 60rpx;
._content_usdt {
display: flex;
justify-content: space-between;
font-weight: bold;
font-size: 30rpx;
color: #333333;
border-bottom: 2rpx solid #EEEEEE;
padding: 0 0 20rpx;
}
._content_item {
margin-top: 30rpx;
._content_item_title {
margin-bottom: 20rpx;
font-weight: bold;
font-size: 30rpx;
color: #333333;
}
._content_item_setting_pwd {
color: $app-zt-color;
cursor: pointer;
text-decoration: underline;
font-size: 26rpx;
margin-left: 10rpx;
}
._content_item_msg {
font-weight: 500;
font-size: 24rpx;
color: #808080;
margin-top: 16rpx;
}
._content_item_account {
display: flex;
justify-content: space-between;
align-items: center;
background: #F8F8F8;
border-radius: 20rpx;
padding: 30rpx 20rpx;
font-weight: 500;
font-size: 28rpx;
color: #333333;
}
}
}
}
}
</style>
@@ -0,0 +1,215 @@
<template>
<view class="rwa_withdrawal_log">
<Header leftTitle="提现记录" left-path-type="navigateTo" :leftPath="leftPath" />
<view class="_log_content">
<view class="_log_content_title">
<view>提现账户邮箱/时间</view>
<view>金额/状态</view>
</view>
<scroll-view scroll-y="true" @scrolltolower="loadMore" style="height:calc(100vh - 300rpx)">
<view class="_content_item" v-for="item in logList" :key="item.id" v-if="logList && logList.length !== 0">
<view class="_content_item_no _content_item_no_buto">NO.{{ item.tradeNo }}</view>
<!-- <view class="_content_item_no _content_item_no_buto" v-if="item.exchNo">交易所流水号:{{item.exchNo}}</view> -->
<view class="_content_item_but">
<view class="_content_item_left">
<up-image src="/static/rwa/account.png" width="40" height="40" bgColor="#f1f6ff00" />
<view class="_content_item_left_">
<view class="_content_item_left_title">{{ item.name }}-{{ item.account }}</view>
<view class="_content_item_left_val">{{ formatDate(item.ctdate) }}</view>
</view>
</view>
<view class="_content_item_right">
<view class="_content_item_left_title _content_item_left_amount">{{ item.amount }} {{ categotyObj.name ||
'USDT'}}</view>
<view class="_content_item_left_status">{{ getValue(RWA_STATUS, item.status) }}</view>
</view>
</view>
</view>
<view v-else class="not_order_warp">
<up-image src="/static/rwa/kzt.png" width="100" height="100" bgColor="#f1f6ff00"></up-image>
<view class="not_order_msg_warp">暂无提现数据~</view>
</view>
<view v-if="loading" style="text-align: center;">加载中...</view>
</scroll-view>
</view>
</view>
</template>
<script>
import Header from '@/components/header.vue';
import { getExchTransferRecord, getAcctBalance } from '@/api/finance.js'
import { formatDate } from '@/utils/index.js';
import { RWA_STATUS, getValue } from '@/utils/enumUtils.js';
export default {
components: { Header },
computed: {
RWA_STATUS() {
return RWA_STATUS;
}
},
data() {
return {
leftPath: "/pages/rwa_package/rwa_withdrawal/rwa_withdrawal",
logList: [],
form: {
page: 1,
pageSize: 10,
},
loading: false,
categotyObj: {},
};
},
onLoad(option) {
const back = option.back;
if (back === "rwa") {
this.leftPath = "/pages/rwa_package/rwa/rwa"
}
if (back === "withdrawal") {
this.leftPath = "/pages/rwa_package/rwa_withdrawal/rwa_withdrawal"
}
this.loadData();
this.getAcctBalance();
},
methods: {
getValue,
formatDate,
// 查询余额
async getAcctBalance() {
const resp = await getAcctBalance();
let data = {};
if (resp && resp.bizcode === 100) {
if (resp.data) {
resp.data.map(item => {
// 交易币
if (item.categoty === "vcoin") {
data = item;
}
})
}
}
this.categotyObj = data;
},
// 加载数据的方法
async loadData() {
if (this.loading) return; // 如果正在加载,则不重复加载
this.loading = true; // 设置加载状态为true
try {
// 模拟异步获取数据,实际应用中应该替换为你的数据获取逻辑,例如API调用
const newData = await this.fetchData(this.form.page, this.form.pageSize);
this.logList = [...this.logList, ...newData]; // 将新数据添加到列表中
this.form.page++; // 页码加1
} catch (error) {
console.error('加载数据失败:', error);
} finally {
this.loading = false; // 设置加载状态为false
}
},
// 模拟获取数据的方法,实际应用中应该替换为你的数据获取逻辑,例如从服务器获取数据
async fetchData(page, pageSize) {
const params = {
page,
pageSize,
}
console.log("params", params);
const resp = await getExchTransferRecord(params);
console.log("resp", resp);
if (resp && resp.bizcode === 100) {
const data = resp.data && resp.data.entitys || [];
return data
} else {
return [];
}
},
// 当滚动到底部时触发的方法
loadMore() {
this.loadData(); // 加载更多数据
}
}
}
</script>
<style lang="scss">
.rwa_withdrawal_log {
background: #F5F5F5;
height: calc(100vh - 0rpx);
overflow: hidden;
._log_content {
height: calc(100vh - 216rpx);
padding: 30rpx;
._log_content_title {
display: flex;
justify-content: space-between;
align-items: center;
font-weight: 500;
font-size: 28rpx;
color: #666666;
margin-bottom: 20rpx;
}
._content_item {
margin-bottom: 20rpx;
background: #FFFFFF;
border-radius: 20rpx;
padding: 20rpx;
._content_item_no {
padding: 0 0 20rpx 0;
text-align: right;
font-size: 20rpx;
}
._content_item_no_buto {
border-bottom: 1rpx solid #EEEEEE;
}
._content_item_but {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20rpx;
}
._content_item_left {
display: flex;
align-items: center;
}
._content_item_left_ {
margin-left: 10rpx;
}
._content_item_left_title {
font-weight: bold;
font-size: 22rpx;
color: #000000;
margin-bottom: 10rpx;
}
._content_item_left_amount {
text-align: right;
}
._content_item_left_exchNo {
font-size: 20rpx;
color: #9E9E9E;
margin-bottom: 10rpx;
}
._content_item_left_val {
font-weight: 400;
font-size: 24rpx;
color: #999999;
}
._content_item_left_status {
font-weight: 400;
font-size: 20rpx;
text-align: right;
}
}
}
}
</style>