1
jhzh
2025-04-14 a5601fbcdc19292b32423bea88e67fc9ab4422a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<template>
  <div class=" d-flex flex-col dep-list">
    <!-- 卖 -->
    <div class="d-flex justify-between fn-xs m-b-xs m-t-md" style="background: #F7F8FC;padding: 3px 40px;font-size: 15px;color: #9498A1;">
      <span>{{$t('exchange.d2')}}</span>
      <span>{{$t('exchange.c5')}}</span>
    </div>
    <div class=" overflow-scroll rotatebox" style="height: 148px;" v-if="symbol!='GITP/USDT'">
      <div class="rotateZ">
        <div
          class="d-flex  justify-between  align-center row"
          v-for="(item,idx) in showSellList"
          :key="idx"
          @click="$emit('price',item.price)"
          style="padding: 8px 40px;font-weight: bold;border-bottom: 1px solid #ECECEC;;"
          >
            <span style="color: #F6465D;" v-if="item.price>100">{{omitTo(item.price,2)}}</span>
            <span style="color: #F6465D;" v-if="item.price>1&&item.price<100">{{omitTo(item.price,4)}}</span>
            <span style="color: #F6465D;"  v-if="item.price<1">{{omitTo(item.price,6)}}</span>
          <span class="p-r-xs" style="color: #9498A1;">{{omitTo(item.amount,2)}}</span>
          <div
            class="proagess h-max bg-sell-transparent"
            :style="{width:getValue(item.amount)+'%'}"
          >
          </div>
        </div>
        
        <div class="border-t border-b p-y-xs" style="font-weight: bold;color: #2EBD85 !important;">
            <slot/>
        </div>
        <div class=" overflow-scroll">
          <div
            class="d-flex justify-between  align-center row"
            v-for="(item,idx) in showBuyList"
            :key="idx"
            @click="$emit('price',item.price)"
            style="padding: 8px 40px;font-weight: bold;border-bottom: 1px solid #ECECEC;;"
            >
                <span style="color: #00D094;" v-if="item.price>100">{{omitTo(item.price,2)}}</span>
                <span style="color: #00D094;" v-if="item.price>1&&item.price<100">{{omitTo(item.price,4)}}</span>
                <span style="color: #00D094;"  v-if="item.price<1">{{omitTo(item.price,6)}}</span>
            <span class="p-r-xs" style="color: #9498A1;">{{omitTo(item.amount,2)}}</span>
            <div class="proagess h-max bg-buy-transparent" :style="{width:getValue(item.amount)+'%'}"></div>
          </div>
      </div>
    </div>
    
    </div>
  </div>
</template>
<script>
import date from "@/utils/class/date";
import math from "@/utils/class/math";
export default {
  name: "buy-and-sell",
  props: {
    buyList: {
      default:()=> [],
      required: true,
      type: Array,
    },
    sellList: {
      default: ()=>[],
      required: true,
      type: Array,
    },
    max:{
      default:undefined,
      type:Number,
      required:false
    },
    contract:{
      default:undefined,
      type:Number,
      required:false
    },
    symbol: {
      default: undefined,
      type: String,
      required: false,
    },
  },
  components: {},
  computed: {
    showBuyList(){
      if(this.max){
        return this.buyList.splice(0,this.max)
      }
      return this.buyList
    },
    showSellList(){
      if(this.max&&this.contract==1){
        return this.sellList.splice(this.sellList.length-this.max,this.max)
      }
      if(this.max&&this.contract==0){
        return this.sellList.splice(0,this.max)
      }
      return this.sellList
    }
  },
  mounted() {
  },
  methods: {
    parseTime: date.parseTime,
    omitTo: math.omitTo,
     // 计算深度
    getValue(amount) {
      const arr = this.showBuyList.concat(this.showSellList).map((item) => item.amount);
      let max = Math.max(...arr);
      return math.division(amount, max, 2) * 100;
    },
  },
};
</script>
<style lang="scss" scoped>
.dep-list {
  max-height: 456px;
  .row {
    position: relative;
    .proagess {
      position: absolute;
      right: 0;
      top: 0;
      transition: width 0.3s;
    }
  }
}
.rotatebox {
  transform: rotateZ(-180deg);
  .rotateZ {
    transform: rotateZ(180deg);
  }
}
</style>