Box.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div class="count-box">
  3. <div class="swiper-container" v-swiper:swiper="swiperOption">
  4. <div class="swiper-wrapper">
  5. <div class="swiper-slide" v-for="(c, index) in list1" :key="index">
  6. <count-item class="item" :title="c.item" :value="c.count"></count-item>
  7. </div>
  8. <div class="swiper-slide" v-for="(c, index) in list2" :key="index">
  9. <count-item class="item" :title="c.item" :value="c.count"></count-item>
  10. </div>
  11. <div class="swiper-slide" v-for="(c, index) in list2" :key="index">
  12. <count-item class="item" :title="c.item" :value="c.count"></count-item>
  13. </div>
  14. <div class="swiper-slide" v-for="(c, index) in list3" :key="index">
  15. <count-item class="item" :title="c.item" :value="c.count"></count-item>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import CountItem from './Item.vue'
  23. export default {
  24. name: 'count-box',
  25. components: {
  26. CountItem
  27. },
  28. data () {
  29. return {
  30. swiperOption: {
  31. autoplay: 5000,
  32. speed: 500,
  33. direction: 'vertical',
  34. slidesPerView: 2,
  35. slidesPerGroup: 2
  36. }
  37. }
  38. },
  39. computed: {
  40. counts () {
  41. return this.$store.state.product.common.counts
  42. },
  43. list1 () {
  44. return this.counts.data.slice(1, 2)
  45. },
  46. list2 () {
  47. return this.counts.data.slice(2, 3)
  48. },
  49. list3 () {
  50. return this.counts.data.slice(3, 4)
  51. }
  52. },
  53. mounted () {
  54. this.$nextTick(() => {
  55. this.loadCounts()
  56. // 刷新统计信息
  57. setInterval(() => {
  58. this.loadCounts()
  59. }, 30000)
  60. })
  61. },
  62. methods: {
  63. loadCounts () {
  64. this.$store.dispatch('loadProductCounts', { _status: 'actived' })
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .count-box {
  71. position: relative;
  72. top: 15px;
  73. float: right;
  74. width: 300px;
  75. height: 60px;
  76. overflow: hidden;
  77. .swiper-container {
  78. height: 100%;
  79. }
  80. }
  81. </style>