index.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!-- -->
  2. <template>
  3. <Navbar class="mb-3" />
  4. <v-card class="default-width my-3" style="height: calc(100vh - 356px)">
  5. <showText :class="showPrizeDraw ? '' : 'mb-15'"></showText>
  6. <!-- 抽奖 -->
  7. <prizeDraw v-if="showPrizeDraw" type="2" :lotteryId="lotteryId" class="prizeDraw mx-15 my-7" @success="handleReceive"></prizeDraw>
  8. </v-card>
  9. </template>
  10. <script setup>
  11. defineOptions({name: 'payOver-index'})
  12. import { ref } from 'vue'
  13. import Navbar from '../components/navbar.vue'
  14. import showText from './components/show.vue'
  15. import prizeDraw from '@/views/mall/components/prizeDraw.vue'
  16. import { useRoute, useRouter } from 'vue-router'
  17. import { getPrizeByGoodsId } from '@/api/mall/prize'
  18. const { spuId } = useRoute().query
  19. const showPrizeDraw = ref(false)
  20. const lotteryId = ref('')
  21. const getLottery = async () => {
  22. if (!spuId) return
  23. const data = await getPrizeByGoodsId(spuId)
  24. showPrizeDraw.value = data && Object.keys(data).length > 0
  25. console.log(showPrizeDraw.value, '是否显示抽奖活动')
  26. lotteryId.value = data.id
  27. }
  28. getLottery()
  29. // 前往我的奖品
  30. const router = useRouter()
  31. const handleReceive = () => {
  32. router.push('/mall/user/prize')
  33. }
  34. </script>
  35. <style lang="scss" scoped>
  36. </style>