diff --git a/components/positionList/positionList.vue b/components/positionList/positionList.vue
index 12d0d8a..8f6edac 100644
--- a/components/positionList/positionList.vue
+++ b/components/positionList/positionList.vue
@@ -6,9 +6,9 @@
- {{ item.price }}
- {{ item.total }}
-
+ {{ parseFloat(item.price).toFixed(item.baseCoinScale) }}
+ {{ item.size }}
+
@@ -18,9 +18,9 @@
- {{ item.price }}
- {{ item.total }}
-
+ {{ parseFloat(item.price).toFixed(item.baseCoinScale) }}
+ {{ item.size }}
+
@@ -33,7 +33,15 @@ export default {
item: Object,
marketDetail: {
type: Object,
- default: () => {}
+ default: () => {
+
+ }
+ },
+ sum: {
+ type: Object,
+ default: () => {
+
+ }
},
bboList:{
type: Object,
@@ -43,9 +51,7 @@ export default {
data() {
return {
popoverVisible: false,
- depthValue: 1,
- sellList: 9,
- buyList: 10,
+
}
},
computed: {
diff --git a/components/transaction/transaction.vue b/components/transaction/transaction.vue
index fcd668c..0e28f38 100644
--- a/components/transaction/transaction.vue
+++ b/components/transaction/transaction.vue
@@ -86,6 +86,12 @@ export default {
return 'USDT'
}
},
+ type: { // 货币名称
+ type: String,
+ default() {
+ return 'buy'
+ }
+ },
coinPrice: { // 数字货币价格
type: Number,
default() {
@@ -107,7 +113,7 @@ export default {
},
data() {
return {
- type: 'buy',
+
priceSelectListShow: false,
priceTypeValue: 0,
priceTypeList: [
diff --git a/pages/markets/index.vue b/pages/markets/index.vue
index 1225c06..e0981ab 100644
--- a/pages/markets/index.vue
+++ b/pages/markets/index.vue
@@ -43,11 +43,11 @@
onShow() {
},
- onHide() {
- this.unsubWebSocket();
- },
- onUnload() {
- this.unsubWebSocket();
+ onHide() {
+ this.websock.closeSocket();
+ },
+ onUnload() {
+ this.websock.closeSocket();
},
computed: {
i18n() {
diff --git a/pages/markets/kLine.vue b/pages/markets/kLine.vue
index af6e4c2..26aefe0 100644
--- a/pages/markets/kLine.vue
+++ b/pages/markets/kLine.vue
@@ -1,41 +1,48 @@
- {{ 'BTC/USDT' }}
+ {{ symbol.pair }}
-
- 1M
-
- 30M
-
- 60M
-
- 1D
-
- 30D
-
+
+
+ 1min
+
+ 5min
+
+ 15min
+
+ 30min
+
+ 60min
+
+ 1day
+
+ 1week
+
+ 1mon
+
{{ i18n.BuyingPrice }}
-
- 0.87897874
- {{ item }}
-
+
+ {{parseFloat(item.size).toFixed(6)}}
+ {{ item.price }}
+
{{ i18n.Quantity }}
- {{ i18n.SellPrice20 }}
+ {{ i18n.SellPrice }}
-
- 0.87897874
- {{ item }}
-
+
+ {{parseFloat(item.size).toFixed(6)}}
+ {{ item.price }}
+
@@ -78,11 +85,11 @@
-
+
{{ i18n.open }}
-
+
{{ i18n.close }}
@@ -99,10 +106,16 @@
},
data() {
return {
- buyList: 7,
- sellList: 9,
- kdata: [],
- type:1
+ kdata: {},
+ type: '1min',
+ symbol: null,
+ marketDetail: {
+ close: 0,
+ usdRate: 0
+ },
+ bboList: {},
+ webSocketChannel: {},
+ sum: {}
};
},
@@ -112,12 +125,283 @@
},
},
onLoad() {
- this.kdata = this.splitData(ktest.JSON);
+ //this.kdata = this.splitData(ktest.JSON);
// console.log(this.kdata, 1111)
},
- onShow() {},
- methods: {
+ onShow() {
+ this.into();
+
+ },
+ onHide() {
+ this.websock.closeSocket();
+ },
+ onUnload() {
+ this.websock.closeSocket();
+ },
+
+ methods: {
+
into() {
+ this.symbol = uni.getStorageSync('symbol');
+ if (!this.symbol) {
+ // #ifdef H5
+ history.back()
+ // #endif
+
+ // #ifdef APP-PLUS
+ uni.navigateBack()
+ // #endif
+ }
+ this.getMarketDetail();
+ this.initWebSocket();
+ this.getBboList()
+ },
+ statisticsSum() {
+ this.sum.buy = 0
+ this.sum.sell = 0
+ console.log(this.sum.buy);
+
+ for (var buy in this.bboList.buy) {
+ if (buy >= 8) {
+ break;
+ }
+ this.sum.buy += parseFloat(this.bboList.buy[buy].size)
+ }
+ for (var sell in this.bboList.sell) {
+ if (sell >= 8) {
+ break;
+ }
+ this.sum.sell += parseFloat(this.bboList.sell[sell].size)
+ }
+
+ },
+ onChangeType(type) {
+ this.unsubkline();
+ this.type = type
+ this.subKHistory()
+ this.subkline();
+ },
+
+ formateDate(time) {
+ var date = new Date(parseInt(time * 1000));
+ var Y = date.getFullYear();
+ var M = '-' + (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
+ var D = '-' + date.getDate();
+ var h = ' ' + date.getHours();
+ var m = ':' + date.getMinutes();
+ var s = ':' + date.getSeconds();
+ var time;
+ if (this.type.indexOf('min') > -1) {
+ time = Y + M + D + h + m;
+ } else if (this.type === '1day' || this.type === '1week') {
+ time = Y + M + D;
+ } else {
+ time = Y + M;
+ }
+
+ return time;
+ },
+ getBboList() {
+ const bboList = this.$api.bboList({
+ "symbol": this.symbol.symbol
+ });
+ bboList.then(res => {
+ console.log(9999999,res)
+ this.bboList = res
+ this.statisticsSum();
+ })
+ .catch(e => {
+ console.log(e)
+ uni.showToast({
+ title: e,
+ icon: 'none',
+ duration: 2500
+ })
+ })
+ },
+ getMarketDetail() {
+ const marketDetail = this.$api.marketDetail({
+ "symbol": this.symbol.symbol
+ });
+ marketDetail.then(res => {
+ this.marketDetail = res
+
+ })
+ .catch(e => {
+ console.log(e)
+ uni.showToast({
+ title: e,
+ icon: 'none',
+ duration: 2500
+ })
+ })
+ },
+ initWebSocket() {
+
+
+ this.websock = new this.$websocket(this.$constant.WSSURL) // xxx 表示接口地址URL
+
+
+ var that = this
+ this.websock.getWebSocketMsg(data => {
+
+ if (data.channel === 'conn') {
+ that.websockId = data.data
+
+ that.subbbo()
+ that.submarketDetail()
+ that.subKHistory()
+ that.subkline();
+ } else if (data.channel === 'market.pairsgroup') {
+ that.symbolList = data.data.USDT;
+ } else if (data.channel === that.webSocketChannel.bbo) {
+ that.bboList = data.data;
+
+ } else if (data.channel === that.webSocketChannel.bbo) {
+ that.bboList = data.data;
+ that.statisticsSum();
+
+ } else if (data.channel === that.webSocketChannel.trade) {
+ that.tradeList = data.data;
+ } else if (data.channel === that.webSocketChannel.detail) {
+ that.marketDetail = data.data;
+ } else if (data.channel === that.webSocketChannel.kline) {
+ if (data.event === 'req') {
+ that.kdata = that.splitData(data.data)
+ } else {
+ that.upkline(data.data)
+ }
+
+ }
+ });
+ },
+ //订阅交易对
+ subKHistory() {
+ var toDate = parseInt(new Date().getTime() / 1000);
+ var num = 100000;
+ var fromDate = parseInt(new Date().getTime() / 1000);
+ switch (this.type) {
+ case '1min':
+ fromDate = fromDate - num;
+ break;
+ case '5min':
+ fromDate = fromDate - (5 * num);
+ break;
+ case '15min':
+ fromDate = fromDate - (15 * num);
+ break;
+ case '30min':
+ fromDate = fromDate - (30 * num);
+ break;
+ case '60min':
+ fromDate = fromDate - (60 * num);
+ break;
+ case '1day':
+ fromDate = fromDate - (60 * 24 * num);
+ break;
+ case '1week':
+ fromDate = fromDate - (60 * 24 * 7 * num);
+ break;
+ case '1mon':
+ fromDate = fromDate - (60 * 24 * 30 * num);
+ break;
+ }
+ this.webSocketChannel.kline = 'market.' + this.symbol.symbol + ".kline." + this.type;
+ const data = {
+ event: 'req',
+ type: 'kline',
+ id: this.websockId,
+ channel: [this.webSocketChannel.kline],
+ fromDate: parseInt(fromDate),
+ toDate: toDate
+ };
+
+ this.websock.webSocketSendMsg(data)
+ },
+ subkline() {
+ this.webSocketChannel.kline = 'market.' + this.symbol.symbol + ".kline." + this.type;
+ const data = {
+ event: 'sub',
+ type: 'kline',
+ id: this.websockId,
+ channel: [this.webSocketChannel.kline],
+
+ };
+
+ this.websock.webSocketSendMsg(data)
+ },
+
+ unsubkline() {
+ this.webSocketChannel.kline = 'market.' + this.symbol.symbol + ".kline." + this.type;
+ const data = {
+ event: 'un_sub',
+ type: 'kline',
+ id: this.websockId,
+ channel: [this.webSocketChannel.kline],
+
+ };
+
+ this.websock.webSocketSendMsg(data)
+ },
+ upkline(data) {
+
+ if (data.id === this.kdata.values[this.kdata.values.length - 1][5]) {
+ this.kdata.values.pop();
+ this.kdata.volumes.pop();
+ this.kdata.values.push([data.open, data.close, data.low, data.high, data.kTime, data.id]);
+ this.kdata.volumes.push([this.kdata.volumes.length, data.high, data.open > data.close ? 1 : -1])
+ } else {
+ this.kdata.values.push([data.open, data.close, data.low, data.high, data.kTime, data.id]);
+ this.kdata.volumes.push([this.kdata.volumes.length, this.kdata.volumes.length, data.high, data.open >
+ data.close ? 1 : -1
+ ])
+ this.kdata.categoryData.push(this.formateDate(data.kTime));
+ }
+ },
+ subbbo() {
+ this.webSocketChannel.bbo = 'market.' + this.symbol.symbol + ".bbo";
+ this.subWebSocket('bbo', [this.webSocketChannel.bbo])
+ },
+
+ unsubbbo() {
+ this.unsubWebSocket('bbo', [this.webSocketChannel.bbo])
+ },
+ subtrade() {
+ this.webSocketChannel.trade = 'market.' + this.symbol.symbol + ".trade";
+ this.subWebSocket('trade', [this.webSocketChannel.trade])
+ },
+
+ unsubtrade() {
+ this.unsubWebSocket('trade', [this.webSocketChannel.trade])
+ },
+ submarketDetail() {
+ this.webSocketChannel.detail = 'market.' + this.symbol.symbol + ".detail";
+ this.subWebSocket('detail', [this.webSocketChannel.detail])
+ },
+
+ unsubmarketDetail() {
+ this.unsubWebSocket('detail', [this.webSocketChannel.detail])
+ },
+
+ subWebSocket(type, channel) {
+ const data = {
+ event: 'sub',
+ type: type,
+ id: this.websockId,
+ channel: channel
+ };
+
+ this.websock.webSocketSendMsg(data)
+ console.log("websocket发送", data);
+ },
+ unsubWebSocket(type, channel) {
+ const data = {
+ event: 'un_sub',
+ type: type,
+ id: this.websockId,
+ channel: channel
+ };
+ this.websock.webSocketSendMsg(data)
},
splitData(rawData) {
@@ -125,15 +409,20 @@
let values = [];
let volumes = [];
for (let i = 0; i < rawData.length; i++) {
- categoryData.push(rawData[i].splice(0, 1)[0]);
- values.push(rawData[i]);
- volumes.push([i, rawData[i][4], rawData[i][0] > rawData[i][1] ? 1 : -1]);
+ var ldata = rawData[i];
+ categoryData.push(this.formateDate(ldata.kTime));
+
+ values.push([ldata.open, ldata.close, ldata.low, ldata.high, ldata.kTime, ldata.id]);
+ volumes.push([i, ldata.high, ldata.open > ldata.close ? 1 : -1]);
}
return {
categoryData: categoryData,
values: values,
- volumes: volumes
+ volumes: volumes,
+ webSocketChannel: this.webSocketChannel.kline
};
+
+
},
depthChange(e) {
console.log(e);
@@ -150,19 +439,16 @@
uni.navigateTo({
url,
});
- },
- openBtnClick(){
- // let categoryData = [];
- // let values = [];
- // let volumes = [];
- // this.kdata.values.pop();
- // this.kdata.volumes.pop();
- this.kdata.values.push([17827.33+Math.floor(Math.random()*100),
- 17829.73+Math.floor(Math.random()*100),
- 17799.8+Math.floor(Math.random()*100),
- 17877.84+Math.floor(Math.random()*100) , 85130000+Math.floor(Math.random()*100)])
- this.kdata.volumes.push([3140,1688777777,1])
- this.kdata.categoryData.push('2016-06-22')
+ },
+ btnClick(type) {
+ uni.setStorageSync('orderType',type);
+ // #ifdef H5
+ history.back()
+ // #endif
+
+ // #ifdef APP-PLUS
+ uni.navigateBack()
+ // #endif
}
},
@@ -172,7 +458,7 @@
let kline
export default {
mounted() {
- console.log('1111', this.kdata.categoryData);
+
if (typeof window.echarts === 'function') {
//this.initEcharts()
} else {
@@ -187,16 +473,20 @@
},
methods: {
- receive(newValue, oldValue, ownerVm, vm) {
-
- console.log('newValue', newValue)
+ receive(newValue, oldValue, ownerVm, vm) {
+
+ if (this.channel != newValue.webSocketChannel) {
+ this.is = false
+ }
+ this.channel = newValue.webSocketChannel
+
const script = document.createElement('script');
// view 层的页面运行在 www 根目录,其相对路径相对于 www 计算
script.src = './static/echarts.js';
script.onload = this.upData.bind(this);
document.head.appendChild(script);
-
-
+
+
},
calculateMA(dayCount, data) {
@@ -217,12 +507,13 @@
upData(myChart) {
const upColor = '#00C873';
const downColor = '#FF3750';
- var chartDom = document.getElementById('kline');
- if(!this.is){
- this.myChart = echarts.init(chartDom);
+ var chartDom = document.getElementById('kline');
+ if (!this.is) {
+ console.log("this.is11111111", this.is)
+ this.myChart = echarts.init(chartDom);
}
-
- this.is=true;
+
+ this.is = true;
var option;
this.myChart.setOption(
(option = {
@@ -245,8 +536,8 @@
axisLine: {
show: false,
onZero: false
- },
-
+ },
+
axisTick: {
show: false
},
@@ -280,12 +571,12 @@
max: 'dataMax'
}
],
- yAxis: [{
-
- scale: true,
-
- axisLine: {
-
+ yAxis: [{
+ position: 'right',
+ scale: true,
+
+ axisLine: {
+
show: false
},
axisTick: {
@@ -326,7 +617,7 @@
visualMap: {
show: false,
- seriesIndex: 1,
+ seriesIndex: 5,
dimension: 2,
pieces: [{
value: 1,
@@ -338,17 +629,17 @@
}
]
},
- grid: [{
- top: '8%',
- left: '50rpx',
- right: '10rpx',
- height: '60%',
-
+ grid: [{
+ top: '8%',
+ left: '10rpx',
+ right: '50rpx',
+ height: '60%',
+
backgroundColor: 'transparent',
},
{
- left: '0%',
- right: '0%',
+ left: '10rpx',
+ right: '50rpx',
top: '80%',
height: '16%'
}
@@ -369,7 +660,7 @@
}
],
series: [{
- name: 'Dow-Jones index',
+
type: 'candlestick',
data: this.kdata.values,
itemStyle: {
@@ -377,19 +668,20 @@
color0: downColor,
borderColor: undefined,
borderColor0: undefined
- },
- markLine: {
- symbol: ['none', 'none'],
- data: [
-
-
- {
- name: 'max line on close',
- type: 'max',
- valueDim: 'close'
- }
- ]
- },
+ },
+ markLine: {
+ symbol: ['none', 'none'],
+ data: [
+
+
+ {
+ name: 'max line on close',
+ type: 'max',
+ valueDim: 'highest'
+ }
+ ]
+ },
+
tooltip: {
formatter: function(param) {
param = param[0];
@@ -404,6 +696,47 @@
}
}
},
+ {
+ name: 'MA5',
+ type: 'line',
+ showSymbol: false,
+ data: this.calculateMA(5, this.kdata),
+ smooth: true,
+ lineStyle: {
+ opacity: 0.5
+ }
+ },
+ {
+ name: 'MA10',
+ type: 'line',
+ showSymbol: false,
+ data: this.calculateMA(10, this.kdata),
+ smooth: true,
+ lineStyle: {
+ opacity: 0.5
+ }
+ },
+ {
+ name: 'MA20',
+ type: 'line',
+ showSymbol: false,
+ data: this.calculateMA(20, this.kdata),
+ smooth: true,
+ lineStyle: {
+ opacity: 0.5
+ }
+ },
+ {
+ name: 'MA30',
+ type: 'line',
+ showSymbol: false,
+ data: this.calculateMA(30, this.kdata),
+ smooth: true,
+ lineStyle: {
+ opacity: 0.5
+ }
+ },
+
{
name: 'Volume',
type: 'bar',
@@ -419,8 +752,8 @@
]
}),
true
- );
-
+ );
+
}
},
watch: {
@@ -498,26 +831,29 @@
}
}
- .tab {
- display: flex;
- background:#000000;
- .item {
- height: 64rpx;
- line-height: 64rpx;
- flex: 1;
- font-size: 24rpx;
- text-align: center;
-
- &.select {
- background: rgba(0, 232, 162,0.3);
- border-radius: 19px;
- }
- }
-
-
+
+ .tab {
+ display: flex;
+ background: #000000;
+
+ .item {
+ height: 64rpx;
+ line-height: 64rpx;
+ flex: 1;
+ font-size: 24rpx;
+ text-align: center;
+
+ &.select {
+ background: rgba(0, 232, 162, 0.3);
+ border-radius: 19px;
+ }
+ }
+
+
}
+
.kline {
-
+
background: #000000;
}
@@ -533,7 +869,7 @@
display: flex;
font-size: 24rpx;
- .box {
+ .box {
padding-left: 32rpx;
flex: 1;
overflow: hidden;
diff --git a/pages/markets/trade.vue b/pages/markets/trade.vue
index e4e4815..4b8cbba 100644
--- a/pages/markets/trade.vue
+++ b/pages/markets/trade.vue
@@ -7,10 +7,11 @@
-
+
-
+
+
@@ -54,84 +55,115 @@
return {
popupShow: false,
symbolList: [],
- symbol: null,
- marketDetail:null,
- bboList:{},
- tradeList:{},
- webSocketChannel:{}
+ symbol: {},
+ marketDetail: {
+ close: 0,
+ usdRate: 0
+ },
+ bboList: {},
+ type:'buy',
+ webSocketChannel: {},
+ sum:{}
};
},
computed: {
i18n() {
return this.$t("markets");
},
+ },
+ onHide() {
+ this.websock.closeSocket();
+ },
+ onUnload() {
+ this.websock.closeSocket();
},
- onLoad() {
+ onLoad() {
+
+
+ },
+ onShow() {
this.getSymbolGroup();
this.initWebSocket();
- this.symbol=uni.getStorageSync('symbol');
- if(this.symbol!=null){
+ this.symbol = uni.getStorageSync('symbol');
+ if (this.symbol) {
this.getMarketDetail()
this.getBboList();
- this.getTradeList();
- }
-
-
- },
- onShow() {
- console.log(11111, uni.getStorageSync('symbol'));
+ }
+ this.type=uni.getStorageSync('orderType');
+ console.log(this.type)
+ this.type=this.type?this.type:'buy';
+ uni.removeStorageSync('orderType');
},
methods: {
- getTradeList(){
- const tradeList = this.$api.tradeList({
- "symbol": this.symbol.symbol
- });
- tradeList.then(res => {
- this.tradeList = res
+ statisticsSum(){
+ this.sum.buy=0
+ this.sum.sell=0
+ console.log(this.sum.buy);
- })
- .catch(e => {
- console.log(e)
- uni.showToast({
- title: e,
- icon: 'none',
- duration: 2500
- })
- })
- },
- getBboList(){
- const bboList = this.$api.bboList({
- "symbol": this.symbol.symbol
- });
- bboList.then(res => {
- this.bboList = res
-
- })
- .catch(e => {
- console.log(e)
- uni.showToast({
- title: e,
- icon: 'none',
- duration: 2500
- })
- })
- },
- getMarketDetail(){
- const marketDetail = this.$api.marketDetail({
- "symbol": this.symbol.symbol
- });
- marketDetail.then(res => {
- this.marketDetail = res
+ for(var buy in this.bboList.buy){
+ if(buy>=5){
+ break;
+ }
+ this.sum.buy+=parseFloat(this.bboList.buy[buy].size)
+ }
+ for(var sell in this.bboList.sell){
+ if(sell>=5){
+ break;
+ }
+ this.sum.sell+=parseFloat(this.bboList.sell[sell].size)
+ }
- })
- .catch(e => {
- console.log(e)
- uni.showToast({
- title: e,
- icon: 'none',
- duration: 2500
- })
- })
+ },
+ getTradeList() {
+ const tradeList = this.$api.tradeList({
+ "symbol": this.symbol.symbol
+ });
+ tradeList.then(res => {
+ this.tradeList = res
+
+ })
+ .catch(e => {
+ console.log(e)
+ uni.showToast({
+ title: e,
+ icon: 'none',
+ duration: 2500
+ })
+ })
+ },
+ getBboList() {
+ const bboList = this.$api.bboList({
+ "symbol": this.symbol.symbol
+ });
+ bboList.then(res => {
+ this.bboList = res
+ this.statisticsSum()
+ })
+ .catch(e => {
+ console.log(e)
+ uni.showToast({
+ title: e,
+ icon: 'none',
+ duration: 2500
+ })
+ })
+ },
+ getMarketDetail() {
+ const marketDetail = this.$api.marketDetail({
+ "symbol": this.symbol.symbol
+ });
+ marketDetail.then(res => {
+ this.marketDetail = res
+
+ })
+ .catch(e => {
+ console.log(e)
+ uni.showToast({
+ title: e,
+ icon: 'none',
+ duration: 2500
+ })
+ })
},
getSymbolGroup() {
const symbolGroup = this.$api.symbolGroup({
@@ -139,8 +171,13 @@
});
symbolGroup.then(res => {
this.symbolList = res.USDT
- if(this.symbol==null){
- this.symbol=this.symbolList[0]
+ this.symbol = uni.getStorageSync('symbol');
+ if (!this.symbol) {
+ this.symbol = this.symbolList[0]
+ this.getMarketDetail()
+ this.getBboList();
+ this.switchTo(this.symbol);
+
}
})
@@ -155,90 +192,90 @@
- },
- initWebSocket() {
-
-
- this.websock = new this.$websocket(this.$constant.WSSURL) // xxx 表示接口地址URL
-
-
- var that = this
- this.websock.getWebSocketMsg(data => {
-
- if (data.channel === 'conn') {
- that.websockId = data.data
- that.subpairsgroup()
- that.subbbo()
- that.subtrade()
- that.submarketDetail()
- } else if (data.channel === 'market.pairsgroup') {
- that.symbolList = data.data.USDT;
- }else if (data.channel === that.webSocketChannel.bbo) {
- that.bboList = data.data;
-
- }else if (data.channel === that.webSocketChannel.bbo) {
+ },
+ initWebSocket() {
+
+
+ this.websock = new this.$websocket(this.$constant.WSSURL) // xxx 表示接口地址URL
+
+
+ var that = this
+ this.websock.getWebSocketMsg(data => {
+
+ if (data.channel === 'conn') {
+ that.websockId = data.data
+ that.subpairsgroup()
+ that.subbbo()
+ that.submarketDetail()
+ } else if (data.channel === 'market.pairsgroup') {
+ that.symbolList = data.data.USDT;
+ } else if (data.channel === that.webSocketChannel.bbo) {
+ that.bboList = data.data;
+
+ } else if (data.channel === that.webSocketChannel.bbo) {
that.bboList = data.data;
-
- }else if(data.channel === that.webSocketChannel.trade){
- that.tradeList=data.data;
- }else if(data.channel === that.webSocketChannel.detail){
- that.marketDetail=data.data;
- }
- });
- },
- //订阅交易对
- subpairsgroup(){
- this.subWebSocket('pairsgroup',['market.pairsgroup'])
- },
- //取消订阅交易对
- unsubpairsgroup(){
- this.unsubWebSocket('pairsgroup',['market.pairsgroup'])
- },
- subbbo(){
- this.webSocketChannel.bbo='market.'+this.symbol.symbol+".bbo";
- this.subWebSocket('bbo',[this.webSocketChannel.bbo])
- },
-
- unsubbbo(){
- this.unsubWebSocket('bbo',[this.webSocketChannel.bbo])
- },
- subtrade(){
- this.webSocketChannel.trade='market.'+this.symbol.symbol+".trade";
- this.subWebSocket('trade',[this.webSocketChannel.trade])
- },
-
- unsubtrade(){
- this.unsubWebSocket('trade',[this.webSocketChannel.trade])
- },
- submarketDetail(){
- this.webSocketChannel.detail='market.'+this.symbol.symbol+".detail";
- this.subWebSocket('detail',[this.webSocketChannel.detail])
- },
-
- unsubmarketDetail(){
- this.unsubWebSocket('detail',[this.webSocketChannel.detail])
- },
-
- subWebSocket(type,channel) {
- const data = {
- event: 'sub',
- type: type,
- id: this.websockId,
- channel: channel
- };
-
- this.websock.webSocketSendMsg(data)
- console.log("websocket发送", data);
- },
- unsubWebSocket(type,channel) {
- const data = {
- event: 'un_sub',
- type: type,
- id: this.websockId,
- channel: channel
- };
- this.websock.webSocketSendMsg(data)
-
+ that.statisticsSum();
+
+ } else if (data.channel === that.webSocketChannel.trade) {
+ that.tradeList = data.data;
+ } else if (data.channel === that.webSocketChannel.detail) {
+ that.marketDetail = data.data;
+ }
+ });
+ },
+ //订阅交易对
+ subpairsgroup() {
+ this.subWebSocket('pairsgroup', ['market.pairsgroup'])
+ },
+ //取消订阅交易对
+ unsubpairsgroup() {
+ this.unsubWebSocket('pairsgroup', ['market.pairsgroup'])
+ },
+ subbbo() {
+ this.webSocketChannel.bbo = 'market.' + this.symbol.symbol + ".bbo";
+ this.subWebSocket('bbo', [this.webSocketChannel.bbo])
+ },
+
+ unsubbbo() {
+ this.unsubWebSocket('bbo', [this.webSocketChannel.bbo])
+ },
+ subtrade() {
+ this.webSocketChannel.trade = 'market.' + this.symbol.symbol + ".trade";
+ this.subWebSocket('trade', [this.webSocketChannel.trade])
+ },
+
+ unsubtrade() {
+ this.unsubWebSocket('trade', [this.webSocketChannel.trade])
+ },
+ submarketDetail() {
+ this.webSocketChannel.detail = 'market.' + this.symbol.symbol + ".detail";
+ this.subWebSocket('detail', [this.webSocketChannel.detail])
+ },
+
+ unsubmarketDetail() {
+ this.unsubWebSocket('detail', [this.webSocketChannel.detail])
+ },
+
+ subWebSocket(type, channel) {
+ const data = {
+ event: 'sub',
+ type: type,
+ id: this.websockId,
+ channel: channel
+ };
+
+ this.websock.webSocketSendMsg(data)
+ console.log("websocket发送", data);
+ },
+ unsubWebSocket(type, channel) {
+ const data = {
+ event: 'un_sub',
+ type: type,
+ id: this.websockId,
+ channel: channel
+ };
+ this.websock.webSocketSendMsg(data)
+
},
depthChange(e) {
console.log(e);
@@ -260,18 +297,15 @@
* 切换当前交易货币对
*/
switchTo(item) {
- this.popupShow = false;
-
- this.unsubbbo()
- this.unsubtrade()
- this.unsubmarketDetail()
- this.symbol=item;
- uni.setStorageSync('symbol',this.symbol);
- this.getMarketDetail()
- this.getBboList();
- this.getTradeList();
- this.subbbo()
- this.subtrade()
+ this.popupShow = false;
+
+ this.unsubbbo()
+ this.unsubmarketDetail()
+ this.symbol = item;
+ uni.setStorageSync('symbol', this.symbol);
+ this.getMarketDetail()
+ this.getBboList();
+ this.subbbo()
this.submarketDetail()
}
diff --git a/utils/axios.js b/utils/axios.js
index c557e0f..6914635 100644
--- a/utils/axios.js
+++ b/utils/axios.js
@@ -132,10 +132,10 @@ service.interceptors.request.use(
//配置成功后的拦截器
service.interceptors.response.use(res => {
- console.log('过期了吗', res)
- uni.hideLoading()
+
+ uni.hideLoading()
+
res=res.data;
- console.log('11111', res)
// console.log(res)
// console.log(res.data)
// console.log(res.data.data[0].nameAlias)
diff --git a/utils/language/en_US.js b/utils/language/en_US.js
index 24663ff..424f30f 100644
--- a/utils/language/en_US.js
+++ b/utils/language/en_US.js
@@ -141,7 +141,7 @@ export default {
MarketTrades:'Market Trades',
Quantity:'Quantity',
BuyingPrice:'Buying Price',
- SellPrice20:'Sell Price20',
+ SellPrice:'Sell Price',
open:'Open',
},
diff --git a/utils/websocket.js b/utils/websocket.js
index 9d55568..06089f8 100644
--- a/utils/websocket.js
+++ b/utils/websocket.js
@@ -165,15 +165,22 @@ class WebSocketClass {
// 关闭ws方法
closeSocket() {
if (this.ws) {
- this.userClose = true;
- this.ws.close({
- success(res) {
- console.log("关闭成功", res)
- },
- fail(err) {
- console.log("关闭失败", err)
- }
- });
+ this.userClose = true;
+ // #ifdef H5
+ this.ws && this.ws.close();
+ // #endif
+
+ // #ifdef APP-PLUS
+ this.ws.close({
+ success(res) {
+ console.log("关闭成功", res)
+ },
+ fail(err) {
+ console.log("关闭失败", err)
+ }
+ });
+ // #endif
+
}
}