Box.vue 1.3 KB

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