index.vue 1.1 KB

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