Browse Source

修改股票页面

master
liaoxinyu 2 weeks ago
parent
commit
9b00d9d17d
  1. 4
      src/api/market.js
  2. 20
      src/components/CommonFooter.vue
  3. 14
      src/components/CommonHeader.vue
  4. 8
      src/views/exchangeStock/index.vue
  5. 121
      src/views/exchangeStock/make-deal.vue
  6. 6
      src/views/exchangeStock/order-list.vue

4
src/api/market.js

@ -63,6 +63,10 @@ class Market {
static getstockCoinInfo(params) {
return server.get(`/stock/getCoinInfo`,{ params });
}
// 是否显示颜色
static getstocktradingOpen(params) {
return server.get(`/stock/tradingOpen`,{ params });
}
}
export default Market;

20
src/components/CommonFooter.vue

@ -352,11 +352,11 @@ export default {
label: "Turkey",
url: require("../assets/img/tr.jpg"),
},
// {
// value: 'ar',
// label: 'عربي',
// url:require('../assets/img/polski.png')
// },
{
value: 'ar',
label: 'عربي',
url:require('../assets/img/polski.png')
},
{
value: "tw", // zh-TW
label: "繁体中文",
@ -485,11 +485,11 @@ export default {
this.getServiceLink();
// console.log(this.service);
this.getEmial();
if(this.isLogin){
this.chatcount = setInterval(()=>{
this.chat()
},5000)
}
// if(this.isLogin){
// this.chatcount = setInterval(()=>{
// this.chat()
// },5000)
// }
},
};
</script>

14
src/components/CommonHeader.vue

@ -42,9 +42,9 @@
<li class="nav-item">
<router-link class="nav-link" :to="contract.url">{{ contract.label }}</router-link>
</li>
<!-- <li class="nav-item">
<li class="nav-item">
<router-link class="nav-link" to="/exchangestock">{{ $t('exchange.a1') }}</router-link>
</li> -->
</li>
<li class="nav-item">
<router-link class="nav-link" :to="learn.url">{{ learn.label }}</router-link>
</li>
@ -419,11 +419,11 @@ export default {
label: "Turkey",
url: require("../assets/img/tr.jpg"),
},
// {
// value: 'ar',
// label: 'عربي',
// url:require('../assets/img/polski.png')
// },
{
value: 'ar',
label: 'عربي',
url:require('../assets/img/polski.png')
},
{
value: "tw", // zh-TW
label: "繁体中文",

8
src/views/exchangeStock/index.vue

@ -491,8 +491,11 @@
Exchange.getstockUserBalance(this.marketInfo.pair_name).then(data => {
// this.fromBalance = data[this.pair.from.toUpperCase()].usable_balance;
// this.toBalance = data[this.pair.to.toUpperCase()].usable_balance;
console.log(data[this.activeContract.coin_name].usable_balance,'111');
this.fromBalance = data[this.pair.from.toUpperCase()].usable_balance;
this.toBalance = data[this.pair.to.toUpperCase()].usable_balance;
this.toBalance = data[this.activeContract.coin_name].usable_balance;
}).catch(err => {
@ -504,6 +507,9 @@
//
update() {
this.getBalance();
setTimeout(()=>{
this.getBalance();
},2000)
this.getOrders();
this.getCurrencyExCny();
},

121
src/views/exchangeStock/make-deal.vue

@ -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": {
@ -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. 0000 3000
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)
@ -646,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}`;
}
}
@ -718,9 +813,18 @@ export default {
created() {
this.getCoinInfo()
this.tradingOpen()
this.startSchedule();
this.reset();
},
beforeDestroy() {
// this.clearSchedule();
if (this.timer) {
clearInterval(this.timer);
}
},
}
</script>
@ -822,4 +926,13 @@ export default {
.market-trade p{
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>

6
src/views/exchangeStock/order-list.vue

@ -101,9 +101,9 @@
<td>{{item.usable_balance}}</td>
<td>{{item.realtimePrice}}</td>
<td>{{item.cost_price}}</td>
<td>{{item.dayProfit}}</td>
<td>{{item.unRealProfit}}</td>
<td>{{item.profitRate}}</td>
<td :class="item.dayProfit>0?'increace':item.dayProfit<0?'decreace':''">{{item.dayProfit}}</td>
<td :class="item.unRealProfit>0?'increace':item.unRealProfit<0?'decreace':''">{{item.unRealProfit}}</td>
<td :class="item.profitRate>0?'increace':item.profitRate<0?'decreace':''">{{item.profitRate}}</td>
</tr>
</tbody>
</table>

Loading…
Cancel
Save