1
jhzh
2025-11-02 411edaf3d05d0a7393e4784ff8f3310a0ccb2196
src/page/trading/buy.vue
@@ -118,8 +118,8 @@
          </div>
          <div class="tr_rs">
            <div class="top_bzz" style="padding-bottom: 0.2rem">
              <span style="text-align: left"> {{ $t("交易总额") }}() </span>
              <span style="text-align: right"> {{ $t("hj103") }}() </span>
              <span style="text-align: left"> {{ $t("交易总额") }} </span>
              <span style="text-align: right"> {{ $t("hj103") }} </span>
            </div>
            <div class="bottom_bzz">
@@ -144,7 +144,7 @@
          </div>
          <div class="tr_rs">
            <div class="top_bzz" style="padding-bottom: 0.2rem">
              <span style="text-align: left"> {{ $t("hj44") }}() </span>
              <span style="text-align: left"> {{ $t("hj44") }} </span>
              <span style="text-align: right"> </span>
            </div>
@@ -221,6 +221,14 @@
          </div>
        </div>
      </div> -->
      <div class="btn_buy" @click="clickishow()">
        <div
          :class="tabsCurrentIndex == 0 ? 'maichu' : ''"
          :style="preMarket==0?'background-color:#555555 !important':'background-color:#287dff'"
        >
          <span>{{ tabsCurrentIndex == 0 ? $t("场外卖出") : $t("场外买入") }}</span>
        </div>
      </div>
      <div class="btn_buy" @click="gdOrSetBuy()">
        <div
          :class="tabsCurrentIndex == 0 ? 'maichu' : ''"
@@ -230,6 +238,37 @@
        </div>
      </div>
    </div>
    <van-popup v-model="isshow" position="center" round>
      <div class="edit-popup">
        <div class="edit-title">
          {{ tabsCurrentIndex == 0 ? $t("场外卖出") : $t("场外买入") }}
        </div>
        <div class="division"></div>
        <div class="edit-form">
          <div class="form-item">
            <div class="form-label">
              <span class="required">*</span>{{ $t("hj271") }}
            </div>
            <input
              pattern="^(0\.\d+|[1-9]\d*(\.\d+)?)$"
              type="number"
              v-model="preMarketPrice"
              :placeholder="$t('hj271')"
              class="form-input"
            />
          </div>
        </div>
        <div class="division"></div>
        <div class="edit-buttons">
          <div class="cancel-btn" @click="isshow = false">
            {{ $t("qx") }}
          </div>
          <div class="save-btn" @click="saveEdit">{{ $t("qr") }}</div>
        </div>
      </div>
    </van-popup>
    <van-action-sheet
      v-model="showGg"
      :actions="siteLeverList"
@@ -278,6 +317,9 @@
    if (this.$route.query.if_us) {
      this.if_us = this.$route.query.if_us;
    }
    if(this.$route.query.preMarket){
      this.preMarket = this.$route.query.preMarket;
    }
  },
  data() {
    return {
@@ -290,6 +332,9 @@
      nums: 1,
      profit: false,
      nowPrice: 0,
      isshow: false,
      preMarketPrice:"",
      preMarket:0,
      type: 0,
      code: "",
      name: "",
@@ -378,6 +423,30 @@
    }
  },
  methods: {
    async clickishow(){
      if(this.preMarket==0){
        return
      }
      if(this.tabsCurrentIndex == 0 ){
        this.$store.commit("elAlertShow", {
          elAlertShow: true,
          elAlertText: this.$t("失败")
        });
      }else{
        this.isshow = true
      }
    },
    async saveEdit(){
      if(this.preMarketPrice<=0){
      this.$store.commit("elAlertShow", {
          elAlertShow: true,
          elAlertText: this.$t("hj277")+0
        });
      }else{
        this.setBuy()
      }
    },
    async queryStockConfig() {
      let data = await api.queryStockConfig();
      if (data.status === 0) {
@@ -528,6 +597,14 @@
      this.selectLever = val.label;
    },
    gdOrSetBuy() {
      if(this.preMarket == 1){
      this.$store.commit("elAlertShow", {
        elAlertShow: true,
        elAlertText: this.$t('hj113'),
        elAlertType: "success"
      });
        return
      }
      if (this.priceTabsCurrentIndex == 0) {
        this.setBuy();
      } else {
@@ -604,7 +681,7 @@
        // buyType: this.selectType,
        lever: this.selectCycle ? this.selectCycle : 0,
        // subaccountNumber:this.subaccountNumber
        preMarketPrice:this.preMarketPrice,
        // 买入是买涨buyType:0, 卖出是买跌buyType:1,卖出的状态是0,买入的状态是1
        buyNum: this.num, // 单位为手
        // buyNum: (this.num.match(/\d+/g))[0] * 100, // 单位为手
@@ -759,6 +836,7 @@
</script>
<style scoped lang="less">
  @green: #287dff;
.buy_page {
  width: 100%;
  min-height: 100vh;
@@ -771,6 +849,95 @@
    background-color: #222;
  }
}
.edit-popup {
  width: 100%;
  padding: 0.25rem 0;
  box-sizing: border-box;
  .division {
    width: 100%;
    height: 0.25rem;
    background-color: #f5f5f5;
  }
}
/deep/ .van-popup {
  width: 80%;
  border-radius: 8px;
}
.edit-popup {
  width: 100%;
  padding: 0.25rem 0;
  box-sizing: border-box;
  .division {
    width: 100%;
    height: 0.25rem;
    background-color: #f5f5f5;
  }
}
.form-item {
  // margin-bottom: 15px;
  border-bottom: 1px solid #f5f5f5;
  padding: 0.35rem 0 0.25rem;
}
.form-label {
  font-size: 0.4rem;
  margin-bottom: 0.2rem;
  color: #333;
}
.required {
  color: red;
  margin-right: 4px;
}
.form-input {
  width: 100%;
  height: 1.1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0 10px;
  font-size: 0.3rem;
  box-sizing: border-box;
  color: #333;
}
.edit-buttons {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #f5f5f5;
  padding-top: 15px;
}
.cancel-btn,
.save-btn {
  flex: 1;
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 16px;
  cursor: pointer;
}
.cancel-btn {
  color: #333;
}
.save-btn {
  color: @green;
  font-weight: 500;
}
.edit-title {
  text-align: center;
  font-size: 0.45rem;
  font-weight: 700;
  padding: 0.25rem;
  color: #333;
}
.edit-form {
  padding: 0.25rem;
}
.top_cny {
  width: 100%;