StatisticsMobile.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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. <ul class="list-inline" :style="{top: widthTop + 'rem'}" :class="{no_tran: widthTop == 2.4}">
  18. <li v-for="(item, index) in itemData" :style="index % 2 == 0 ? 'text-align: right;padding-right: .3rem;' : 'text-align: left;padding-left: .3rem;'">
  19. <span class="number" v-if="item.type === 2">
  20. <img :src="`/images/mobile/@2x/home/count${index + 1}.jpg`" alt="">
  21. <span v-html="formatDouble(item.count)" style="vertical-align: middle"></span>
  22. <span class="unit">条</span>
  23. </span>
  24. <span class="number" v-else>
  25. <img :src="`/images/mobile/@2x/home/count${index + 1}.jpg`" alt="">
  26. <span v-html="formatNumber(item.count, index)" style="vertical-align: middle"></span>
  27. <span class="unit" v-if="item.type === 3">家</span>
  28. </span>
  29. </li>
  30. </ul>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'StatisticsView',
  36. data () {
  37. return {
  38. step: 1,
  39. widthTop: 0,
  40. timerIndex: 0,
  41. timer: {}, // 定时器实体
  42. imgbox: {
  43. 'src': ''
  44. }
  45. }
  46. },
  47. mounted () {
  48. this.$nextTick(() => {
  49. this.changeInterval()
  50. })
  51. },
  52. methods: {
  53. changeInterval () {
  54. setInterval(() => {
  55. this.widthTop += -0.6
  56. if (this.widthTop === -2.4) {
  57. this.widthTop = 0
  58. }
  59. }, 3000)
  60. },
  61. formatNumber (num, type) {
  62. if (num.toString().indexOf('E') !== -1) {
  63. let arr = num.toString().split('E')
  64. num = arr[0] * Math.pow(10, arr[1])
  65. }
  66. if (num > 99999999) {
  67. let str2 = num.toString()
  68. num = Math.floor(num / 100000000)
  69. if (parseInt(str2.charAt(str2.length - 8)) > 8) {
  70. num = num + 1
  71. }
  72. num = num + '<span style="color: #333">亿</span>'
  73. } else if (num > 9999) {
  74. let str = num.toString()
  75. num = Math.floor(num / 10000)
  76. if (parseInt(str.charAt(str.length - 4)) > 4) {
  77. num = num + 1
  78. }
  79. num += '<span style="color: #333">万</span>'
  80. } else {
  81. if (type === 6 || type === 7) {
  82. num += '<span style="color: #333">元</span>'
  83. } else if (type === 0 || type === 1 || type === 2) {
  84. num += '<span style="color: #333">个</span>'
  85. } else {
  86. num += ''
  87. }
  88. }
  89. return num
  90. },
  91. formatDouble (num) {
  92. if (num.toString().indexOf('E') !== -1) {
  93. let arr = num.toString().split('E')
  94. num = arr[0] * Math.pow(10, arr[1])
  95. }
  96. if (num > 99999999) {
  97. num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '<span style="color: #333">亿</span>'
  98. } else if (num > 9999) {
  99. num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '<span style="color: #333">万</span>'
  100. } else {
  101. num += ''
  102. }
  103. return num
  104. }
  105. },
  106. computed: {
  107. allCount () {
  108. return this.$store.state.count.allCount.data
  109. },
  110. inquirySheet () {
  111. let sheetNum = this.$store.state.count.inquirySheet.data.count
  112. return this.formatDouble(sheetNum)
  113. },
  114. inquirySheetLast () {
  115. let lastSheetNum = this.$store.state.count.inquirySheetLast.data.count
  116. return this.formatDouble(lastSheetNum)
  117. },
  118. all () {
  119. let count = this.$store.state.supplier.merchant.merchantAll.data
  120. return count.content ? count.totalElements : '0'
  121. },
  122. counts () {
  123. return this.$store.state.product.common.counts
  124. },
  125. itemData () {
  126. let str = []
  127. if (this.counts.data) {
  128. this.counts.data.forEach((value, key, $data) => {
  129. str.push({id: $data[key].item, count: $data[key].count, type: 1})
  130. })
  131. }
  132. str.push({id: '供应商', count: this.all ? this.all : 0, type: 3})
  133. str.push({id: '本月询价单', count: this.$store.state.count.inquirySheet.data ? this.$store.state.count.inquirySheet.data.count : 0, type: 2})
  134. str.push({id: '上月询价单', count: this.$store.state.count.inquirySheetLast.data ? this.$store.state.count.inquirySheetLast.data.count : 0, type: 2})
  135. if (this.allCount) {
  136. this.allCount.forEach((value, key, $data) => {
  137. str.push({id: $data[key].item, count: $data[key].count, type: 1})
  138. })
  139. }
  140. str = [str[1], str[2], str[0], ...str.slice(3, 6), str[7], str[6]]
  141. return str
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .statistics{
  148. position:relative;
  149. /* height: 0.6rem;*/
  150. height: 8rem;
  151. border-radius:.3rem;
  152. background: #fff;
  153. margin:0 .05rem .2rem;
  154. /*overflow: hidden;*/
  155. background: url('/images/mobile/@2x/home/countbg.png') no-repeat center;
  156. ul{
  157. float: left;
  158. width:50%;
  159. position:absolute;
  160. transition: .5s all linear;
  161. border: 1px solid red;
  162. &:no_tran{
  163. transition:none;
  164. }
  165. li{
  166. width:100%;
  167. height:.6rem;
  168. line-height: .6rem;
  169. font-size: .28rem;
  170. font-weight: bold;
  171. white-space: nowrap;
  172. overflow: hidden;
  173. vertical-align:top;
  174. &:nth-child(even){
  175. &::before{
  176. content: '';
  177. display: inline-block;
  178. width: 0.02rem;
  179. height: 0.3rem;
  180. background-color: #9c9c9c;
  181. position: relative;
  182. top: .1rem;
  183. left: -.3rem;
  184. }
  185. }
  186. span{
  187. img {
  188. height: .3rem;
  189. }
  190. &.number{
  191. display: inline-block;
  192. color:red;
  193. font-size: 0.32rem;
  194. height: .6rem;
  195. vertical-align:middle;
  196. line-height:.6rem;
  197. .unit{
  198. color: #333;
  199. vertical-align: middle;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. </style>-->
  207. <template>
  208. <div class="statistics">
  209. <ul class="list-inline pull-left" ref="pingdanListWrapper" :style="{top: topLeft + 'rem'}" :class="{no_tran: topLeft == 2.4}">
  210. <li v-for="(item, index) in itemData" v-if="index <= 4">
  211. <span class="number">
  212. <span class="name" v-html="count[index]"></span>
  213. <span class="num" v-html="formatNumber(item.count, index)"></span>
  214. <span class="unit" v-if="item.type === 3">家</span>
  215. </span>
  216. </li>
  217. </ul>
  218. <ul class="list-inline pull-right" ref="pingdanListWrapper" :style="{top: topRight + 'rem'}" :class="{no_tran: topRight == 2.4}">
  219. <li v-for="(item, index) in itemData" v-if="index > 4">
  220. <span class="number">
  221. <span class="name" v-html="count[index]"></span>
  222. <span class="month" v-if="index === 5">(上月)</span>
  223. <span class="month" v-if="index === 6">(本月)</span>
  224. <span class="num" v-html="formatDouble(item.count)"></span>
  225. <span class="unit" v-if="item.type === 2">条</span>
  226. </span>
  227. </li>
  228. </ul>
  229. </div>
  230. </template>
  231. <script>
  232. import {whichTransitionEvent} from '~utils/baseUtils.js'
  233. export default {
  234. name: 'StatisticsView',
  235. data () {
  236. return {
  237. step: 1,
  238. count: ['现货', '品牌', '规格书', '供应商', '店铺', '询价求购', '询价求购', '上年交易', '本年交易'],
  239. topLeft: 0,
  240. topRight: 0,
  241. timerIndex: 0,
  242. timer: {}, // 定时器实体
  243. imgbox: {
  244. 'src': ''
  245. }
  246. }
  247. },
  248. mounted () {
  249. this.$nextTick(() => {
  250. this.changeIntervalL()
  251. this.changeIntervalR()
  252. })
  253. },
  254. methods: {
  255. // changeIntervalL () {
  256. // setInterval(() => {
  257. // this.topLeft += -1
  258. // let arr1 = this.itemData.slice(0, 5)
  259. // let arr2 = arr1.shift()
  260. // arr1.push(arr2)
  261. // if (this.topLeft === -5) {
  262. // this.topLeft = 0
  263. // }
  264. // }, 2400)
  265. // },
  266. // changeIntervalR () {
  267. // setInterval(() => {
  268. // this.topRight += -1
  269. // let arr1 = this.itemData.slice(5, 9)
  270. // let arr2 = arr1.shift()
  271. // arr1.push(arr2)
  272. // this.itemDataTemp.push(this.itemData)
  273. // if (this.topRight === -4) {
  274. // this.topRight = 0
  275. // }
  276. // }, 3000)
  277. // },
  278. changeIntervalL: function (flag) {
  279. if (flag) {
  280. this.timer = setInterval(() => {
  281. this.isTop = false
  282. let isChange = true
  283. this.timerIndex++
  284. let _transitionEvent = whichTransitionEvent()
  285. _transitionEvent && this.$refs.pingdanListWrapper[0].addEventListener(
  286. _transitionEvent, () => {
  287. console.log(isChange)
  288. if (isChange) {
  289. let title = this.itemData.slice(0, 5).shift()
  290. this.title.push(title)
  291. this.timerIndex = 0
  292. isChange = false
  293. this.isTop = true
  294. }
  295. })
  296. }, 2400)
  297. } else {
  298. clearInterval(this.timer)
  299. }
  300. },
  301. changeIntervalR: function (flag) {
  302. if (flag) {
  303. this.timer = setInterval(() => {
  304. this.isTop = false
  305. let isChange = true
  306. this.timerIndex++
  307. let _transitionEvent = whichTransitionEvent()
  308. _transitionEvent && this.$refs.pingdanListWrapper[0].addEventListener(
  309. _transitionEvent, () => {
  310. console.log(isChange)
  311. if (isChange) {
  312. let title = this.itemData.slice(5, 9).shift()
  313. this.title.push(title)
  314. this.timerIndex = 0
  315. isChange = false
  316. this.isTop = true
  317. }
  318. })
  319. }, 3000)
  320. } else {
  321. clearInterval(this.timer)
  322. }
  323. },
  324. formatNumber (num, type) {
  325. if (num.toString().indexOf('E') !== -1) {
  326. let arr = num.toString().split('E')
  327. num = arr[0] * Math.pow(10, arr[1])
  328. }
  329. if (num > 99999999) {
  330. let str2 = num.toString()
  331. num = Math.floor(num / 100000000)
  332. if (parseInt(str2.charAt(str2.length - 8)) > 8) {
  333. num = num + 1
  334. }
  335. num = num + '亿'
  336. } else if (num > 9999) {
  337. let str = num.toString()
  338. num = Math.floor(num / 10000)
  339. if (parseInt(str.charAt(str.length - 4)) > 4) {
  340. num = num + 1
  341. }
  342. num += '万'
  343. } else {
  344. if (type >= 7) {
  345. num += '元'
  346. } else if (type <= 2) {
  347. num += '个'
  348. } else {
  349. num += ''
  350. }
  351. }
  352. return num
  353. },
  354. formatDouble (num) {
  355. if (num.toString().indexOf('E') !== -1) {
  356. let arr = num.toString().split('E')
  357. num = arr[0] * Math.pow(10, arr[1])
  358. }
  359. if (num > 99999999) {
  360. num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '亿'
  361. } else if (num > 9999) {
  362. num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '万'
  363. } else {
  364. num += ''
  365. }
  366. return num
  367. }
  368. },
  369. computed: {
  370. allCount () {
  371. return this.$store.state.count.allCount.data
  372. },
  373. inquirySheet () {
  374. let sheetNum = this.$store.state.count.inquirySheet.data.count
  375. return this.formatDouble(sheetNum)
  376. },
  377. inquirySheetLast () {
  378. let lastSheetNum = this.$store.state.count.inquirySheetLast.data.count
  379. return this.formatDouble(lastSheetNum)
  380. },
  381. all () {
  382. let count = this.$store.state.supplier.merchant.merchantAll.data
  383. return count.content ? count.totalElements : '0'
  384. },
  385. counts () {
  386. return this.$store.state.product.common.counts
  387. },
  388. list () {
  389. let list = JSON.parse(JSON.stringify(this.$store.state.provider.stores.storeList.data))
  390. console.log(list)
  391. return list.totalElements
  392. },
  393. itemData () {
  394. let str = []
  395. if (this.counts.data) {
  396. this.counts.data.forEach((value, key, $data) => {
  397. str.push({id: $data[key].item, count: $data[key].count, type: 1})
  398. })
  399. }
  400. str.push({id: '供应商', count: this.all ? this.all : 0, type: 3})
  401. str.push({id: '本月询价单', count: this.$store.state.count.inquirySheet.data ? this.$store.state.count.inquirySheet.data.count : 0, type: 2})
  402. str.push({id: '上月询价单', count: this.$store.state.count.inquirySheetLast.data ? this.$store.state.count.inquirySheetLast.data.count : 0, type: 2})
  403. if (this.allCount) {
  404. this.allCount.forEach((value, key, $data) => {
  405. str.push({id: $data[key].item, count: $data[key].count, type: 1})
  406. })
  407. }
  408. str.push({id: '店铺', count: this.list ? this.list : 0, type: 3})
  409. str = [str[1], str[0], str[2], str[3], str[8], str[5], str[4], str[6], str[7]]
  410. return str
  411. }
  412. }
  413. }
  414. </script>
  415. <style lang="scss" scoped>
  416. .statistics{
  417. position:relative;
  418. height: 1rem;
  419. border-radius:.48rem;
  420. background: #fff;
  421. margin:0 .05rem .2rem;
  422. overflow: hidden;
  423. background: url('/images/mobile/@2x/home/countbg.png') no-repeat center;
  424. background-size: auto 0.96rem;
  425. ul{
  426. width:50%;
  427. position:relative;
  428. transition: .5s all linear;
  429. &:first-child{
  430. margin-left: .0rem;
  431. }
  432. &:no_tran{
  433. transition:none;
  434. }
  435. li{
  436. width:100%;
  437. text-align: center;
  438. height:1rem;
  439. line-height: 0.92rem;
  440. font-size: .28rem;
  441. font-weight: bold;
  442. white-space: nowrap;
  443. overflow: hidden;
  444. vertical-align:top;
  445. span{
  446. &.number{
  447. display: inline-block;
  448. color:red;
  449. font-size: 0.32rem;
  450. height: .6rem;
  451. vertical-align:middle;
  452. line-height:.6rem;
  453. font-weight: bold;
  454. .name, .month{
  455. color: #fff;
  456. vertical-align:middle;
  457. }
  458. .month{
  459. font-size: 0.22rem;
  460. }
  461. .unit, .num{
  462. color: #feff00;
  463. vertical-align:middle;
  464. }
  465. .num{
  466. padding-left: .1rem;
  467. }
  468. }
  469. }
  470. }
  471. }
  472. }
  473. </style>