From 2f4b958b6230962ac4e2f1f03d639ba35b4bdadb Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Wed, 09 Jul 2025 16:15:55 +0800
Subject: [PATCH] style

---
 src/components/constract/PerpetualContract/orderCom/amountSlider.vue |  115 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 96 insertions(+), 19 deletions(-)

diff --git a/src/components/constract/PerpetualContract/orderCom/amountSlider.vue b/src/components/constract/PerpetualContract/orderCom/amountSlider.vue
index 29b0ca4..50a5f86 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"
       />
 
@@ -23,14 +22,17 @@
         v-model="sliderAmount"
         :format-tooltip="(v) => `${v}%`"
         :marks="marks"
+        :step="25"
       >
       </el-slider>
     </div>
     <!-- 订单 -->
     <div v-if="existToken">
       <div v-if="typeNum == 0" class="submit-info-item">
-        <div>{{ $t("message.home.kekaizhangshu") }}</div>
-        <div>{{ `${maxAmount} ${$t("message.home.zhang")}` }}</div>
+        <!-- <div>{{ $t("message.home.kekaizhangshu") }}</div>
+        <div>{{ `${maxAmount} ${$t("message.home.zhang")}` }}</div> -->
+        <div>{{ $t("message.jiaoyi.qianbaoyue") }}</div>
+        <div>{{ walletMoney }} USDT</div>
       </div>
 
       <div v-if="typeNum == 1" class="submit-info-item">
@@ -53,6 +55,9 @@
 import { mapState, mapActions, mapStores } from "pinia";
 import { useUserStore } from "@/store/user";
 import { useCurrencyStore } from "@/store/currency";
+import Axios from "@/api/currency.js";
+import bus from "vue3-eventbus";
+
 export default {
   emits: ["getAmount"],
   name: "amountSlider",
@@ -81,6 +86,10 @@
       type: Number,
       default: 0,
     },
+    initOpen: {
+      type: Object,
+      default: {},
+    },
   },
   data() {
     return {
@@ -90,15 +99,52 @@
         0: "0",
         25: "25%",
         50: "50%",
-        75: "70%",
+        75: "75%",
         100: "100%",
       },
+      allowedSteps: [0, 25, 50, 75, 100],
+
+      totalAsset: "0.000000", //总资产
+      walletMoney: "0.000000", //钱包余额
+      profitLoss: "0.000000", //未实现盈亏
+      marginRate: "0.000000", //保证金比率
+      maintenanceMargin: "0.000000", //维持保证金 = 钱包余额
     };
+  },
+  mounted() {
+    if (this.existToken) {
+      this.timer = setInterval(() => {
+        this.getAssetTotal();
+      }, 2000);
+    }
+  },
+  unmounted() {
+    if (this.timer) {
+      clearInterval(this.timer);
+      this.timer = null;
+    }
   },
   computed: {
     ...mapState(useUserStore, ["existToken"]),
+    //保证金余额
+    marginBalance: function () {
+      // 钱包余额 + 未实现盈亏
+      return bigDecimal.add(this.walletMoney, this.profitLoss);
+    },
   },
   methods: {
+    //获取资产总余额
+    getAssetTotal() {
+      Axios.currencyPaypal().then((res) => {
+        const { total, money_wallet, money_contract, money_contract_profit } =
+          res.data;
+        this.totalAsset = total; //总资产
+        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); //合约可用余额
+      });
+    },
     //输入框事件
     inputChange(val) {
       this.$emit("getAmount", val);
@@ -110,24 +156,55 @@
     //滑块事件
     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 = Math.floor(maxAmount / this.initOpen.amount);
+      // 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 = undefined;
+      this.sliderAmount = 0;
     },
   },
 };

--
Gitblit v1.9.3