StatisticsMobile.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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">
  5. <span class="title"><i class="icon" :class="'icon' + index" ></i></span>
  6. <span class="number" v-if="item.type === 2">
  7. <span v-html="formatDouble(item.count)"></span>
  8. <span class="unit">条</span>
  9. </span>
  10. <span class="number" v-else>
  11. <span v-html="formatNumber(item.count, index)"></span>
  12. <span class="unit" v-if="item.type === 3">家</span>
  13. </span>
  14. </li>
  15. </ul>
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. name: 'StatisticsView',
  21. data () {
  22. return {
  23. step: 1,
  24. widthTop: 0,
  25. timerIndex: 0,
  26. timer: {}, // 定时器实体
  27. imgbox: {
  28. 'src': ''
  29. }
  30. }
  31. },
  32. mounted () {
  33. this.$nextTick(() => {
  34. this.changeInterval()
  35. })
  36. },
  37. methods: {
  38. changeInterval () {
  39. setInterval(() => {
  40. this.widthTop += -0.6
  41. if (this.widthTop === -2.4) {
  42. this.widthTop = 0
  43. }
  44. }, 3000)
  45. },
  46. formatNumber (num, type) {
  47. if (num.toString().indexOf('E') !== -1) {
  48. let arr = num.toString().split('E')
  49. num = arr[0] * Math.pow(10, arr[1])
  50. }
  51. if (num > 99999999) {
  52. let str2 = num.toString()
  53. num = Math.floor(num / 100000000)
  54. if (parseInt(str2.charAt(str2.length - 8)) > 8) {
  55. num = num + 1
  56. }
  57. num = num + '<span style="color: #333">亿</span>'
  58. } else if (num > 9999) {
  59. let str = num.toString()
  60. num = Math.floor(num / 10000)
  61. if (parseInt(str.charAt(str.length - 4)) > 4) {
  62. num = num + 1
  63. }
  64. num += '<span style="color: #333">万</span>'
  65. } else {
  66. if (type === 6 || type === 7) {
  67. num += '<span style="color: #333">元</span>'
  68. } else {
  69. num += ''
  70. }
  71. }
  72. return num
  73. },
  74. formatDouble (num) {
  75. console.log(11)
  76. if (num.toString().indexOf('E') !== -1) {
  77. let arr = num.toString().split('E')
  78. num = arr[0] * Math.pow(10, arr[1])
  79. }
  80. if (num > 99999999) {
  81. num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '<span style="color: #333">亿</span>'
  82. } else if (num > 9999) {
  83. num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '<span style="color: #333">万</span>'
  84. } else {
  85. num += ''
  86. }
  87. return num
  88. }
  89. },
  90. computed: {
  91. allCount () {
  92. return this.$store.state.count.allCount.data
  93. },
  94. inquirySheet () {
  95. let sheetNum = this.$store.state.count.inquirySheet.data.count
  96. return this.formatDouble(sheetNum)
  97. },
  98. inquirySheetLast () {
  99. let lastSheetNum = this.$store.state.count.inquirySheetLast.data.count
  100. return this.formatDouble(lastSheetNum)
  101. },
  102. all () {
  103. let count = this.$store.state.supplier.merchant.merchantAll.data
  104. return count.content ? count.totalElements : '0'
  105. },
  106. counts () {
  107. return this.$store.state.product.common.counts
  108. },
  109. itemData () {
  110. let str = []
  111. if (this.counts.data) {
  112. this.counts.data.forEach((value, key, $data) => {
  113. str.push({id: $data[key].item, count: $data[key].count, type: 1})
  114. })
  115. }
  116. str.push({id: '供应商', count: this.all ? this.all : 0, type: 3})
  117. str.push({id: '本月询价单', count: this.$store.state.count.inquirySheet.data ? this.$store.state.count.inquirySheet.data.count : 0, type: 2})
  118. str.push({id: '上月询价单', count: this.$store.state.count.inquirySheetLast.data ? this.$store.state.count.inquirySheetLast.data.count : 0, type: 2})
  119. if (this.allCount) {
  120. this.allCount.forEach((value, key, $data) => {
  121. str.push({id: $data[key].item, count: $data[key].count, type: 1})
  122. })
  123. }
  124. str = [str[1], str[2], str[0], ...str.slice(3, 6), str[7], str[6]]
  125. return str
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .statistics{
  132. position:relative;
  133. height: .6rem;
  134. border-radius:.3rem;
  135. background: #fff;
  136. margin:0 .05rem .2rem;
  137. overflow: hidden;
  138. ul{
  139. position:absolute;
  140. transition: .5s all linear;
  141. &:no_tran{
  142. transition:none;
  143. }
  144. li{
  145. width:50%;
  146. height:.6rem;
  147. line-height: .6rem;
  148. /*padding: 0 .3rem;*/
  149. /*text-align: center;*/
  150. font-size: .28rem;
  151. font-weight: bold;
  152. white-space: nowrap;
  153. overflow: hidden;
  154. vertical-align:top;
  155. &:nth-child(odd){
  156. &::after{
  157. content: '';
  158. display: inline-block;
  159. width: 0.02rem;
  160. height: 0.3rem;
  161. background-color: #9c9c9c;
  162. position: relative;
  163. top: 3px;
  164. }
  165. }
  166. span{
  167. &.title{
  168. display: inline-block;
  169. width: 1.85rem;
  170. height:.6rem;
  171. line-height: .6rem;
  172. vertical-align:middle;
  173. margin-left: 0.15rem;
  174. i{
  175. &.icon{
  176. display: inline-block;
  177. width: 100%;
  178. height: .6rem;
  179. }
  180. &.icon0{
  181. background:url('/images/mobile/@2x/home/count1.jpg') right no-repeat;
  182. background-size: auto 0.3rem;
  183. }
  184. &.icon1{
  185. background:url('/images/mobile/@2x/home/count2.jpg') right no-repeat;
  186. background-size: auto 0.3rem;
  187. }
  188. &.icon2{
  189. background:url('/images/mobile/@2x/home/count3.jpg') right no-repeat;
  190. background-size: auto 0.3rem;
  191. }
  192. &.icon3{
  193. background:url('/images/mobile/@2x/home/count4.jpg') right no-repeat;
  194. background-size: auto 0.3rem;
  195. }
  196. &.icon4{
  197. background:url('/images/mobile/@2x/home/count5.jpg') right no-repeat;
  198. background-size: auto 0.3rem;
  199. }
  200. &.icon5{
  201. background:url('/images/mobile/@2x/home/count6.jpg') right no-repeat;
  202. background-size: auto 0.3rem;
  203. }
  204. &.icon6{
  205. background:url('/images/mobile/@2x/home/count7.jpg') right no-repeat;
  206. background-size: auto 0.3rem;
  207. }
  208. &.icon7{
  209. background:url('/images/mobile/@2x/home/count8.jpg') right no-repeat;
  210. background-size: auto 0.3rem;
  211. }
  212. }
  213. }
  214. &.number{
  215. display: inline-block;
  216. color:red;
  217. width: 1.6rem;
  218. font-size: 0.32rem;
  219. height: .6rem;
  220. vertical-align:middle;
  221. padding-left: 0.14rem;
  222. line-height:.6rem;
  223. .unit{
  224. color: #333;
  225. }
  226. }
  227. }
  228. &:nth-child(2), &:nth-child(4){
  229. span{
  230. &.title{
  231. width: 1.4rem;
  232. }
  233. }
  234. }
  235. &:nth-child(6){
  236. span{
  237. &.title{
  238. width: 1.83rem;
  239. margin-left: 0rem;
  240. }
  241. }
  242. }
  243. &:nth-child(8){
  244. span{
  245. &.title{
  246. width: 1.3rem;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>