From 802fba84f2a31820a305db3c449f82044f7fc324 Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Sun, 15 Jun 2025 14:36:28 +0800
Subject: [PATCH] 金额计算
---
src/components/constract/PerpetualContract/orderCom/amountSlider.vue | 65 +++++++++++++++++++++++++-------
1 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/src/components/constract/PerpetualContract/orderCom/amountSlider.vue b/src/components/constract/PerpetualContract/orderCom/amountSlider.vue
index f4c0b21..46a622a 100644
--- a/src/components/constract/PerpetualContract/orderCom/amountSlider.vue
+++ b/src/components/constract/PerpetualContract/orderCom/amountSlider.vue
@@ -87,6 +87,10 @@
type: Number,
default: 0,
},
+ initOpen: {
+ type: Object,
+ default: {},
+ },
},
data() {
return {
@@ -115,6 +119,12 @@
}, 2000);
}
},
+ unmounted() {
+ if (this.timer) {
+ clearInterval(this.timer);
+ this.timer = null;
+ }
+ },
computed: {
...mapState(useUserStore, ["existToken"]),
//保证金余额
@@ -130,10 +140,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); //合约可用余额
});
},
//输入框事件
@@ -148,18 +158,43 @@
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);
+ // 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;
+ console.log(maxAmount * rate, fl);
+
+ data = maxAmount * rate - fl;
+
+ // 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);
}
},
--
Gitblit v1.9.3