StatisticsMobile.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div class="statistics">
  3. <ul class="list-inline pull-left" ref="pingdanListWrapperL" :style="'top: -' + 0.7 * timerIndexL + 'rem'" :class="{'topL': isTopL}">
  4. <li v-for="(item, index) in itemLeft">
  5. <span class="number">
  6. <span class="name" v-html="nameLeft[index]"></span>
  7. <span class="num" v-html="formatNumber(item.count, item.type)"></span>
  8. <span class="unit" v-if="item.type === 3">家</span>
  9. </span>
  10. </li>
  11. </ul>
  12. <ul class="list-inline pull-right" ref="pingdanListWrapperR" :style="'top: -' + 0.7 * timerIndexR + 'rem'" :class="{'topR': isTopR}">
  13. <li v-for="(item, index) in itemRight">
  14. <span class="number" v-if="item.type === 2">
  15. <span class="name" v-html="nameRight[index]"></span>
  16. <span class="month" v-if="item.id === '上月询价单'">(上月)</span>
  17. <span class="month" v-if="item.id === '本月询价单'">(本月)</span>
  18. <span class="num" v-html="formatDouble(item.count)"></span>
  19. <span class="unit">条</span>
  20. </span>
  21. <span class="number" v-else>
  22. <span class="name" v-html="nameRight[index]"></span>
  23. <span class="num" v-html="formatNumber(item.count, item.type)"></span>
  24. </span>
  25. </li>
  26. </ul>
  27. </div>
  28. </template>
  29. <script>
  30. export default {
  31. name: 'StatisticsView',
  32. data () {
  33. return {
  34. step: 1,
  35. nameLeft: ['现货', '品牌', '规格书', '平台用户', '店铺'],
  36. nameRight: ['询价求购', '询价求购', '上年交易', '本年交易'],
  37. topLeft: 0,
  38. topRight: 0,
  39. // timer: {},
  40. // timerIndex: 0,
  41. timerIndexL: 0,
  42. timerIndexR: 0,
  43. isTopL: false,
  44. isTopR: false,
  45. timerL: {},
  46. timerR: {}, // 定时器实体
  47. imgbox: {
  48. 'src': ''
  49. }
  50. }
  51. },
  52. mounted () {
  53. this.$nextTick(() => {
  54. this.changeIntervalL(true)
  55. this.changeIntervalR(true)
  56. })
  57. },
  58. methods: {
  59. changeIntervalL: function (flag) {
  60. if (flag) {
  61. this.timerL = setInterval(() => {
  62. this.isTopL = false
  63. let isChange = true
  64. this.timerIndexL++
  65. if (this.$refs.pingdanListWrapperL) {
  66. let _transitionEvent = this.baseUtils.whichTransitionEvent()
  67. _transitionEvent && this.$refs.pingdanListWrapperL.addEventListener(
  68. _transitionEvent, () => {
  69. if (isChange) {
  70. let title = this.itemLeft.shift()
  71. let name = this.nameLeft.shift()
  72. this.itemLeft.push(title)
  73. this.nameLeft.push(name)
  74. this.timerIndexL = 0
  75. isChange = false
  76. this.isTopL = true
  77. }
  78. })
  79. }
  80. }, 2400)
  81. } else {
  82. clearInterval(this.timerL)
  83. }
  84. },
  85. changeIntervalR: function (flag) {
  86. if (flag) {
  87. this.timerR = setInterval(() => {
  88. this.isTopR = false
  89. let isChange = true
  90. this.timerIndexR++
  91. if (this.$refs.pingdanListWrapperR) {
  92. let _transitionEvent = this.baseUtils.whichTransitionEvent()
  93. _transitionEvent && this.$refs.pingdanListWrapperR.addEventListener(
  94. _transitionEvent, () => {
  95. if (isChange) {
  96. let title = this.itemRight.shift()
  97. let name = this.nameRight.shift()
  98. this.itemRight.push(title)
  99. this.nameRight.push(name)
  100. this.timerIndexR = 0
  101. isChange = false
  102. this.isTopR = true
  103. }
  104. })
  105. }
  106. }, 3000)
  107. } else {
  108. clearInterval(this.timerR)
  109. }
  110. },
  111. formatNumber (num, type) {
  112. if (num === '' || !num) return false
  113. if (num.toString().indexOf('E') !== -1) {
  114. let arr = num.toString().split('E')
  115. num = arr[0] * Math.pow(10, arr[1])
  116. }
  117. if (num > 99999999) {
  118. let str2 = num.toString()
  119. num = Math.floor(num / 100000000)
  120. if (parseInt(str2.charAt(str2.length - 8)) > 8) {
  121. num = num + 1
  122. }
  123. num = num + '亿'
  124. } else if (num > 9999) {
  125. let str = num.toString()
  126. num = Math.floor(num / 10000)
  127. if (parseInt(str.charAt(str.length - 4)) > 4) {
  128. num = num + 1
  129. }
  130. num += '万'
  131. } else {
  132. if (type === 4) {
  133. num += '元'
  134. } else if (type === 1) {
  135. num += '个'
  136. } else {
  137. num += ''
  138. }
  139. }
  140. return num || 0
  141. },
  142. formatDouble (num) {
  143. if (num === '' || !num) return false
  144. if (num.toString().indexOf('E') !== -1) {
  145. let arr = num.toString().split('E')
  146. num = arr[0] * Math.pow(10, arr[1])
  147. }
  148. if (num > 99999999) {
  149. num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '亿'
  150. } else if (num > 9999) {
  151. num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '万'
  152. } else {
  153. num += ''
  154. }
  155. return num || 0
  156. }
  157. },
  158. computed: {
  159. allCount () {
  160. return this.$store.state.count.allCount.data
  161. },
  162. inquirySheet () {
  163. let sheetNum = this.$store.state.count.inquirySheet.data
  164. return sheetNum ? this.formatDouble(sheetNum.count) : 0
  165. },
  166. inquirySheetLast () {
  167. let lastSheetNum = this.$store.state.count.inquirySheetLast.data
  168. return lastSheetNum ? this.formatDouble(lastSheetNum.count) : 0
  169. },
  170. all () {
  171. let count = this.$store.state.supplier.merchant.merchantAll.data
  172. return count.content ? count.totalElements : '0'
  173. },
  174. counts () {
  175. return this.$store.state.product.common.counts
  176. },
  177. list () {
  178. let list = JSON.parse(JSON.stringify(this.$store.state.provider.stores.storeList.data))
  179. // console.log(list)
  180. return list.totalElements
  181. },
  182. itemData () {
  183. let str = []
  184. if (this.counts.data) {
  185. this.counts.data.forEach((value, key, $data) => {
  186. str.push({id: $data[key].item, count: $data[key].count, type: 1})
  187. })
  188. }
  189. str.push({id: '供应商', count: this.all ? this.all : 0, type: 3})
  190. str.push({id: '本月询价单', count: this.$store.state.count.inquirySheet.data ? this.$store.state.count.inquirySheet.data.count : 0, type: 2})
  191. str.push({id: '上月询价单', count: this.$store.state.count.inquirySheetLast.data ? this.$store.state.count.inquirySheetLast.data.count : 0, type: 2})
  192. if (this.allCount) {
  193. this.allCount.forEach((value, key, $data) => {
  194. str.push({id: $data[key].item, count: $data[key].count, type: 4})
  195. })
  196. }
  197. str.push({id: '店铺', count: this.list ? this.list : 0, type: 3})
  198. str = [str[1], str[0], str[2], str[3], str[8], str[5], str[4], str[6], str[7]]
  199. return str
  200. },
  201. itemLeft () {
  202. return this.itemData.slice(0, 5)
  203. },
  204. itemRight () {
  205. return this.itemData.slice(5, 9)
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. .statistics{
  212. position:relative;
  213. height: 0.7rem;
  214. border-radius:.48rem;
  215. background: #fff;
  216. margin:0 .05rem .2rem;
  217. overflow: hidden;
  218. background: url('/images/mobile/@2x/home/countnewbg1.png') no-repeat center;
  219. background-size: auto 0.69rem;
  220. ul{
  221. width:50%;
  222. position:relative;
  223. transition: .5s all linear;
  224. &.topL {
  225. transition: top 0s;
  226. -moz-transition: top 0s; /* Firefox 4 */
  227. -webkit-transition: top 0s; /* Safari and Chrome */
  228. -o-transition: top 0s; /* Opera */
  229. }
  230. &.topR {
  231. transition: top 0s;
  232. -moz-transition: top 0s; /* Firefox 4 */
  233. -webkit-transition: top 0s; /* Safari and Chrome */
  234. -o-transition: top 0s; /* Opera */
  235. }
  236. &:first-child{
  237. margin-left: .0rem;
  238. }
  239. &:no_tran{
  240. transition:none;
  241. }
  242. li{
  243. width:100%;
  244. text-align: center;
  245. height:0.7rem;
  246. line-height: 0.7rem;
  247. font-size: .28rem;
  248. font-weight: bold;
  249. white-space: nowrap;
  250. overflow: hidden;
  251. vertical-align:top;
  252. span{
  253. &.number{
  254. display: inline-block;
  255. color:red;
  256. font-size: 0.32rem;
  257. height: .7rem;
  258. line-height:.7rem;
  259. font-weight: bold;
  260. .name, .month{
  261. color: #fff;
  262. }
  263. .month{
  264. font-size: 0.22rem;
  265. }
  266. .unit, .num{
  267. color: #feff00;
  268. }
  269. .num{
  270. padding-left: .1rem;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. </style>