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