StatisticsMobile.vue 5.7 KB

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