|
|
@ -191,7 +191,8 @@ |
|
|
{{ $t('exchange.balance') }} |
|
|
{{ $t('exchange.balance') }} |
|
|
<span> {{fromBalance}} {{pair.from}}</span> |
|
|
<span> {{fromBalance}} {{pair.from}}</span> |
|
|
</p> |
|
|
</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> |
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- Sell Order --> |
|
|
<!-- Sell Order --> |
|
|
@ -237,7 +238,8 @@ |
|
|
<el-popover popper-class='popover-tips' placement="top-start" trigger="manual" v-model="visibles.sell.limitAmount"> |
|
|
<el-popover popper-class='popover-tips' placement="top-start" trigger="manual" v-model="visibles.sell.limitAmount"> |
|
|
<span class="content"> |
|
|
<span class="content"> |
|
|
<i class="el-icon-warning-outline"></i> |
|
|
<i class="el-icon-warning-outline"></i> |
|
|
{{ msgList.sell[2] }} |
|
|
<!-- {{ msgList.sell[2] }} --> |
|
|
|
|
|
{{ msgList.sell[4] }} |
|
|
</span> |
|
|
</span> |
|
|
<div class="input-group" slot="reference"> |
|
|
<div class="input-group" slot="reference"> |
|
|
<input type="number" v-model="sellorder.amount" class="form-control" min=0 :placeholder="$t('exchange.enter-amount')"> |
|
|
<input type="number" v-model="sellorder.amount" class="form-control" min=0 :placeholder="$t('exchange.enter-amount')"> |
|
|
@ -272,7 +274,8 @@ |
|
|
{{ $t('exchange.balance') }} |
|
|
{{ $t('exchange.balance') }} |
|
|
<span> {{fromBalance}} {{pair.from}}</span> |
|
|
<span> {{fromBalance}} {{pair.from}}</span> |
|
|
</p> |
|
|
</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> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
@ -299,6 +302,11 @@ export default { |
|
|
cacheTotal: 0, // 存放市价单输入的总值 |
|
|
cacheTotal: 0, // 存放市价单输入的总值 |
|
|
cachePrice: null, // 存放最新价格 |
|
|
cachePrice: null, // 存放最新价格 |
|
|
|
|
|
|
|
|
|
|
|
timeoutId: null, |
|
|
|
|
|
intervalId: null, |
|
|
|
|
|
tradingOpenshow:false, |
|
|
|
|
|
timer: null, |
|
|
|
|
|
|
|
|
// 气泡弹框内容和触发 |
|
|
// 气泡弹框内容和触发 |
|
|
visibles: { |
|
|
visibles: { |
|
|
"buy": { |
|
|
"buy": { |
|
|
@ -454,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) { |
|
|
renderBuyAmount(val, index) { |
|
|
// console.Info(val) |
|
|
// console.Info(val) |
|
|
// console.Info(this.buyorder) |
|
|
// console.Info(this.buyorder) |
|
|
@ -646,10 +739,12 @@ export default { |
|
|
if (this.empty(order.amount)) { |
|
|
if (this.empty(order.amount)) { |
|
|
flag = false; |
|
|
flag = false; |
|
|
this.visibles[orderType].marketAmount = true; |
|
|
this.visibles[orderType].marketAmount = true; |
|
|
|
|
|
this.visibles[orderType].limitAmount = true; |
|
|
this.msgList[orderType][4] = this.$t('nav.a6'); |
|
|
this.msgList[orderType][4] = this.$t('nav.a6'); |
|
|
} else if (order.amount < this.minQty) { |
|
|
} else if (order.amount < this.minQty) { |
|
|
flag = false; |
|
|
flag = false; |
|
|
this.visibles[orderType].marketAmount = true; |
|
|
this.visibles[orderType].marketAmount = true; |
|
|
|
|
|
this.visibles[orderType].limitAmount = true; |
|
|
this.msgList[orderType][4] = this.$t('nav.a7')+` ${this.minQty}`; |
|
|
this.msgList[orderType][4] = this.$t('nav.a7')+` ${this.minQty}`; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -718,9 +813,18 @@ export default { |
|
|
|
|
|
|
|
|
created() { |
|
|
created() { |
|
|
this.getCoinInfo() |
|
|
this.getCoinInfo() |
|
|
|
|
|
|
|
|
|
|
|
this.tradingOpen() |
|
|
|
|
|
this.startSchedule(); |
|
|
|
|
|
|
|
|
this.reset(); |
|
|
this.reset(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
beforeDestroy() { |
|
|
|
|
|
// this.clearSchedule(); |
|
|
|
|
|
if (this.timer) { |
|
|
|
|
|
clearInterval(this.timer); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
@ -822,4 +926,13 @@ export default { |
|
|
.market-trade p{ |
|
|
.market-trade p{ |
|
|
color: #e7e7e7; |
|
|
color: #e7e7e7; |
|
|
} |
|
|
} |
|
|
|
|
|
.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> |
|
|
</style> |
|
|
|