groupon-card-list.vue 3.3 KB

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