groupon-card-list.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!-- 拼团活动参团记录卡片 -->
  2. <template>
  3. <view v-if="state.list.length > 0" class="groupon-list detail-card ss-p-x-20">
  4. <view class="join-activity ss-flex ss-row-between ss-m-t-30">
  5. <view class="">已有{{ state.list.length }}人参与活动</view>
  6. <text class="cicon-forward"></text>
  7. </view>
  8. <view
  9. v-for="(record, index) in state.list"
  10. @tap="sheep.$router.go('/pages/activity/groupon/detail', { id: record.id })"
  11. :key="index"
  12. class="ss-m-t-40 ss-flex ss-row-between border-bottom ss-p-b-30"
  13. >
  14. <view class="ss-flex ss-col-center">
  15. <image :src="sheep.$url.cdn(record.avatar)" class="user-avatar"></image>
  16. <view class="user-nickname ss-m-l-20 ss-line-1">{{ record.nickname }}</view>
  17. </view>
  18. <view class="ss-flex ss-col-center">
  19. <view class="ss-flex-col ss-col-bottom ss-m-r-20">
  20. <view class="title ss-flex ss-m-b-14">
  21. 还差
  22. <view class="num">{{ record.userSize - record.userCount }}人</view>
  23. 成团
  24. </view>
  25. <view class="end-time">{{ endTime(record.expireTime) }}</view>
  26. </view>
  27. <view class="">
  28. <button class="ss-reset-button go-btn" @tap.stop="onJoinGroupon(record)"> 去参团 </button>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import { onMounted, reactive } from 'vue';
  36. import sheep from '@/sheep';
  37. import { useDurationTime } from '@/sheep/hooks/useGoods';
  38. import CombinationApi from '@/sheep/api/promotion/combination';
  39. const props = defineProps({
  40. modelValue: {
  41. type: Object,
  42. default() {},
  43. },
  44. });
  45. const state = reactive({
  46. list: [],
  47. });
  48. // 去参团
  49. const emits = defineEmits(['join']);
  50. function onJoinGroupon(record) {
  51. emits('join', record);
  52. }
  53. // 结束时间或状态
  54. function endTime(time) {
  55. const durationTime = useDurationTime(time);
  56. if (durationTime.ms <= 0) {
  57. return '该团已解散';
  58. }
  59. let timeText = '剩余 ';
  60. timeText += `${durationTime.h}时`;
  61. timeText += `${durationTime.m}分`;
  62. timeText += `${durationTime.s}秒`;
  63. return timeText;
  64. }
  65. // 初始化
  66. onMounted(async () => {
  67. // 查询参团记录
  68. // status = 0 表示未成团
  69. const { data } = await CombinationApi.getHeadCombinationRecordList(props.modelValue.id, 0, 10);
  70. state.list = data;
  71. });
  72. </script>
  73. <style lang="scss" scoped>
  74. .detail-card {
  75. background-color: $white;
  76. margin: 14rpx 20rpx;
  77. border-radius: 10rpx;
  78. overflow: hidden;
  79. }
  80. .groupon-list {
  81. .join-activity {
  82. font-size: 28rpx;
  83. font-weight: 500;
  84. color: #999999;
  85. .cicon-forward {
  86. font-weight: 400;
  87. }
  88. }
  89. .user-avatar {
  90. width: 60rpx;
  91. height: 60rpx;
  92. background: #ececec;
  93. border-radius: 60rpx;
  94. }
  95. .user-nickname {
  96. font-size: 28rpx;
  97. font-weight: 500;
  98. color: #333333;
  99. width: 160rpx;
  100. }
  101. .title {
  102. font-size: 24rpx;
  103. font-weight: 500;
  104. color: #666666;
  105. .num {
  106. color: #ff6000;
  107. }
  108. }
  109. .end-time {
  110. font-size: 24rpx;
  111. font-weight: 500;
  112. color: #999999;
  113. }
  114. .go-btn {
  115. width: 140rpx;
  116. height: 60rpx;
  117. background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
  118. border-radius: 30rpx;
  119. color: #fff;
  120. font-weight: 500;
  121. font-size: 26rpx;
  122. line-height: normal;
  123. }
  124. }
  125. </style>