StatisticsMobile.vue 8.0 KB

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