From 0d7c0aa6baba05bfeefd7dd7f37e63a9752caf90 Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Mon, 30 Jun 2025 19:32:24 +0800
Subject: [PATCH] 当前持仓添加轮询
---
src/components/perpetual-open/index.vue | 142 +++++++++++++++++++++++++++--------------------
1 files changed, 82 insertions(+), 60 deletions(-)
diff --git a/src/components/perpetual-open/index.vue b/src/components/perpetual-open/index.vue
index 09c19ee..0f20263 100644
--- a/src/components/perpetual-open/index.vue
+++ b/src/components/perpetual-open/index.vue
@@ -196,45 +196,9 @@
<!-- {{initFutrue.amount / (initData.amount + 0.0375) * form.lever_rate }} // -->
<!-- {{ initFutrue.amount }} // 余额 -->
</span>
- {{ form.lever_rate }}
- <span
- class="font-22 font-400 textColor"
- v-if="form.lever_rate == 25"
- >
- {{
- Math.floor(initFutrue.amount / (initData.amount + 0.0375)) *
- form.lever_rate
- }}
- {{ $t("手数") }}
- </span>
- <span
- class="font-22 font-400 textColor"
- v-if="form.lever_rate == 50"
- >
- {{
- Math.floor(initFutrue.amount / (initData.amount + 0.075)) *
- form.lever_rate
- }}
- {{ $t("手数") }}
- </span>
- <span
- class="font-22 font-400 textColor"
- v-if="form.lever_rate == 100"
- >
- {{
- Math.floor(initFutrue.amount / (initData.amount + 0.15)) *
- form.lever_rate
- }}
- {{ $t("手数") }}
- </span>
- <span
- class="font-22 font-400 textColor"
- v-if="form.lever_rate == 200"
- >
- {{
- Math.floor(initFutrue.amount / (initData.amount + 0.3)) *
- form.lever_rate
- }}
+ <!-- {{ form.lever_rate }} -->
+ <span class="font-22 font-400 textColor">
+ {{ maxItems }}
{{ $t("手数") }}
</span>
</div>
@@ -253,10 +217,10 @@
<span class="flex-1 text-right">75%</span>
<span class="flex-1 text-right">100%</span>
</div> -->
- <!-- 张数输入 -->
+ <!-- 张数 滑块 -->
<amount-slider
ref="sliderRef"
- :maxAmount="getVolumnByLever()"
+ :maxAmount="maxItems"
@getAmount="getAmount"
></amount-slider>
</template>
@@ -271,9 +235,7 @@
<div class="flex justify-between mt-30">
<div class="text-grey">{{ $t("保证金") }}</div>
<div class="textColor">
- {{
- ((form.amount * initData.amount) / form.lever_rate).toFixed(4)
- }}
+ {{ margin.toFixed(4) }}
USDT
</div>
</div>
@@ -284,22 +246,7 @@
? initData.fee * (form.amount / 1)
: (initData.fee * (form.amount / 1) * form.lever_rate) | nan
}} -->
- <div class="textColor" v-if="form.lever_rate == 25">
- {{ (initData.amount * (form.amount / 1) * 0.0375).toFixed(4) }}
- USDT
- </div>
- <div class="textColor" v-if="form.lever_rate == 50">
- {{ (initData.amount * (form.amount / 1) * 0.075).toFixed(4) }}
- USDT
- </div>
- <div class="textColor" v-if="form.lever_rate == 100">
- {{ (initData.amount * (form.amount / 1) * 0.15).toFixed(4) }}
- USDT
- </div>
- <div class="textColor" v-if="form.lever_rate == 200">
- {{ ((form.amount * 0.3) / form.lever_rate).toFixed(4) }}
- USDT
- </div>
+ <div class="textColor">{{ fee.toFixed(4) }} USDT</div>
</div>
</template>
<div
@@ -740,6 +687,18 @@
// 倍数
obj.lever = [
{
+ id: 25,
+ lever_rate: 25,
+ },
+ {
+ id: 50,
+ lever_rate: 50,
+ },
+ {
+ id: 100,
+ lever_rate: 100,
+ },
+ {
id: 200,
lever_rate: 200,
},
@@ -752,6 +711,66 @@
coudBuyVolume() {
// 可买数量
return Math.floor(this.initOpen.volume / 1 / this.form.lever_rate);
+ },
+ // 每份保证金
+ perItemMargin() {
+ console.log(
+ this.initData,
+ ": 每份保证金",
+ this.initData.amount / this.form.lever_rate
+ );
+ return this.initData.amount / this.form.lever_rate;
+ },
+ // 每份手续费(基于保证金)
+ perItemFee() {
+ const rateMap = {
+ 25: 0.0375,
+ 50: 0.075,
+ 100: 0.15,
+ 200: 0.3,
+ };
+ const rate = rateMap[this.form.lever_rate];
+ return this.perItemMargin * rate;
+ },
+ // 每份总支出
+ perItemTotalCost() {
+ return this.perItemMargin + this.perItemFee;
+ },
+ // 最大可购买整数份数
+ maxItems() {
+ console.log(this.initFutrue.amount, ": initFutrue.amount");
+ if (this.perItemTotalCost <= 0) return 0;
+ return Math.floor(this.initFutrue.amount / this.perItemTotalCost);
+ },
+ // 实际交易金额
+ actualTradeValue() {
+ return this.form.amount * this.initData.amount;
+ },
+ // 总保证金
+ margin() {
+ return this.form.amount * this.perItemMargin;
+ },
+ // 总手续费
+ fee() {
+ return this.form.amount * this.perItemFee;
+ },
+ // 总支出
+ totalExpenditure() {
+ return this.margin + this.fee;
+ },
+ calculatedFee() {
+ const rateMap = {
+ 25: 0.0375,
+ 50: 0.075,
+ 100: 0.15,
+ 200: 0.3,
+ };
+ const rate = rateMap[this.form.lever_rate];
+ console.log(this.initData.amount, ": initData.amount");
+ return (
+ (this.form.amount * this.initData.amount * rate) / this.form.lever_rate
+ );
+ // : this.initData.amount * (this.form.amount / 1) * rate;
},
},
filters: {
@@ -849,6 +868,7 @@
methods: {
//获取张数
getAmount(val) {
+ console.log(val, "获取张数");
this.form.amount = val || 0;
// if(this.form.lever_rate==25){
// this.form.amount = Math.floor((this.initFutrue.amount-(this.initFutrue.amount * 0.0375))/this.initData.amount)
@@ -1170,11 +1190,13 @@
this.$refs.sliderRef.emptyValue();
}
this.$toast(this.$t("操作成功"));
+
_getBalance().then((data) => {
// 刷新余额
this.$store.commit("user/SET_USERINFO", {
balance: data.money,
});
+ location.reload();
});
this.$emit("ordered", emitFunc);
if (this.selectIndex / 1 === 2) {
--
Gitblit v1.9.3