From b4400036ffe65ecfe86dc34b08ba8ee19f8f1cf2 Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Mon, 30 Jun 2025 11:50:34 +0800
Subject: [PATCH] style 充值接口替换
---
src/components/constract/PerpetualContract/orderCom/amountSlider.vue | 78 +++++++++++++++++++++++++++++---------
1 files changed, 59 insertions(+), 19 deletions(-)
diff --git a/src/components/constract/PerpetualContract/orderCom/amountSlider.vue b/src/components/constract/PerpetualContract/orderCom/amountSlider.vue
index f4c0b21..506e359 100644
--- a/src/components/constract/PerpetualContract/orderCom/amountSlider.vue
+++ b/src/components/constract/PerpetualContract/orderCom/amountSlider.vue
@@ -12,7 +12,6 @@
v-model="amount"
step-strictly="true"
:min="0"
- :max="maxAmount"
@change="inputChange"
/>
@@ -87,6 +86,10 @@
type: Number,
default: 0,
},
+ initOpen: {
+ type: Object,
+ default: {},
+ },
},
data() {
return {
@@ -115,6 +118,12 @@
}, 2000);
}
},
+ unmounted() {
+ if (this.timer) {
+ clearInterval(this.timer);
+ this.timer = null;
+ }
+ },
computed: {
...mapState(useUserStore, ["existToken"]),
//保证金余额
@@ -130,10 +139,10 @@
const { total, money_wallet, money_contract, money_contract_profit } =
res.data;
this.totalAsset = total; //总资产
- this.walletMoney = bigDecimal.round(money_wallet, 6); //钱包余额
- this.profitLoss = bigDecimal.round(money_contract_profit, 6); //永续合约总未实现盈亏
- bus.emit("moneyContract", money_contract); //合约可用余额
- // bus.emit("moneyContract", this.walletMoney); //合约可用余额
+ this.walletMoney = bigDecimal.round(money_wallet, 2); //钱包余额
+ this.profitLoss = bigDecimal.round(money_contract_profit, 2); //永续合约总未实现盈亏
+ // bus.emit("moneyContract", money_contract); //合约可用余额
+ bus.emit("moneyContract", money_wallet); //合约可用余额
});
},
//输入框事件
@@ -147,21 +156,52 @@
//滑块事件
sliderAmountChange(val) {
let data;
- if (this.maxAmount) {
- if (val == 0) {
- this.amount = undefined;
- } else {
- const rate = val / 100; //如0.25
- data = this.maxAmount * rate;
- // if (this.lever_rate) {
- // data = math.format((this.maxAmount * rate), 2);
- // } else {
- // data = math.format((this.maxAmount * rate) / 1, 2);
- // }
- this.amount = parseInt(data);
- }
- this.$emit("getAmount", this.amount);
+ console.log(val, "sliderAmountChange");
+
+ // if (val) {
+ // if (val == 0) {
+ // this.amount = undefined;
+ // } else {
+
+ const rate = val / 100; //如0.25
+ let sxf = 0;
+ switch (Number(this.lever_rate)) {
+ case 25:
+ sxf = 0.0375;
+ break;
+ case 50:
+ sxf = 0.075;
+ break;
+ case 100:
+ sxf = 0.15;
+ break;
+ case 200:
+ sxf = 0.3;
+ break;
+ default:
+ sxf = 0;
}
+ // const fl =
+ // this.walletMoney * sxf * this.initOpen.amount * this.lever_rate * rate;
+ // const maxAmount =
+ // this.walletMoney * this.initOpen.amount * this.lever_rate;
+ const maxAmount =
+ Math.floor((this.walletMoney / (1 + sxf)) * rate) * this.lever_rate;
+ // const fl = maxAmount * sxf;
+ console.log(maxAmount * rate);
+
+ // data = maxAmount * rate - fl;
+ data = maxAmount;
+ // this.maxAmount = maxAmount;
+ // if (this.lever_rate) {
+ // data = math.format((this.maxAmount * rate), 2);
+ // } else {
+ // data = math.format((this.maxAmount * rate) / 1, 2);
+ // }
+ this.amount = data;
+ // }
+ this.$emit("getAmount", this.amount);
+ // }
},
emptyValue() {
this.sliderAmount = 0;
--
Gitblit v1.9.3