Browse Source

申购记录新增涨幅比和优化WS

master
ltlzx 4 years ago
parent
commit
6a3432dcb9
  1. 12
      src/components/KLine.vue
  2. 3
      src/i18n/cn.json
  3. 3
      src/i18n/en.json
  4. 3
      src/i18n/tw.json
  5. 1
      src/views/contract/handicap.vue
  6. 5
      src/views/contract/index.vue
  7. 148
      src/views/exchange/index.vue
  8. 1
      src/views/option/VDatafeed.js
  9. 38
      src/views/option/kline.vue
  10. 2
      src/views/purchase/index.vue

12
src/components/KLine.vue

@ -16,6 +16,7 @@ import Option from "@/api/option";
import Exchange from "@/api/exchange";
import tvStyle from "@/assets/js/tvStyle.js";
import { mapState } from "vuex";
import bus from "@/components/bus.js";
export default {
props: ["socket", "symbol", "priceDecimals"],
@ -365,7 +366,16 @@ export default {
}
},
created() {},
created() {
bus.$on('sendMsg', msg => {
this.model.subscribe([
{
cmd: "sub",
msg: `Kline_${this.symbol}_${this.interval}min`
}
]);
});
},
mounted() {
// ws

3
src/i18n/cn.json

@ -906,7 +906,8 @@
"k6": "全平成功",
"k7": "反向成功",
"k8": "请先登录进行申购",
"k9":"请输入认购码"
"k9":"请输入认购码",
"l1":"涨幅比例"
},
"otc": {
"a0": "请选择交易类型",

3
src/i18n/en.json

@ -971,7 +971,8 @@
"k6": "Completely successful",
"k7": "Reverse success",
"k8": "Please log in first to apply",
"k9":"Please enter the subscription code"
"k9":"Please enter the subscription code",
"l1":"Proportion of increase"
},
"otc": {
"a0": "Please select transaction type",

3
src/i18n/tw.json

@ -910,7 +910,8 @@
"k6": "全平成功",
"k7": "反向成功",
"k8": "請先登錄進行申購 ",
"k9":"請輸入認購碼"
"k9":"請輸入認購碼",
"l1":"漲幅比例"
},
"otc": {
"a0": "請選擇交易類型",

1
src/views/contract/handicap.vue

@ -190,7 +190,6 @@ export default {
this.linkSocket();
}
bus.$on('collapse', msg => {
// console.info(msg)
this.newPriceObj.price = (msg.close).toFixed(3);
this.$emit("input", this.newPriceObj);
});

5
src/views/contract/index.vue

@ -287,6 +287,11 @@ export default {
});
}
});
this.ws.on('close',()=>{
this.ws= new Socket(this.Globals.Server.Path.WS1),
console.log('链接关闭');
this.swapMarketList();
})
},
//
getMarketList() {

148
src/views/exchange/index.vue

@ -36,6 +36,7 @@ import Market from '@/api/market.js';
import Exchange from "@/api/exchange";
import Order from "@/api/order"
import Home from "@/api/home";
import bus from "@/components/bus.js";
export default {
components: {
@ -48,14 +49,14 @@ export default {
beforeCreate() {
this.ws = new Socket(`${this.Globals.Server.Path.WS}`);
// this.ws = new Socket(`${this.Globals.Server.Path.WS}`);
},
data() {
return {
isLianjie:false,
// `btcusdt` `/`
symbol: this.$route.params.symbol || null,
marketId: null,
@ -407,76 +408,87 @@ export default {
}, 100);
}).catch((res) => {});
},
initWs(){
this.ws = new Socket(`${this.Globals.Server.Path.WS}`);
this.ws.on("open", () => {
if(this.isLianjie){
bus.$emit('sendMsg');
this.isLianjie=false
}
//
this.initMarket();
// id
if (this.symbol) this.addSub();
})
this.ws.on("message", (response) => {
let {
data, //
sub, //
type, //
msg, //
code, //
} = response;
//
if (type == "ping") this.ws.send({
type: "pong"
});
switch (sub) {
case "exchangeMarketList":
this.marketList = data;
if (!this.symbol) { // symbol
this.symbol = _.nth(data).marketInfoList[0].symbol;
} else { // symbol
this.findMarketBySymbol();
}
break;
case `buyList_${this.symbol}`:
this.buyList = data;
break;
case `sellList_${this.symbol}`:
this.sellList = data;
break;
case `tradeList_${this.symbol}`:
if (type == "history") { //
this.trade = this.trade.concat(data);
} else if (type == "dynamic") { //
this.trade.unshift(data);
}
//
this.newTrade = _.nth(this.trade);
if (this.newTrade && this.newTrade.buy_user_id === this.userInfo.user_id || this.newTrade.sell_user_id == this.userInfo.user_id) this.update();
break;
}
});
this.ws.on("close", () => {
this.$message({
type: "error",
message: this.$t("nav.b8"),
duration: 2000,
});
this.isLianjie=true
this.initWs()
});
}
},
created() {
this.ws.on("open", () => {
//
this.initMarket();
// id
if (this.symbol) this.addSub();
})
this.ws.on("message", (response) => {
let {
data, //
sub, //
type, //
msg, //
code, //
} = response;
//
if (type == "ping") this.ws.send({
type: "pong"
});
switch (sub) {
case "exchangeMarketList":
this.marketList = data;
if (!this.symbol) { // symbol
this.symbol = _.nth(data).marketInfoList[0].symbol;
} else { // symbol
this.findMarketBySymbol();
}
break;
case `buyList_${this.symbol}`:
this.buyList = data;
break;
case `sellList_${this.symbol}`:
this.sellList = data;
break;
case `tradeList_${this.symbol}`:
if (type == "history") { //
this.trade = this.trade.concat(data);
} else if (type == "dynamic") { //
this.trade.unshift(data);
}
//
this.newTrade = _.nth(this.trade);
if (this.newTrade && this.newTrade.buy_user_id === this.userInfo.user_id || this.newTrade.sell_user_id == this.userInfo.user_id) this.update();
break;
}
});
this.ws.on("close", () => {
this.$message({
type: "error",
message: this.$t("nav.b8"),
duration: 2000,
});
});
this.initWs()
if (this.symbol) this.getCurrencyExCny();
this.indexList()
// this.update();

1
src/views/option/VDatafeed.js

@ -35,7 +35,6 @@ class VDatafeed {
}
getBars(symbolInfo, resolution, rangeStartDate, rangeEndDate, onDataCallback, onErrorCallback) {
console.info(resolution)
var onLoadedCallback = function onLoadedCallback(data) {
if (data && data.length) {

38
src/views/option/kline.vue

@ -122,9 +122,30 @@ data() {
sub: "",
isCreateSocket: false,
page: {},
tt:undefined
};
},
methods: {
reconnect() {
if(this.isCreateSocket) {
return;
};
let msgObj = {
cmd: "sub",
msg: this.sub,
};
this.isCreateSocket = true;
//
this.tt && clearTimeout(this.tt);
let th=this
th.tt = setTimeout(function () {
th.isCreateSocket = false;
th.linkSocket(() => {
th.ws.send(msgObj);
});
}, 4000);
},
// socket
linkSocket(call) {
const ws = new Socket(this.wsUrl);
@ -132,17 +153,28 @@ methods: {
this.ws = ws;
call && call();
});
ws.on("message", (res) => {
let { data, msg, code, sub, type, status, req, cmd } = res;
if (sub == this.sub && this.onRealtimeCallback) {
this.onRealtimeCallback(this.getMap(data));
bus.$emit('collapse', data);
this.onRealtimeCallback(this.getMap(data));
// console.info(data)
bus.$emit('collapse', data);
} else if (type == "ping" || cmd == "ping") {
this.ws.send({
cmd: "pong",
});
}
});
ws.on('close',()=>{
console.log('链接关闭');
this.reconnect();
})
ws.on('error',()=>{
console.log('发生异常了');
this.reconnect();
})
},
//
unsub(pair_id, timer) {
@ -207,7 +239,6 @@ methods: {
onErrorCallback
) {
// handleClick
console.info(resolution)
this.page[this.symbol] = this.page[this.symbol] || 1;
let page = this.page[this.symbol] > 3 ? 3 : this.page[this.symbol];
let data = {
@ -289,7 +320,6 @@ methods: {
initView() {
let _this = this;
let Tdata = new VDatafeed(this);
console.info(Tdata)
let widget=(_this.TView = new TradingView.widget({
width: "100%",
height: 590,

2
src/views/purchase/index.vue

@ -154,6 +154,7 @@
<th>{{$t('wallet.money')}}</th>
<th>{{$t('purchase.subscriptionCurrency')}}</th>
<th>{{$t('contract.b1')}}</th>
<th>{{$t('contract.l1')}}</th>
<th class="text-right">{{$t('wallet.status')}}</th>
</tr>
</thead>
@ -167,6 +168,7 @@
<td>{{ item.payment_amount }}</td>
<td>{{ item.payment_currency }}</td>
<td>{{ item.subscription_time|parseTime }}</td>
<td>{{ ( ((detail.issue_price-(item.payment_amount/item.subscription_currency_amount))/detail.issue_price)*100 ).toFixed(2) }}%</td>
<td class="text-right">
<span class="success">{{$t('wallet.success')}}</span>
</td>

Loading…
Cancel
Save