From c42857f46e7c6fa6f8bb0b75f399707789c4ab72 Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Sat, 21 Jun 2025 16:47:27 +0800
Subject: [PATCH] k线添加网格

---
 src/components/perpetual-open/index.vue |  116 ++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 64 insertions(+), 52 deletions(-)

diff --git a/src/components/perpetual-open/index.vue b/src/components/perpetual-open/index.vue
index 3fe795d..48d454b 100644
--- a/src/components/perpetual-open/index.vue
+++ b/src/components/perpetual-open/index.vue
@@ -161,7 +161,7 @@
             <input
               :placeholder="
                 selectIndex == 1
-                  ? $t('张数')
+                  ? $t('手数')
                   : $t('最少') + initFutrue && initFutrue.para
                   ? $t('最小金额') + initFutrue.para[paraIndex].buy_min
                   : ''
@@ -191,57 +191,51 @@
           </div>
           <template v-if="selectIndex == 1">
             <div class="mt-40 mb-30 w-full flex justify-between items-center">
-              <span class="font-22 font-400 text-grey">{{
-                $t("可开张数")
-              }}</span
-              >{{ form.lever_rate }}
+              <span class="font-22 font-400 text-grey">
+                {{ $t("可开") }}{{ $t("手数") }}
+                <!-- {{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 - initFutrue.amount * 0.0375) /
-                      initData.amount
-                  )
+                  Math.floor(initFutrue.amount / (initData.amount + 0.0375)) *
+                  form.lever_rate
                 }}
-                {{ $t("张") }}
+                {{ $t("手数") }}
               </span>
               <span
                 class="font-22 font-400 textColor"
                 v-if="form.lever_rate == 50"
               >
                 {{
-                  Math.floor(
-                    (initFutrue.amount - initFutrue.amount * 0.075) /
-                      initData.amount
-                  )
+                  Math.floor(initFutrue.amount / (initData.amount + 0.075)) *
+                  form.lever_rate
                 }}
-                {{ $t("张") }}
+                {{ $t("手数") }}
               </span>
               <span
                 class="font-22 font-400 textColor"
                 v-if="form.lever_rate == 100"
               >
                 {{
-                  Math.floor(
-                    (initFutrue.amount - initFutrue.amount * 0.15) /
-                      initData.amount
-                  )
+                  Math.floor(initFutrue.amount / (initData.amount + 0.15)) *
+                  form.lever_rate
                 }}
-                {{ $t("张") }}
+                {{ $t("手数") }}
               </span>
               <span
                 class="font-22 font-400 textColor"
                 v-if="form.lever_rate == 200"
               >
                 {{
-                  Math.floor(
-                    (initFutrue.amount - initFutrue.amount * 0.3) /
-                      initData.amount
-                  )
+                  Math.floor(initFutrue.amount / (initData.amount + 0.3)) *
+                  form.lever_rate
                 }}
-                {{ $t("张") }}
+                {{ $t("手数") }}
               </span>
             </div>
             <!-- <vue-slider v-bind="options" v-model="form.amount"></vue-slider> -->
@@ -270,20 +264,16 @@
             <div class="flex justify-between mt-30">
               <div class="text-grey">{{ $t("合约金额") }}</div>
               <div class="textColor">
-                {{
-                  (
-                    initData.amount *
-                    (form.amount / 1) *
-                    form.lever_rate
-                  ).toFixed(4)
-                }}
+                {{ (form.amount * initData.amount).toFixed(4) }}
                 USDT
               </div>
             </div>
             <div class="flex justify-between mt-30">
               <div class="text-grey">{{ $t("保证金") }}</div>
               <div class="textColor">
-                {{ ((initData.amount * (form.amount / 1)) | nan).toFixed(4) }}
+                {{
+                  ((form.amount * initData.amount) / form.lever_rate).toFixed(4)
+                }}
                 USDT
               </div>
             </div>
@@ -307,7 +297,7 @@
                 USDT
               </div>
               <div class="textColor" v-if="form.lever_rate == 200">
-                {{ (initData.amount * (form.amount / 1) * 0.3).toFixed(4) }}
+                {{ ((form.amount * 0.3) / form.lever_rate).toFixed(4) }}
                 USDT
               </div>
             </div>
@@ -750,6 +740,18 @@
           // 倍数
           obj.lever = [
             {
+              id: 25,
+              lever_rate: 25,
+            },
+            {
+              id: 50,
+              lever_rate: 50,
+            },
+            {
+              id: 100,
+              lever_rate: 100,
+            },
+            {
               id: 200,
               lever_rate: 200,
             },
@@ -803,7 +805,7 @@
         stop_price_profit: "",
         stop_price_loss: "",
         price: "",
-        amount: "", // 数量
+        amount: 0, // 数量
         para_id: "", // 交割周琦id
       },
       focus: false,
@@ -859,7 +861,7 @@
   methods: {
     //获取张数
     getAmount(val) {
-      this.form.amount = 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)
       // }else if(this.form.lever_rate==50){
@@ -875,25 +877,33 @@
       let vol;
       // vol = this.initOpen.volume / 1;
       if (this.form.lever_rate == 25) {
-        vol = Math.floor(
-          (this.initFutrue.amount - this.initFutrue.amount * 0.0375) /
-            this.initData.amount
-        );
+        vol =
+          Math.floor(
+            // (this.initFutrue.amount - this.initFutrue.amount * 0.0375) /
+            //   this.initData.amount
+            this.initFutrue.amount / (this.initData.amount + 0.0375)
+          ) * this.form.lever_rate;
       } else if (this.form.lever_rate == 50) {
-        vol = Math.floor(
-          (this.initFutrue.amount - this.initFutrue.amount * 0.0375) /
-            this.initData.amount
-        );
+        vol =
+          Math.floor(
+            // (this.initFutrue.amount - this.initFutrue.amount * 0.0375) /
+            //   this.initData.amount
+            this.initFutrue.amount / (this.initData.amount + 0.075)
+          ) * this.form.lever_rate;
       } else if (this.form.lever_rate == 100) {
-        vol = Math.floor(
-          (this.initFutrue.amount - this.initFutrue.amount * 0.15) /
-            this.initData.amount
-        );
+        vol =
+          Math.floor(
+            // (this.initFutrue.amount - this.initFutrue.amount * 0.15) /
+            //   this.initData.amount
+            this.initFutrue.amount / (this.initData.amount + 0.15)
+          ) * this.form.lever_rate;
       } else {
-        vol = Math.floor(
-          (this.initFutrue.amount - this.initFutrue.amount * 0.3) /
-            this.initData.amount
-        );
+        vol =
+          Math.floor(
+            // (this.initFutrue.amount - this.initFutrue.amount * 0.3) /
+            //   this.initData.amount
+            this.initFutrue.amount / (this.initData.amount + 0.3)
+          ) * this.form.lever_rate;
       }
       return Math.floor(vol);
     },
@@ -1172,11 +1182,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