index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <script setup lang="ts">
  2. import type { CouponInfoAppVo } from '@/api/globals'
  3. definePage({
  4. name: 'activityCenter-detail',
  5. islogin: true,
  6. style: {
  7. navigationBarTitleText: '活动详情',
  8. navigationStyle: 'custom',
  9. },
  10. })
  11. const staticUrl = import.meta.env.VITE_STATIC_BASE_URL
  12. const couponInfo = ref<CouponInfoAppVo>()
  13. const { send } = useRequest(couponId => Apis.app.get_smqjh_system_app_api_coupon_findbyid({ params: { couponId } }), {
  14. immediate: false,
  15. }).onSuccess((res) => {
  16. couponInfo.value = res.data.data
  17. })
  18. onLoad((options: any) => {
  19. send(options.id)
  20. })
  21. // 抵扣信息文案
  22. const discountText = computed(() => {
  23. if (!couponInfo.value)
  24. return ''
  25. const discount = (couponInfo.value.discountMoney || 0) / 100
  26. const amount = (couponInfo.value.amountMoney || 0) / 100
  27. return `抵扣${discount}元(满${amount}元可用)`
  28. })
  29. // 活动状态
  30. const activityStatus = computed(() => {
  31. if (!couponInfo.value)
  32. return ''
  33. const now = Date.now()
  34. const start = couponInfo.value.couponStartTime ? new Date(couponInfo.value.couponStartTime).getTime() : 0
  35. const end = couponInfo.value.couponEndTime ? new Date(couponInfo.value.couponEndTime).getTime() : 0
  36. if (start && now < start)
  37. return '未开始'
  38. if (end && now > end)
  39. return '已结束'
  40. return '进行中'
  41. })
  42. // 活动规则
  43. const rules = computed(() => [
  44. {
  45. title: '1.抵扣券',
  46. items: [discountText.value],
  47. },
  48. {
  49. title: '2.使用限制',
  50. items: ['每单限用1张', '不可与其他优惠同享'],
  51. },
  52. {
  53. title: '3.使用油站',
  54. items: ['全部合作油站', '部分油站不可用'],
  55. },
  56. {
  57. title: '4.有效期',
  58. items: [`领取后${couponInfo.value?.expirationDate || 7}天内有效`],
  59. },
  60. ])
  61. // 领取活动
  62. function handleClaim() {
  63. useUserStore().handleExchange(couponInfo.value)
  64. }
  65. </script>
  66. <template>
  67. <view v-if="couponInfo" class="activity-page pt20rpx">
  68. <!-- 活动卡片 -->
  69. <view class="mx24rpx overflow-hidden rounded-16rpx">
  70. <view class="pages-bg flex items-center justify-between px24rpx py28rpx">
  71. <view>
  72. <view class="text-32rpx text-#333 font-semibold">
  73. {{ couponInfo.activityName }}
  74. </view>
  75. <view class="mt12rpx text-28rpx">
  76. {{ discountText }}
  77. </view>
  78. </view>
  79. <image
  80. :src="`${staticUrl}/smqjh-jy-center.png`"
  81. class="h156rpx w156rpx"
  82. />
  83. </view>
  84. </view>
  85. <!-- 活动状态信息 -->
  86. <view class="mx24rpx mt20rpx rounded-16rpx bg-white px24rpx py28rpx">
  87. <view class="flex items-center text-28rpx">
  88. <view class="text-#666">
  89. 活动状态:
  90. </view>
  91. <view class="text-#333">
  92. {{ activityStatus }}
  93. </view>
  94. </view>
  95. <view class="mt20rpx flex items-center text-28rpx">
  96. <view class="text-#666">
  97. 活动ID:
  98. </view>
  99. <view class="text-#333">
  100. {{ couponInfo.activityId }}
  101. </view>
  102. </view>
  103. <view class="mt20rpx flex items-center text-28rpx">
  104. <view class="text-#666">
  105. 剩余库存:
  106. </view>
  107. <view class="text-#333">
  108. {{ couponInfo.inventoryActual }}张
  109. </view>
  110. </view>
  111. </view>
  112. <!-- 活动规则 -->
  113. <view class="mx24rpx mt20rpx rounded-16rpx bg-white px24rpx py28rpx">
  114. <view class="text-32rpx text-#333 font-semibold">
  115. 活动规则
  116. </view>
  117. <view v-for="(rule, index) in rules" :key="index" class="mt24rpx">
  118. <view class="text-28rpx text-#333 font-medium">
  119. {{ rule.title }}
  120. </view>
  121. <view v-for="(item, idx) in rule.items" :key="idx" class="mt12rpx text-26rpx text-#666">
  122. · {{ item }}
  123. </view>
  124. </view>
  125. </view>
  126. <!-- 底部占位 -->
  127. <view class="h200rpx" />
  128. </view>
  129. <!-- 底部固定按钮 -->
  130. <FixedLayout>
  131. <wd-button
  132. block
  133. size="large"
  134. :disabled="couponInfo?.receiveSign || activityStatus !== '进行中'"
  135. @click="handleClaim"
  136. >
  137. {{ couponInfo?.receiveSign ? '已领取' : '立即领取' }}
  138. </wd-button>
  139. </FixedLayout>
  140. </template>
  141. <style lang="scss" scoped>
  142. .pages-bg{
  143. background: linear-gradient( 180deg, #FFDCDC 0%, #FFFFFF 100%);
  144. }
  145. </style>