diff --git a/src/assets/js/common.js b/src/assets/js/common.js index 6455e08..49b280a 100644 --- a/src/assets/js/common.js +++ b/src/assets/js/common.js @@ -5,6 +5,7 @@ export default { //baseURL: '/api',//本地测试时用(解决跨域问题) baseURL: 'http://119.23.49.169:10601', //测试站使用 + //baseURL: 'http://192.168.1.99:10601', //本地测试 //Token名字 tokenKey: '', diff --git a/src/store/modules/trend.js b/src/store/modules/trend.js index 564df17..c7cb709 100644 --- a/src/store/modules/trend.js +++ b/src/store/modules/trend.js @@ -11,6 +11,8 @@ export default { myCollectList: [] ,//我的收藏 currentPair: null, //当前交易对 + buyList: [], //买盘 + sellList: [], //卖盘 }, mutations: { setCoin(state, data) { //币种 --资产模块 @@ -19,12 +21,16 @@ export default { setPair(state, data) { //交易对 -- 行情、币币模块 //console.log(JSON.stringify(data)); state.allPairList = data; - state.currentPair = data[0].childen[0].prices[0]; }, setTrend(state, data) { //行情 //console.log(JSON.stringify(data)); state.allTrendList = data; }, + setDepth(state, data) { //深度 + state.buyList = data.buyList; + state.sellList = data.sellList; + }, + setCollect(state, data) { //收藏 -- 自选模块 state.myCollectList = JSON.parse(data); }, @@ -63,6 +69,14 @@ export default { context.commit('setTrend', res.data); }) }, + getDepth(context, params) { //获取深度 + common.setItem('loading', true); //不显示loading + request.postAxios('/api/entrust/depth/list', params) + .then(res => { + context.commit('setDepth', res.data); + }) + }, + getCollect(context) { //获取收藏列表 request.getAxios('/api/user/config/list') .then(res => { diff --git a/src/views/coincoin/coincoin_trade.vue b/src/views/coincoin/coincoin_trade.vue index bdd9be5..ed909b7 100644 --- a/src/views/coincoin/coincoin_trade.vue +++ b/src/views/coincoin/coincoin_trade.vue @@ -36,7 +36,7 @@
- +
@@ -77,6 +77,10 @@ mainCoinBalance: '0', //主币余额 tradeCoinBalance: '0', //交易币余额 + + depthValue: 0, + + timers: '', //定时器 } }, computed: { @@ -125,13 +129,30 @@ sideToggle(val) { //左侧币种列表展开/收起 this.sideShow = val; }, - updateOrder() { + + getDepth() { //获取深度 + this.$store.dispatch('trend/getDepth', { + symbol: this.currentPair.symbolId, + depth: this.depthValue + }); + }, + chooseDepth(val) { //切换深度 + this.depthValue = val; + }, + updateOrder() { //更新订单 this.$refs.order.getOrderList(1); this.getBalance(); - } + }, + }, + beforeDestroy() { + clearInterval(this.timers); }, created() { this.initCoin(); + this.timers = setInterval(() => { + this.$store.dispatch('trend/getAllPair'); + this.getDepth(); + }, 1000); } } diff --git a/src/views/coincoin/components/trade_depth.vue b/src/views/coincoin/components/trade_depth.vue index 3114e56..dac96d4 100644 --- a/src/views/coincoin/components/trade_depth.vue +++ b/src/views/coincoin/components/trade_depth.vue @@ -17,12 +17,11 @@
-
    -
  • 9101.08
  • -
  • 0.0547
  • +
      +
    • {{item.price}}
    • +
    • {{item.deal}}
    • 1.44
    -
@@ -39,12 +38,11 @@
-
    -
  • 9101.08
  • -
  • 0.0547
  • +
      +
    • {{item.price}}
    • +
    • {{item.deal}}
    • 1.44
    -
@@ -61,7 +59,7 @@
- + @@ -75,42 +73,59 @@ import { mapState } from 'vuex' export default { name: 'tradeDepth', + props: { + depthValue: Number, + }, data() { return { - timer:'', + timers:'', depthListType: 1, //1全部 2买单 3卖单 - depthValue: 1, - depthOptions: [ - {value: 1, label: '深度1'}, - {value: 2, label: '深度2'}, - {value: 3, label: '深度3'}, - {value: 4, label: '深度4'}, - ] + depth: 0, //深度 + depthOptions: [ //深度 + {value: 0, label: '深度1'}, + {value: 1, label: '深度2'}, + {value: 2, label: '深度3'}, + {value: 3, label: '深度4'}, + ], } }, computed: { - ...mapState('trend', ['currentPair']), + ...mapState('trend', ['currentPair', 'buyList', 'sellList']), + + buyDepth() { + let list = []; + let buyLength = this.depthListType == 2 ? 30: 15; + + this.buyList.forEach((item, index) => { + if(index < buyLength) { + list.push(item) + } + }); + + return list; + }, + sellDepth() { + let list = []; + let sellLength = this.depthListType == 3 ? 30: 15; + + this.sellList.forEach((item, index) => { + if(index < sellLength) { + list.push(item) + } + }); + + return list; + }, }, methods: { - getDepth() { //获取深度盘口 - this.postAxios('/api/coin/price/getDepth', {symbolId: this.currentPair.symbolId}) - .then(data => { - console.log(JSON.stringify(data)) - }) - }, - chooseDepth(val) { //切换深度 - this.depthValue = val; + this.$emit('chooseDepth', val); }, changeList(val) { //切换列表类型 this.depthListType = val; } }, - mounted() { - this.getDepth(); - - } } diff --git a/src/views/index/components/price.vue b/src/views/index/components/price.vue index 0e8f6df..9de2389 100644 --- a/src/views/index/components/price.vue +++ b/src/views/index/components/price.vue @@ -27,8 +27,8 @@ priceList() { let list = []; - this.allTrendList.forEach((item, index) => { - if(index < 6) { + this.allTrendList.forEach((item) => { + if(item.caseCode == 1) { list.push(item) } }); diff --git a/src/views/release/components/release_depth.vue b/src/views/release/components/release_depth.vue index 3114e56..dac96d4 100644 --- a/src/views/release/components/release_depth.vue +++ b/src/views/release/components/release_depth.vue @@ -17,12 +17,11 @@
-
    -
  • 9101.08
  • -
  • 0.0547
  • +
      +
    • {{item.price}}
    • +
    • {{item.deal}}
    • 1.44
    -
@@ -39,12 +38,11 @@
-
    -
  • 9101.08
  • -
  • 0.0547
  • +
      +
    • {{item.price}}
    • +
    • {{item.deal}}
    • 1.44
    -
@@ -61,7 +59,7 @@
- + @@ -75,42 +73,59 @@ import { mapState } from 'vuex' export default { name: 'tradeDepth', + props: { + depthValue: Number, + }, data() { return { - timer:'', + timers:'', depthListType: 1, //1全部 2买单 3卖单 - depthValue: 1, - depthOptions: [ - {value: 1, label: '深度1'}, - {value: 2, label: '深度2'}, - {value: 3, label: '深度3'}, - {value: 4, label: '深度4'}, - ] + depth: 0, //深度 + depthOptions: [ //深度 + {value: 0, label: '深度1'}, + {value: 1, label: '深度2'}, + {value: 2, label: '深度3'}, + {value: 3, label: '深度4'}, + ], } }, computed: { - ...mapState('trend', ['currentPair']), + ...mapState('trend', ['currentPair', 'buyList', 'sellList']), + + buyDepth() { + let list = []; + let buyLength = this.depthListType == 2 ? 30: 15; + + this.buyList.forEach((item, index) => { + if(index < buyLength) { + list.push(item) + } + }); + + return list; + }, + sellDepth() { + let list = []; + let sellLength = this.depthListType == 3 ? 30: 15; + + this.sellList.forEach((item, index) => { + if(index < sellLength) { + list.push(item) + } + }); + + return list; + }, }, methods: { - getDepth() { //获取深度盘口 - this.postAxios('/api/coin/price/getDepth', {symbolId: this.currentPair.symbolId}) - .then(data => { - console.log(JSON.stringify(data)) - }) - }, - chooseDepth(val) { //切换深度 - this.depthValue = val; + this.$emit('chooseDepth', val); }, changeList(val) { //切换列表类型 this.depthListType = val; } }, - mounted() { - this.getDepth(); - - } } diff --git a/src/views/release/release_trade.vue b/src/views/release/release_trade.vue index 021d397..3e7a843 100644 --- a/src/views/release/release_trade.vue +++ b/src/views/release/release_trade.vue @@ -36,7 +36,7 @@
- +
@@ -77,6 +77,10 @@ mainCoinBalance: '0', //主币余额 tradeCoinBalance: '0', //交易币余额 + + depthValue: 0, + + timers: '', //定时器 } }, computed: { @@ -129,13 +133,30 @@ sideToggle(val) { //左侧币种列表展开/收起 this.sideShow = val; }, - updateOrder() { + + getDepth() { //获取深度 + this.$store.dispatch('trend/getDepth', { + symbol: this.currentPair.symbolId, + depth: this.depthValue + }); + }, + chooseDepth(val) { //切换深度 + this.depthValue = val; + }, + updateOrder() { //更新订单 this.$refs.order.getOrderList(1); this.getBalance(); - } + }, + }, + beforeDestroy() { + clearInterval(this.timers); }, created() { this.initCoin(); + this.timers = setInterval(() => { + this.$store.dispatch('trend/getAllPair'); + this.getDepth(); + }, 1000); } } diff --git a/src/views/user/shop_info.vue b/src/views/user/shop_info.vue index d9942f3..e38d999 100644 --- a/src/views/user/shop_info.vue +++ b/src/views/user/shop_info.vue @@ -184,7 +184,8 @@
- + +