prizeDraw.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div class="prizeDrawBox">
  3. <div class="text-end cursor-pointer color-666" @click="emit('success')">
  4. <v-btn color="primary" variant="tonal" append-icon="mdi-pan-right">我的奖品</v-btn>
  5. </div>
  6. <div class="d-flex flex-column align-center">
  7. <div class="numberBox mb-5">恭喜您获得房券抽奖机会</div>
  8. <gridPage v-if="props.type === '1'" :lotteryId="props.lotteryId" :disabled="disabled" @end="endCallback"></gridPage>
  9. <slotMachinePage v-if="props.type === '2'" :lotteryId="props.lotteryId" height="120" :disabled="disabled" @end="endCallback"></slotMachinePage>
  10. <CtDialog :visible="showDialog" titleClass="text-h6" :footer="false" :widthType="3" title="抽奖详情" @close="showDialog = false">
  11. <div class="d-flex align-center flex-column">
  12. <svg-icon name="submit" size="300"></svg-icon>
  13. <p v-for="(k, i) in prizeData" :key="i" class="mb-3">{{ k.prize.prompt }}</p>
  14. <div class="my-10">
  15. <v-btn color="primary" variant="outlined" width="120" @click="showDialog = false">取 消</v-btn>
  16. <v-btn color="primary" width="120" class="ml-5" @click.stop="emit('success')">前往领取</v-btn>
  17. </div>
  18. </div>
  19. </CtDialog>
  20. </div>
  21. </div>
  22. </template>
  23. <script setup>
  24. defineOptions({ name: 'prizeDraw'})
  25. import gridPage from './prizeDraw/grid.vue'
  26. import slotMachinePage from './prizeDraw/slotMachine.vue'
  27. import { ref } from 'vue'
  28. import { getLuckLotteryRecordByOrderId } from '@/api/mall/prize'
  29. import Snackbar from '@/plugins/snackbar'
  30. const emit = defineEmits(['success'])
  31. const props = defineProps({
  32. lotteryId: [Number, String],
  33. orderId: [Number, String],
  34. type: {
  35. type: String,
  36. default: '1'
  37. }
  38. })
  39. const disabled = ref(false)
  40. // 获取中奖记录
  41. const prizeData = ref({})
  42. const getRecord = async () => {
  43. const data = await getLuckLotteryRecordByOrderId(props.orderId)
  44. prizeData.value = data || []
  45. if (!data || !data.length) disabled.value = true
  46. }
  47. if (props.orderId) getRecord()
  48. const showDialog = ref(false)
  49. const endCallback = () => {
  50. if (!prizeData.value.length) return Snackbar.warning('您已经抽过奖了哦')
  51. showDialog.value = true
  52. disabled.value = true
  53. }
  54. </script>
  55. <style scoped lang="scss">
  56. .prizeDrawBox {
  57. padding: 20px 40px;
  58. background-color: var(--default-bgc);
  59. }
  60. .prizeDraw {
  61. margin: 0 auto;
  62. }
  63. .numberBox {
  64. font-size: 20px;
  65. font-weight: bold;
  66. padding: 2px 38px;
  67. border-bottom: 3px solid var(--v-primary-base);
  68. }
  69. .colorBase {
  70. color: var(--v-primary-base);
  71. margin: 0 6px;
  72. font-size: 22px;
  73. }
  74. </style>