Box.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: 1,
  26. slidesPerGroup: 1
  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: 20px;
  55. float: right;
  56. width: 210px;
  57. height: 40px;
  58. margin-right: 65px;
  59. overflow: hidden;
  60. border-radius: 3px;
  61. background: url("/images/all/count_bg.png") no-repeat;
  62. /*background: #7299E8;*/
  63. .swiper-slide{
  64. width: 100%;
  65. /*background: #83c5f8;*/
  66. border-radius: 3px;
  67. }
  68. .swiper-container {
  69. height: 100%;
  70. }
  71. }
  72. </style>