sale.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div>
  3. <!-- 深度图 -->
  4. <!-- <div class="depth-map">
  5. <depth-map :serveSellList="sellList" :serveBuyList="buyList" />
  6. </div> -->
  7. <div class="d-flex fn-sm buy-and-sell" style="margin-bottom:150upx;">
  8. <div class="w-6/12 buy">
  9. <div class="d-flex justify-between p-xs">
  10. <div>{{$t('exchange.c5')}}</div>
  11. <div>{{$t('exchange.f3')}}</div>
  12. </div>
  13. <div class="d-flex item justify-between p-xs" v-for="(item,idx) in buyList" :key="idx">
  14. <div class="progress bg-buy-transparent transition-default" :style="{width:getValue(item.amount)+'%'}"></div>
  15. <div class="color-light">{{item.amount}}</div>
  16. <div class="color-buy">{{item.price}}</div>
  17. </div>
  18. </div>
  19. <div class="w-6/12 sell">
  20. <div class="d-flex justify-between p-xs">
  21. <div>{{$t('exchange.c5')}}</div>
  22. <div>{{$t('exchange.f4')}}</div>
  23. </div>
  24. <div class="d-flex item justify-between p-xs" v-for="(item,idx) in sellList" :key="idx">
  25. <div class="progress bg-sell-transparent transition-default" :style="{width:getValue(item.amount)+'%'}"></div>
  26. <div class="color-light">{{item.amount}}</div>
  27. <div class="color-buy">{{item.price}}</div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import depthMap from "./depth-map";
  35. import math from "@/utils/class/math";
  36. export default {
  37. props: {
  38. sellList: {
  39. default() {
  40. return [];
  41. },
  42. type: Array,
  43. },
  44. buyList: {
  45. default() {
  46. return [];
  47. },
  48. type: Array,
  49. },
  50. },
  51. components: {
  52. depthMap,
  53. },
  54. methods: {
  55. // 计算深度 当前数量 / 买卖最大值
  56. getValue(amount) {
  57. const arr = this.buyList.concat(this.sellList).map((item) => item.amount);
  58. let max = Math.max(...arr);
  59. return math.division(amount, max, 2) * 100;
  60. },
  61. },
  62. created() {},
  63. };
  64. </script>
  65. <style lang="scss" scoped>
  66. .buy-and-sell {
  67. .item {
  68. position: relative;
  69. .progress {
  70. position: absolute;
  71. height: 100%;
  72. top: 0;
  73. }
  74. }
  75. .buy {
  76. .progress {
  77. left: 0;
  78. }
  79. }
  80. .sell {
  81. .progress {
  82. right: 0;
  83. }
  84. }
  85. }
  86. </style>