From cf0f537770db12fb8e50a8932a6325e23018bc8b Mon Sep 17 00:00:00 2001
From: dcc <dcc@163.com>
Date: Sun, 07 Jul 2024 10:16:21 +0800
Subject: [PATCH] 7.6号改的东西

---
 src/page/trading/buy.vue |  250 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 195 insertions(+), 55 deletions(-)

diff --git a/src/page/trading/buy.vue b/src/page/trading/buy.vue
index 4f8914c..4194a3c 100644
--- a/src/page/trading/buy.vue
+++ b/src/page/trading/buy.vue
@@ -69,7 +69,7 @@
               <input type="Number" v-model="nums" />
             </div>
             <div class="right_sw flexJy" style="width: auto">
-              <div class="addorj" @click="gdJian">
+              <!-- <div class="addorj" @click="gdJian">
                 <img src="@/assets/img/ic_number_jian.png" alt />
               </div>
               <div class="addorj"></div>
@@ -82,7 +82,7 @@
                 "
               >
                 <img src="@/assets/img/ic_number_add.png" />
-              </div>
+              </div> -->
             </div>
           </div>
           <div class="num">
@@ -92,27 +92,26 @@
             <div class="top_input">
               <input
                 type="number"
-                onkeyup="value=value.replace(/[^\d]/g,'')"
                 v-model="num"
                 @input="numInput"
               />
             </div>
             <div class="right_sw flexJy" style="width: auto">
-              <div class="addorj" @click="jyslJian">
+              <!-- <div class="addorj" @click="jyslJian">
                 <img src="@/assets/img/ic_number_jian.png" />
               </div>
               <div class="addorj"></div>
               <div class="addorj" @click="jjjisua">
                 <img src="@/assets/img/ic_number_add.png" />
-              </div>
+              </div> -->
             </div>
           </div>
-          <div class="tr_rs gg" @click="showGg = true">
+          <!-- <div class="tr_rs gg" @click="showGg = true">
             <div class="top_bzz">
               <span>{{ $t("hj101") }}</span>
               <span>{{ selectCycle }}</span>
             </div>
-          </div>
+          </div> -->
           <div class="tr_rs">
             <div class="top_bzz" style="padding-bottom: 0.2rem">
               <span style="text-align: left">
@@ -124,9 +123,15 @@
             </div>
 
             <div class="bottom_bzz">
-              <span>
+              <span v-if="priceTabsCurrentIndex == 0">
                 {{
-                  ((nowPrice / selectCycle.replace("X", "")) * num)
+                  (nums * selectCycle.replace("X", "") * num)
+                    | _toLocaleString
+                }}
+              </span>
+              <span v-else>
+                {{
+                  (nums * selectCycle.replace("X", "") * num)
                     | _toLocaleString
                 }}
               </span>
@@ -147,10 +152,14 @@
           </div>
         </div>
         <div class="zy" v-show="checkedZy">
+          <!-- <div class="left_zy">
+            <input v-model="profitTarget" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"
+              @input="zyInt" />
+          </div> -->
           <div class="left_zy">
             <input
-              v-model="profitTarget"
-              onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"
+              v-model.number="profitTarget"
+              inputmode="numeric"
               @input="zyInt"
             />
           </div>
@@ -161,7 +170,11 @@
             <div class="addorj"></div>
             <div
               class="addorj"
-              @click="profitTarget = (Number(profitTarget) + 1).toFixed(2)"
+              @click="
+                tabsCurrentIndex == 0
+                  ? (profitTarget = (Number(profitTarget) + 1).toFixed(2))
+                  : (profitTarget = (Number(profitTarget) + 1).toFixed(2))
+              "
             >
               <img src="@/assets/img/ic_number_add.png" />
             </div>
@@ -176,15 +189,14 @@
           </div>
         </div>
         <div class="zy" v-show="checkedZs">
+          <!-- <div class="left_zy">
+            <input v-model="zhisun" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" @input="zsInt" />
+          </div> -->
           <div class="left_zy">
-            <input
-              v-model="zhisun"
-              onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"
-              @input="zsInt"
-            />
+            <input inputmode="numeric" v-model.number="zhisun" @input="zsInt" />
           </div>
           <div class="right_sw" style="width: auto">
-            <div class="addorj" @click="zhisun--">
+            <div class="addorj" @click="zSjian">
               <img src="@/assets/img/ic_number_jian.png" />
             </div>
             <div class="addorj"></div>
@@ -208,6 +220,26 @@
       close-on-click-action
       @select="onSelect"
     />
+    <van-popup
+      v-model="show"
+      :style="{
+        minHeight: '20%',
+        borderTopLeftRadius: '10px',
+        borderTopRightRadius: '10px',
+      }"
+      position="bottom"
+    >
+      <div class="popup-box">
+        <div class="input-box">
+          <div class="laber">{{ $t("秘钥") }}:</div>
+          <input type="text" :maxlength="9" v-model="password" />
+        </div>
+
+        <van-button class="but" type="info" @click="setBuy">
+          {{ $t("立即购买") }}
+        </van-button>
+      </div>
+    </van-popup>
   </div>
 </template>
 
@@ -249,10 +281,12 @@
   },
   data() {
     return {
+      password: "",
+      show: false,
       tradingArr: [this.$t("hj84"), this.$t("hj85")],
       tabsCurrentIndex: 0,
-      // priceTabs: [this.$t("hj108"), this.$t("hj109")],
-      priceTabs: [this.$t("hj108")],
+      priceTabs: [this.$t("hj108"), this.$t("hj109")],
+      // priceTabs: [this.$t("hj108")],
       priceTabsCurrentIndex: 0,
       num: 1,
       nums: 1,
@@ -276,9 +310,18 @@
       bayType: "",
       id: "",
       actions: [
-        { name: "100X", subname: this.$t("hj102") },
-        { name: "200X", subname: this.$t("hj102") },
-        { name: "300X", subname: this.$t("hj102") },
+        {
+          name: "100X",
+          subname: this.$t("hj102"),
+        },
+        {
+          name: "200X",
+          subname: this.$t("hj102"),
+        },
+        {
+          name: "300X",
+          subname: this.$t("hj102"),
+        },
       ],
       profitArr: [
         {
@@ -298,6 +341,7 @@
       gid: "",
     };
   },
+
   mounted() {
     this.bayType = this.$route.query.bayType;
     this.gid = this.$route.query.gid;
@@ -325,20 +369,31 @@
     },
   },
   methods: {
+    zSjian() {
+      var newzishu = (Number(this.zhisun) - 1).toFixed(2);
+      if (Number(newzishu) < 1) {
+      } else {
+        this.zhisun = newzishu;
+      }
+    },
     ...mapActions(["setUseInfo"]),
     numInput(e) {
       // this.nowPrice / this.selectCycle.replace("X", "")
       // this.moneyData.availableBalance
-      let numbs = Math.floor(
-        this.moneyData.availableBalance /
-          this.nowPrice /
-          this.selectCycle.replace("X", "")
-      );
-      if (e.target.value >= numbs) {
-        this.num = numbs;
-      }
+      // let numbs = Math.floor(
+      //   this.moneyData.availableBalance /
+      //     this.nowPrice /
+      //     this.selectCycle.replace("X", "")
+      // );
+      // if (e.target.value >= numbs) {
+      //   this.num = numbs;
+      // }
       // if()
       console.log(e.target.value);
+    },
+    handleDoubleClick(event) {
+      console.log(1);
+      // console.log('Input field was double-clicked', event);
     },
     async getMoneyData() {
       let data = await api.getMoney();
@@ -403,44 +458,74 @@
       }
     },
     zYjian() {
-      if ((Number(this.profitTarget) - 1).toFixed(2) < this.nowPrice) {
-        this.profitTarget = this.nowPrice;
+      var newzishu = (Number(this.profitTarget) - 1).toFixed(2);
+      if (Number(newzishu) < 1) {
       } else {
-        this.profitTarget = (Number(this.profitTarget) - 1).toFixed(2);
+        this.profitTarget = newzishu;
       }
+      // this.profitTarget = (Number(this.profitTarget) - 1).toFixed(2);
+      // if(this.tabsCurrentIndex==0){
+      //   console.log( this.nowPrice);
+      //   if ((Number(this.profitTarget) - 1).toFixed(2) < this.nowPrice) {
+      //     this.profitTarget = (Number(this.profitTarget) - 1).toFixed(2);
+      //   } else {
+      //     this.profitTarget = this.nowPrice;
+      //   }
+      // }else{
+      //   console.log(123);
+      //   if ((Number(this.profitTarget) - 1).toFixed(2) < this.nowPrice) {
+      //     this.profitTarget = this.nowPrice;
+      //   } else {
+      //     this.profitTarget = (Number(this.profitTarget) - 1).toFixed(2);
+      //   }
+      // }
     },
     zSjia() {
-      if ((Number(this.zhisun) + 1).toFixed(2) > this.nowPrice) {
-        this.zhisun = this.nowPrice;
-      } else {
-        this.zhisun++;
-      }
+      this.zhisun++;
+      // if ((Number(this.zhisun) + 1).toFixed(2) > this.nowPrice) {
+      //   this.zhisun = this.nowPrice;
+      // } else {
+      //   this.zhisun++;
+      // }
     },
     zsInt(e) {
-      if (typeof e.target.value === "string") {
-        this.zhisun = this.nowPrice;
-      } else {
-        if (Number(e.target.value) > this.nowPrice) {
-          this.zhisun = this.nowPrice;
-        }
-      }
+      console.log(e);
+      // if (typeof e.target.value === "string") {
+      //   this.zhisun = this.nowPrice;
+      // } else {
+      //   if (Number(e.target.value) > this.nowPrice) {
+      //     this.zhisun = this.nowPrice;
+      //   }
+      // }
     },
     zyInt(e) {
-      if (typeof e.target.value === "string") {
-        this.profitTarget = this.nowPrice;
-      } else {
-        if (Number(e.target.value) < Number(this.nowPrice)) {
-          this.profitTarget = Number(this.nowPrice);
-        }
-      }
+      console.log(e);
+      // if (typeof e.target.value === "string") {
+      //   this.profitTarget = this.nowPrice;
+      // } else {
+      //   if (Number(e.target.value) < Number(this.nowPrice)) {
+      //     this.profitTarget = Number(this.nowPrice);
+      //   }
+      // }
     },
     onSelect(val) {
       this.selectCycle = val.name;
       this.selectLever = val.label;
     },
+    async checkcheckStockVip() {
+      // this.$refs.closeDialog.show = true;
+      let data = await api.checkStockVip({ stockCode: this.code });
+      console.log(data, "data");
+      if (!data.data) {
+        this.password = "";
+        this.setBuy();
+      } else {
+        this.show = true;
+      }
+    },
     gdOrSetBuy() {
       if (this.priceTabsCurrentIndex == 0) {
-        this.setBuy();
+        this.checkcheckStockVip();
       } else {
         this.gdBuy();
       }
@@ -548,6 +633,7 @@
     // 股票买入
     async gpBuy(opts) {
       opts.stockId = this.id;
+      opts.password = this.password;
       let data = await api.buy(opts);
       this.buying = false;
       if (data.status === 0) {
@@ -638,7 +724,10 @@
             i++
           ) {
             let val = this.$store.state.userInfo.siteLever.split("/")[i];
-            let item = { label: val, name: val + "X" };
+            let item = {
+              label: val,
+              name: val + "X",
+            };
             this.siteLeverList.push(item);
           }
           console.log(this.siteLeverList, " this.selectCycle");
@@ -955,6 +1044,7 @@
 .btn_buy {
   width: 100%;
   height: auto;
+  bottom: 0;
   background: #fff;
   padding: 0.8rem 0.8rem;
   display: flex;
@@ -1069,6 +1159,7 @@
     transform: skew(-10deg, 0deg);
   }
 }
+
 /deep/.van-overlay {
   z-index: 10000 !important;
 }
@@ -1076,4 +1167,53 @@
 /deep/.van-popup {
   z-index: 10001 !important;
 }
+
+.popup-box {
+  padding: 30px 20px;
+  .input-box {
+    height: 1.3rem;
+    background: #f3f3f3;
+    border-radius: 0.15rem;
+
+    line-height: 1.3rem;
+    padding-left: 10px;
+    display: flex;
+    padding-left: 0.2rem;
+    font-size: 0.3975rem;
+    .laber {
+      margin-right: 10px;
+    }
+    // margin-top: 0.8rem;
+  }
+  .but {
+    width: 100%;
+    height: 1.3rem;
+    border-radius: 0.15rem;
+    background: #5c288c;
+    color: #fff;
+    font-size: 0.4615rem;
+    margin-top: 0.5rem;
+  }
+  .shijian {
+    width: 100%;
+    margin-top: 0.5rem;
+    margin-bottom: 0.5rem;
+    .xgsj {
+      margin-top: 10px;
+      font-size: 0.3875rem;
+      // font-weight: 600;
+      display: -webkit-box;
+      display: -ms-flexbox;
+      display: flex;
+      height: 50%;
+      -webkit-box-align: center;
+      -ms-flex-align: center;
+      align-items: center;
+      .sjtlt {
+        width: 33%;
+        margin-left: 0.4rem;
+      }
+    }
+  }
+}
 </style>

--
Gitblit v1.9.3