| | |
| | | </div> |
| | | <div class="tabs_content"> |
| | | <div class="num" v-show="priceTabsCurrentIndex == 1"> |
| | | <span>{{ $t("hj99") }}</span> |
| | | <span>{{ isSell ? $t("当价格满足条件时卖出") : $t("hj99") }}</span> |
| | | </div> |
| | | <div class="tr_es flexJy" v-show="priceTabsCurrentIndex == 1"> |
| | | <div class="top_input"> |
| | |
| | | </div> |
| | | </div> |
| | | </div> --> |
| | | <div class="btn_buy" @click="gdOrSetBuy()"> |
| | | <div |
| | | class="btn_buy" |
| | | @click="gdOrSetBuy()" |
| | | :disabled="isSell && !positiontionData.orderNum" |
| | | :class="{ 'disabled-btn': isSell && !positiontionData.orderNum }" |
| | | > |
| | | <!-- <div :class="tabsCurrentIndex == 0 ? 'maichu' : ''">#3b82f6 --> |
| | | <div class="maichu" style="background-color:#3b82f6"> |
| | | <span v-if="isSell">{{ $t("hj78") }}</span> |
| | |
| | | |
| | | <script> |
| | | import * as api from "@/axios/api"; |
| | | import { number } from "echarts/lib/export"; |
| | | import { mapActions } from "vuex"; |
| | | |
| | | export default { |
| | |
| | | created() { |
| | | if (this.$route.query.t) { |
| | | this.tabsCurrentIndex = Number(this.$route.query.t); |
| | | if (this.tabsCurrentIndex === 0) { |
| | | this.isSell = true; |
| | | } |
| | | console.log(this.tabsCurrentIndex); |
| | | |
| | | console.log("tabsCurrentIndex: ", this.tabsCurrentIndex); |
| | | } |
| | | ss; |
| | | |
| | | if (this.$route.query.m) { |
| | | this.nowPrice = Number(this.$route.query.m); |
| | | this.profitTarget = Number(this.$route.query.m); |
| | |
| | | ], |
| | | moneyData: {}, |
| | | gid: "", |
| | | KLine: {} |
| | | KLine: {}, |
| | | positiontionData: { |
| | | orderNum: 0 |
| | | } |
| | | }; |
| | | }, |
| | | |
| | | mounted() { |
| | | async mounted() { |
| | | this.bayType = this.$route.query.bayType; |
| | | this.gid = this.$route.query.gid; |
| | | this.KLine = JSON.parse(window.localStorage.getItem("kLine")); |
| | | if (this.tabsCurrentIndex === 0) { |
| | | this.isSell = true; |
| | | // stockType 1黄金原油 2 股票 |
| | | const data = await api.getPosition({ |
| | | stock: this.$route.query.code || this.$route.query.name, |
| | | stockType: this.KLine.type === "HJ" ? 1 : 2 |
| | | }); |
| | | if (data.data) { |
| | | this.positiontionData = data.data; |
| | | } else { |
| | | if (data.status !== 0) { |
| | | this.$store.commit("elAlertShow", { |
| | | elAlertShow: true, |
| | | elAlertText: data.msg, |
| | | elAlertType: "warning" |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (this.bayType == "in") { |
| | | this.priceTabs = [this.$t("hj108"), this.$t("hj109")]; |
| | | } else if (this.bayType == "qh") { |
| | |
| | | this.selectLever = val.label; |
| | | }, |
| | | gdOrSetBuy() { |
| | | // 无持仓的时候不能下单 |
| | | if (this.isSell && !this.positiontionData.orderNum) return; |
| | | |
| | | if (this.priceTabsCurrentIndex == 0) { |
| | | this.setBuy(); |
| | | } else { |
| | |
| | | let data; |
| | | if (this.KLine.type === "HJ") { |
| | | opts.name = this.KLine.name; |
| | | data = await api.hjyyAddOrder(opts); |
| | | } else { |
| | | data = await api.guadan(opts); |
| | | opts.lever = 100; |
| | | } |
| | | if (this.isSell) { |
| | | let sellDate = { |
| | | positionSn: this.positiontionData.positionSn, |
| | | number: this.num, |
| | | name: opts.name |
| | | }; |
| | | if (this.priceTabsCurrentIndex == 1) { |
| | | sellDate.targetPrice = this.nums; |
| | | sellDate.lever = opts.lever; |
| | | } |
| | | // 挂单 卖出 |
| | | data = await api.sell(sellDate); |
| | | } else { |
| | | if (this.KLine.type === "HJ") { |
| | | data = await api.hjyyAddOrder(opts); |
| | | } else { |
| | | data = await api.guadan(opts); |
| | | } |
| | | } |
| | | |
| | | this.buying = false; |
| | | if (data.status === 0) { |
| | | this.$store.commit("elAlertShow", { |
| | |
| | | // buyNum: (this.num.match(/\d+/g))[0] * 100, // 单位为手 |
| | | lever: this.selectLever |
| | | }; |
| | | if (this.KLine.type === "HJ") { |
| | | opts.lever = this.selectLever * 100; |
| | | } |
| | | // if (this.KLine.type === "HJ") { |
| | | // opts.lever = this.num * 100; |
| | | // } |
| | | console.log(this.selectLever, "this.selectLever "); |
| | | if (this.tabsCurrentIndex == 0) { |
| | | opts.buyType = 1; |
| | |
| | | opts.stockId = this.id; |
| | | let data; |
| | | |
| | | console.log("bayType: ", this.KLine); |
| | | |
| | | console.log("bayType: ", this.KLine, this.isSell); |
| | | if (this.KLine.type == "HJ") { |
| | | opts.name = this.KLine.name; |
| | | opts.lever = this.num * 100; |
| | | } |
| | | |
| | | data = await api.goldCrudeOilbuy(opts); |
| | | if (this.isSell) { |
| | | let sellDate = { |
| | | positionSn: this.positiontionData.positionSn, |
| | | number: this.num, |
| | | name: opts.name |
| | | }; |
| | | if (this.priceTabsCurrentIndex == 1) { |
| | | sellDate.targetPrice = this.nums; |
| | | sellDate.lever = opts.lever; |
| | | } |
| | | // 卖出 |
| | | data = await api.sell(sellDate); |
| | | } else { |
| | | data = await api.buy(opts); |
| | | if (this.KLine.type == "HJ") { |
| | | opts.name = this.KLine.name; |
| | | opts.lever = 100; |
| | | data = await api.goldCrudeOilbuy(opts); |
| | | } else { |
| | | data = await api.buy(opts); |
| | | } |
| | | } |
| | | |
| | | this.buying = false; |
| | |
| | | /deep/.van-popup { |
| | | z-index: 10001 !important; |
| | | } |
| | | |
| | | .disabled-btn { |
| | | opacity: 0.5; |
| | | pointer-events: none; |
| | | cursor: not-allowed; |
| | | } |
| | | </style> |