fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!--
 * @Author: 张嘉彬
 * @Date: 2021-10-12 11:01:37
 * @Description: 拼团模块
-->
<template>
  <div class="collage-box">
    <p>以下小伙伴正在发起拼团,你可以直接参加</p>
    <div class="collage-user">
      <swiper :options="swiperOptions" ref='goodsSwiper' class="swiper-box"
              :class="{'swier-one':list.length===1}">
        <swiper-slide v-for="(item,index) in list" :key="index" class="swiper-slide">
          <div class="user-content">
            <div class="user-msg">
              <img v-if='item.memberPic' :src='item.memberPic | ossProcess' alt="">
              <img v-else src='../../assets/images/goodsDetail/userM.png' alt="">
              <p>{{item.memberNickName}}</p>
            </div>
            <div class="collage-time">
              <p class="num">差{{item.lackNum}}人可拼成</p>
              <p>剩余{{item.endCountDownSecStr}}</p>
            </div>
            <div @click="$emit('openGuide')" class="btn-box">
              <span>去凑团</span>
            </div>
          </div>
        </swiper-slide>
      </swiper>
 
    </div>
  </div>
</template>
 
<script>
export default {
  data () {
    return {
      swiperOptions: {
        direction: 'vertical', // 竖直方向
        autoplay: {
          delay: 3000,
          disableOnInteraction: false
        },
        loop: false, // 循环切换
        slidesPerView: 1, // 可视个数
        loopedSlides: 6
      },
      list: [],
      timer: null
    }
  },
  props: {
    collageUserList: {
      type: Array,
      default: () => []
    }
  },
  created () {
    this.list = [...this.collageUserList]
    this.swiperOptions.slidesPerView = this.list && this.list.length > 1 ? 2 : 1
    this.timer = setInterval(() => {
      this.list.forEach((val, index) => {
        val.endCountDownSec -= 1
        // 拼团有效期结束 删除
        if (val.endCountDownSec <= 0) {
          this.list.splice(index, 1)
          return
        }
        this.$set(val, 'endCountDownSecStr', this.countTime(val.endCountDownSec))
      })
    }, 1000)
  },
  beforeDestroy () {
    clearInterval(this.timer)
  },
  methods: {
    countTime (val) {
      let day = parseInt(val / 60 / 60 / 24)
      let hr = parseInt(val / 60 / 60 % 24)
      let min = parseInt(val / 60 % 60)
      let sec = parseInt(val % 60)
      day = day > 9 ? day : day === 0 ? '' : `0${day}天 `
      hr = hr > 9 ? hr : '0' + hr
      min = min > 9 ? min : '0' + min
      sec = sec > 9 ? sec : '0' + sec
      return `${day}${hr}:${min}:${sec}`
    }
  }
}
</script>
 
<style lang="scss" scoped>
.collage-box {
  border-radius: 8px;
  background-color: #f6f6f6;
  padding-top: 20px;
  > p {
    color: #666666;
    font-size: 24px;
    padding: 0 20px 10px 20px;
    border-bottom: 2px solid #e6e6e6;
  }
}
.swiper-box {
  height: 200px;
  .swiper-slide {
    display: flex;
    align-items: center;
  }
}
.swier-one {
  height: auto;
}
.collage-user {
  padding: 20px;
  color: #333333;
  .user-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .user-msg {
      display: flex;
      align-items: center;
      img {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        margin-right: 10px;
      }
      p {
        width: 160px;
        font-size: 24px;
      }
    }
    .collage-time {
      font-size: 24px;
      .num {
        color: var(--color-red);
        margin-bottom: 7px;
      }
    }
    .btn-box {
      span {
        display: inline-block;
        width: 140px;
        height: 60px;
        line-height: 60px;
        text-align: center;
        color: var(--color-red);
        border: 2px solid var(--color-red);
        border-radius: 32px;
      }
    }
  }
}
</style>