StatisticsMobile.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="statistics">
  3. <ul class="list-inline" :style="{top: widthTop + 'rem'}" :class="{no_tran: widthTop == 2.4}">
  4. <li v-for="item in itemData">
  5. <span v-text="item.id"></span>
  6. <span v-text="formatNumber(item.count)"></span>
  7. </li>
  8. </ul>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'StatisticsView',
  14. data () {
  15. return {
  16. step: 1,
  17. widthTop: 0,
  18. timerIndex: 0,
  19. timer: {} // 定时器实体
  20. }
  21. },
  22. mounted () {
  23. this.$nextTick(() => {
  24. this.changeInterval()
  25. })
  26. },
  27. methods: {
  28. changeInterval () {
  29. setInterval(() => {
  30. this.widthTop += -0.6
  31. if (this.widthTop < -2.4) {
  32. this.widthTop = 0.6
  33. }
  34. }, 3000)
  35. },
  36. formatNumber (num, type) {
  37. if (num.toString().indexOf('E') !== -1) {
  38. let arr = num.toString().split('E')
  39. num = arr[0] * Math.pow(10, arr[1])
  40. }
  41. if (num > 99999999) {
  42. let str2 = num.toString()
  43. num = Math.floor(num / 100000000)
  44. if (parseInt(str2.charAt(str2.length - 8)) > 8) {
  45. num = num + 1
  46. }
  47. num += '亿'
  48. } else if (num > 9999) {
  49. let str = num.toString()
  50. num = Math.floor(num / 10000)
  51. if (parseInt(str.charAt(str.length - 4)) > 4) {
  52. num = num + 1
  53. }
  54. num += '万'
  55. } else {
  56. if (type === 1 || type === 2) {
  57. num += '元'
  58. } else {
  59. num += ''
  60. }
  61. }
  62. return num
  63. },
  64. formatDouble (num) {
  65. if (num.toString().indexOf('E') !== -1) {
  66. let arr = num.toString().split('E')
  67. num = arr[0] * Math.pow(10, arr[1])
  68. }
  69. if (num > 99999999) {
  70. num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '亿'
  71. } else if (num > 9999) {
  72. num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '万'
  73. } else {
  74. num += ''
  75. }
  76. return num
  77. }
  78. },
  79. computed: {
  80. allCount () {
  81. return this.$store.state.count.allCount.data
  82. },
  83. inquirySheet () {
  84. let sheetNum = this.$store.state.count.inquirySheet.data.count
  85. return this.formatDouble(sheetNum)
  86. },
  87. inquirySheetLast () {
  88. let lastSheetNum = this.$store.state.count.inquirySheetLast.data.count
  89. return this.formatDouble(lastSheetNum)
  90. },
  91. all () {
  92. let count = this.$store.state.supplier.merchant.merchantAll.data
  93. return count.content ? count.totalElements : '0'
  94. },
  95. counts () {
  96. return this.$store.state.product.common.counts
  97. },
  98. itemData () {
  99. let str = []
  100. if (this.counts.data) {
  101. this.counts.data.forEach((value, key, $data) => {
  102. str.push({id: $data[key].item, count: $data[key].count, type: 1})
  103. })
  104. }
  105. if (this.allCount) {
  106. this.allCount.forEach((value, key, $data) => {
  107. str.push({id: $data[key].item, count: $data[key].count, type: 1})
  108. })
  109. }
  110. str.push({id: '本月询价单', count: this.$store.state.count.inquirySheet.data ? this.$store.state.count.inquirySheet.data.count : 0, type: 2})
  111. str.push({id: '上月询价单', count: this.$store.state.count.inquirySheetLast.data ? this.$store.state.count.inquirySheetLast.data.count : 0, type: 2})
  112. str.push({id: '供应商', count: this.all ? this.all : 0, type: 3})
  113. console.log(str)
  114. return str
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .statistics{
  121. position:relative;
  122. height: .6rem;
  123. border-radius:.3rem;
  124. background: #fff;
  125. margin:0 .05rem .2rem;
  126. overflow: hidden;
  127. ul{
  128. position:absolute;
  129. transition: .5s all linear;
  130. &:no_tran{
  131. transition:none;
  132. }
  133. li{
  134. width:50%;
  135. height:.6rem;
  136. line-height: .6rem;
  137. padding: 0 .3rem;
  138. text-align: center;
  139. font-size: .28rem;
  140. font-weight: bold;
  141. white-space: nowrap;
  142. overflow: hidden;
  143. vertical-align:top;
  144. span{
  145. margin: 0 .1rem;
  146. &:last-child{
  147. color:red;
  148. }
  149. }
  150. }
  151. }
  152. }
  153. </style>