|
|
|
@ -62,7 +62,7 @@ |
|
|
|
<!-- <stock-kline :symbol="symbol" :socket="socket" :priceDecimals="priceDecimals"></stock-kline> --> |
|
|
|
|
|
|
|
<!-- 交易处理 --> |
|
|
|
<div class="market-trade" style="background-color: transparent;border: 0px;"> |
|
|
|
<div class="market-trade "> |
|
|
|
<h4 style="text-align: center;">{{$t('nav.c12')}}</h4> |
|
|
|
<div class="d-flex" style="margin: 14px;justify-content: space-around;border: 1px solid #b9b9b9;border-radius: 40px;"> |
|
|
|
<div :class="Tab_buysell == 1?'Tab_buy':'Tab_buy1'" @click="Tab_buysell=1">{{$t('order.buy')}}</div> |
|
|
|
@ -191,7 +191,8 @@ |
|
|
|
{{ $t('exchange.balance') }} |
|
|
|
<span> {{fromBalance}} {{pair.from}}</span> |
|
|
|
</p> |
|
|
|
<button class="btn buy" @click="handleBuyOrder">{{ $t("common.buy") }} {{pair.to}}</button> |
|
|
|
<button class="btn buy" @click="handleBuyOrder" v-if="tradingOpenshow==true">{{ $t("common.buy") }} {{pair.to}}</button> |
|
|
|
<button class="btn colorless" @click="handleBuyOrder" v-if="tradingOpenshow==false">{{ $t("common.buy") }} {{pair.to}}</button> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- Sell Order --> |
|
|
|
@ -237,7 +238,8 @@ |
|
|
|
<el-popover popper-class='popover-tips' placement="top-start" trigger="manual" v-model="visibles.sell.limitAmount"> |
|
|
|
<span class="content"> |
|
|
|
<i class="el-icon-warning-outline"></i> |
|
|
|
{{ msgList.sell[2] }} |
|
|
|
<!-- {{ msgList.sell[2] }} --> |
|
|
|
{{ msgList.sell[4] }} |
|
|
|
</span> |
|
|
|
<div class="input-group" slot="reference"> |
|
|
|
<input type="number" v-model="sellorder.amount" class="form-control" min=0 :placeholder="$t('exchange.enter-amount')"> |
|
|
|
@ -272,7 +274,8 @@ |
|
|
|
{{ $t('exchange.balance') }} |
|
|
|
<span> {{fromBalance}} {{pair.from}}</span> |
|
|
|
</p> |
|
|
|
<button class="btn sell" @click="handleSellOrder">{{ $t("common.sell") }} {{pair.to}}</button> |
|
|
|
<button class="btn sell" @click="handleSellOrder" v-if="tradingOpenshow==true">{{ $t("common.sell") }} {{pair.to}}</button> |
|
|
|
<button class="btn colorless" @click="handleSellOrder" v-if="tradingOpenshow==false">{{ $t("common.sell") }} {{pair.to}}</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
@ -299,6 +302,11 @@ export default { |
|
|
|
cacheTotal: 0, // 存放市价单输入的总值 |
|
|
|
cachePrice: null, // 存放最新价格 |
|
|
|
|
|
|
|
timeoutId: null, |
|
|
|
intervalId: null, |
|
|
|
tradingOpenshow:false, |
|
|
|
timer: null, |
|
|
|
|
|
|
|
// 气泡弹框内容和触发 |
|
|
|
visibles: { |
|
|
|
"buy": { |
|
|
|
@ -375,8 +383,9 @@ export default { |
|
|
|
if (!this.isMarket) { |
|
|
|
this.buyorder.amount = Math.division(val, this.buyorder.entrust_price); |
|
|
|
} else { // 市价单 缓存总值 |
|
|
|
this.cacheTotal = val; |
|
|
|
this.buyorder.amount = this.cacheTotal |
|
|
|
// this.cacheTotal = val; |
|
|
|
// this.buyorder.amount = this.cacheTotal |
|
|
|
this.buyorder.amount = Math.division(val, this.buyorder.entrust_price,6); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -453,6 +462,91 @@ export default { |
|
|
|
|
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
tradingOpen(){ |
|
|
|
Market.getstocktradingOpen().then(res => { |
|
|
|
// console.log(res); |
|
|
|
this.tradingOpenshow = res |
|
|
|
}).catch(err => {}); |
|
|
|
}, |
|
|
|
// 开启定时任务逻辑 |
|
|
|
startSchedule() { |
|
|
|
// const now = new Date(); |
|
|
|
// const minutes = now.getMinutes(); |
|
|
|
// const seconds = now.getSeconds(); |
|
|
|
// const milliseconds = now.getMilliseconds(); |
|
|
|
|
|
|
|
// let msUntilNextTime = 0; // 距离下一次调用的毫秒数 |
|
|
|
|
|
|
|
// // 计算距离下一个 00分 或 30分 还有多久 |
|
|
|
// if (minutes < 30) { |
|
|
|
// // 当前在 0~29 分之间,目标是 30 分 |
|
|
|
// msUntilNextTime = (30 - minutes) * 60000 - seconds * 1000 - milliseconds; |
|
|
|
// } else { |
|
|
|
// // 当前在 30~59 分之间,目标是下一个 00 分 (60分) |
|
|
|
// msUntilNextTime = (60 - minutes) * 60000 - seconds * 1000 - milliseconds; |
|
|
|
// } |
|
|
|
|
|
|
|
// console.log(`距离下次刷新还有 ${Math.round(msUntilNextTime / 1000)} 秒`); |
|
|
|
|
|
|
|
// // 1. 先用 setTimeout 等待到下一个整点或半点 |
|
|
|
// this.timeoutId = setTimeout(() => { |
|
|
|
// // 到达整点/半点,执行一次请求 |
|
|
|
// this.tradingOpen(); |
|
|
|
|
|
|
|
// // 2. 之后开启 setInterval,每隔固定的 30 分钟执行一次 |
|
|
|
// const THIRTY_MINUTES_MS = 30 * 60 * 1000; |
|
|
|
// this.intervalId = setInterval(() => { |
|
|
|
// this.tradingOpen(); |
|
|
|
// }, THIRTY_MINUTES_MS); |
|
|
|
|
|
|
|
// }, msUntilNextTime); |
|
|
|
|
|
|
|
this.timer = setInterval(() => { |
|
|
|
const now = new Date(); |
|
|
|
const minutes = now.getMinutes(); |
|
|
|
const seconds = now.getSeconds(); |
|
|
|
|
|
|
|
let remainingSeconds = 0; |
|
|
|
|
|
|
|
// 1. 如果正好是 00分00秒 或 30分00秒,说明时间到了! |
|
|
|
if (minutes % 30 === 0 && seconds === 0) { |
|
|
|
remainingSeconds = 0; |
|
|
|
console.log(`距离下次刷新还有 ${remainingSeconds} 秒,正在执行刷新...`); |
|
|
|
|
|
|
|
// 触发接口调用 |
|
|
|
this.tradingOpen(); |
|
|
|
} |
|
|
|
// 2. 否则,计算距离下一次刷新的秒数 |
|
|
|
else { |
|
|
|
if (minutes < 30) { |
|
|
|
// 如果当前是 0~29 分,目标是 30 分 |
|
|
|
remainingSeconds = (30 - minutes) * 60 - seconds; |
|
|
|
} else { |
|
|
|
// 如果当前是 30~59 分,目标是 60 分 (下一个整点) |
|
|
|
remainingSeconds = (60 - minutes) * 60 - seconds; |
|
|
|
} |
|
|
|
|
|
|
|
// 一直打印倒计时提示 |
|
|
|
// console.log(`距离下次刷新还有 ${remainingSeconds} 秒`); |
|
|
|
} |
|
|
|
}, 1000); |
|
|
|
}, |
|
|
|
|
|
|
|
// 清除定时器的方法 |
|
|
|
// clearSchedule() { |
|
|
|
// if (this.timeoutId) { |
|
|
|
// clearTimeout(this.timeoutId); |
|
|
|
// this.timeoutId = null; |
|
|
|
// } |
|
|
|
// if (this.intervalId) { |
|
|
|
// clearInterval(this.intervalId); |
|
|
|
// this.intervalId = null; |
|
|
|
// } |
|
|
|
// }, |
|
|
|
|
|
|
|
|
|
|
|
renderBuyAmount(val, index) { |
|
|
|
// console.Info(val) |
|
|
|
// console.Info(this.buyorder) |
|
|
|
@ -645,10 +739,12 @@ export default { |
|
|
|
if (this.empty(order.amount)) { |
|
|
|
flag = false; |
|
|
|
this.visibles[orderType].marketAmount = true; |
|
|
|
this.visibles[orderType].limitAmount = true; |
|
|
|
this.msgList[orderType][4] = this.$t('nav.a6'); |
|
|
|
} else if (order.amount < this.minQty) { |
|
|
|
flag = false; |
|
|
|
this.visibles[orderType].marketAmount = true; |
|
|
|
this.visibles[orderType].limitAmount = true; |
|
|
|
this.msgList[orderType][4] = this.$t('nav.a7')+` ${this.minQty}`; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -717,9 +813,18 @@ export default { |
|
|
|
|
|
|
|
created() { |
|
|
|
this.getCoinInfo() |
|
|
|
|
|
|
|
this.tradingOpen() |
|
|
|
this.startSchedule(); |
|
|
|
|
|
|
|
this.reset(); |
|
|
|
}, |
|
|
|
|
|
|
|
beforeDestroy() { |
|
|
|
// this.clearSchedule(); |
|
|
|
if (this.timer) { |
|
|
|
clearInterval(this.timer); |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
@ -785,7 +890,7 @@ export default { |
|
|
|
.Tab_buy1{ |
|
|
|
width: 50%; |
|
|
|
height: 40px; |
|
|
|
color: #000; |
|
|
|
color: #000000; |
|
|
|
line-height: 40px; |
|
|
|
text-align: center; |
|
|
|
border-radius: 40px; |
|
|
|
@ -802,23 +907,32 @@ export default { |
|
|
|
.Tab_sell1{ |
|
|
|
width: 50%; |
|
|
|
height: 40px; |
|
|
|
// color: #ffffff; |
|
|
|
color: #000000; |
|
|
|
line-height: 40px; |
|
|
|
text-align: center; |
|
|
|
border-radius: 40px; |
|
|
|
} |
|
|
|
|
|
|
|
// .market-trade input{ |
|
|
|
// border: 1px solid #404040; |
|
|
|
// } |
|
|
|
// .input-group-text{ |
|
|
|
// border: 1px solid #404040; |
|
|
|
// background-color: #121212; |
|
|
|
// } |
|
|
|
// .form-control{ |
|
|
|
// background-color: #121212; |
|
|
|
// } |
|
|
|
// .market-trade p{ |
|
|
|
// color: #e7e7e7; |
|
|
|
// } |
|
|
|
.market-trade input{ |
|
|
|
border: 1px solid #e7e7e7; |
|
|
|
} |
|
|
|
.input-group-text{ |
|
|
|
border: 1px solid #e7e7e7; |
|
|
|
background-color: #fff; |
|
|
|
} |
|
|
|
.form-control{ |
|
|
|
background-color: #fff; |
|
|
|
} |
|
|
|
.market-trade p{ |
|
|
|
color: #767676; |
|
|
|
} |
|
|
|
.colorless{ |
|
|
|
background: #999999; |
|
|
|
color: #fff; |
|
|
|
text-transform: uppercase; |
|
|
|
padding: 10px; |
|
|
|
margin-top: 30px; |
|
|
|
width: 100%; |
|
|
|
box-shadow: 0px 0px 15px 0px rgba(199, 199, 199, 0.7); |
|
|
|
} |
|
|
|
</style> |
|
|
|
|