@@ -16,37 +16,55 @@ export default {
1616 getCutted ( val ) {
1717 return Math . round ( ( val + Number . EPSILON ) * 100 ) / 100 ;
1818 } ,
19+ countZerosAfterDecimal ( number ) {
20+ const decimalPart = number . toString ( ) . split ( "." ) [ 1 ] ;
21+ let zeroCount = 0 ;
22+ if ( decimalPart > 0 ) {
23+ for ( let i = 0 ; i < decimalPart . length ; i ++ ) {
24+ if ( decimalPart [ i ] === "0" ) {
25+ zeroCount ++ ;
26+ } else {
27+ break ;
28+ }
29+ }
30+ }
31+ return zeroCount ;
32+ } ,
1933 getCoolTrade ( sum , cur ) {
20- sum = typeof sum !== "undefined" ? parseFloat ( sum ) : 0 ;
21- let result = sum ;
34+ if ( sum < 1 && this . countZerosAfterDecimal ( sum ) > 3 ) {
35+ return floor10 ( sum , - 8 ) . toFixed ( 8 ) ;
36+ } else {
37+ sum = typeof sum !== "undefined" ? parseFloat ( sum ) : 0 ;
38+ let result = sum ;
2239
23- if (
24- cur &&
25- this . isFiat ( cur ) &&
26- [ "BTC" , "ETH" , "BCH" ] . includes ( this . currentBaseCurrency )
27- ) {
28- if ( sum >= 100 ) {
29- result = floor10 ( sum , - 2 ) . toFixed ( 2 ) ;
40+ if (
41+ cur &&
42+ this . isFiat ( cur ) &&
43+ [ "BTC" , "ETH" , "BCH" ] . includes ( this . currentBaseCurrency )
44+ ) {
45+ if ( sum >= 100 ) {
46+ result = floor10 ( sum , - 2 ) . toFixed ( 2 ) ;
47+ } else {
48+ result = floor10 ( sum , - 4 ) . toFixed ( 4 ) ;
49+ }
50+ } else if ( cur && this . isFiat ( cur ) ) {
51+ if ( sum >= 10000 ) {
52+ result = floor10 ( sum , 0 ) . toFixed ( 0 ) ;
53+ } else if ( sum >= 1000 ) {
54+ result = floor10 ( sum , - 1 ) . toFixed ( 1 ) ;
55+ } else if ( sum >= 100 ) {
56+ result = floor10 ( sum , - 2 ) . toFixed ( 2 ) ;
57+ } else if ( sum >= 10 ) {
58+ result = floor10 ( sum , - 3 ) . toFixed ( 3 ) ;
59+ } else {
60+ result = floor10 ( sum , - 4 ) . toFixed ( 4 ) ;
61+ }
3062 } else {
31- result = floor10 ( sum , - 4 ) . toFixed ( 4 ) ;
63+ result = floor10 ( sum , - 8 ) . toFixed ( 8 ) ;
3264 }
33- } else if ( cur && this . isFiat ( cur ) ) {
34- if ( sum >= 10000 ) {
35- result = floor10 ( sum , 0 ) . toFixed ( 0 ) ;
36- } else if ( sum >= 1000 ) {
37- result = floor10 ( sum , - 1 ) . toFixed ( 1 ) ;
38- } else if ( sum >= 100 ) {
39- result = floor10 ( sum , - 2 ) . toFixed ( 2 ) ;
40- } else if ( sum >= 10 ) {
41- result = floor10 ( sum , - 3 ) . toFixed ( 3 ) ;
42- } else {
43- result = floor10 ( sum , - 4 ) . toFixed ( 4 ) ;
44- }
45- } else {
46- result = floor10 ( sum , - 8 ) . toFixed ( 8 ) ;
47- }
4865
49- return result ;
66+ return result ;
67+ }
5068 } ,
5169 } ,
5270} ;
0 commit comments