prizeDraw.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="prizeDrawBox">
  3. <div class="d-flex flex-column align-center">
  4. <div class="numberBox mb-5">房券抽奖</div>
  5. <gridPage v-if="props.type === '1'" :lotteryId="props.lotteryId" :disabled="disabled" @end="endCallback"></gridPage>
  6. <slotMachinePage v-if="props.type === '2'" :lotteryId="props.lotteryId" height="120" :disabled="disabled" @end="endCallback"></slotMachinePage>
  7. <v-card min-height="300" width="600" class="mt-5 pa-5">
  8. <div v-if="showDialog">
  9. <p v-for="(k, i) in prizeData" :key="i">{{ k.prize.prompt }}</p>
  10. <p>凭此房券在规定有效期内可享受免费住宿一晚。</p>
  11. <p class="mb-5">请提供收货地址,以便安排房券派送。</p>
  12. <!-- 收货地址 -->
  13. <div>
  14. <v-radio-group v-model="addressSelect" color="primary">
  15. <v-radio v-for="val in address" :key="val.id" :label="val.id === 9999 ? val.label : (val.name + ',' + val.mobile + ',' + val.areaName + val.detailAddress)" :value="val.id"></v-radio>
  16. </v-radio-group>
  17. <v-text-field v-if="addressSelect === 9999" v-model="newAddress" label="新地址" placeholder="示例:张三,13800138000,北京市朝阳区望京街道望京街道" color="primary"></v-text-field>
  18. <div class="text-center mt-3">
  19. <v-btn color="primary" class="elevation-5" width="180" @click.stop="handleSubmit">确 认</v-btn>
  20. </div>
  21. </div>
  22. </div>
  23. </v-card>
  24. </div>
  25. </div>
  26. </template>
  27. <script setup>
  28. defineOptions({ name: 'prizeDraw'})
  29. import gridPage from './prizeDraw/grid.vue'
  30. import slotMachinePage from './prizeDraw/slotMachine.vue'
  31. import { ref } from 'vue'
  32. import { getLuckLotteryRecordByOrderId } from '@/api/mall/prize'
  33. import { getMallUserAddressList } from '@/api/mall/address'
  34. import Snackbar from '@/plugins/snackbar'
  35. const emit = defineEmits(['success'])
  36. const props = defineProps({
  37. lotteryId: [Number, String],
  38. orderId: [Number, String],
  39. type: {
  40. type: String,
  41. default: '1'
  42. }
  43. })
  44. const newAddress = ref('')
  45. const addressSelect = ref()
  46. const disabled = ref(false)
  47. // 获取中奖记录、收货地址
  48. const address = ref([])
  49. const prizeData = ref({})
  50. const getRecord = async () => {
  51. const data = await getLuckLotteryRecordByOrderId(props.orderId)
  52. prizeData.value = data || []
  53. if (!data || !data.length) disabled.value = true
  54. const addressData = await getMallUserAddressList()
  55. address.value = [...addressData, { id: 9999, label: '使用新地址' }] || []
  56. if (addressData && addressData.length) addressSelect.value = addressData[0].id
  57. }
  58. if (props.orderId) getRecord()
  59. const showDialog = ref(false)
  60. const endCallback = () => {
  61. if (!prizeData.value.length) return Snackbar.warning('您已经抽过奖了哦')
  62. showDialog.value = true
  63. disabled.value = true
  64. }
  65. const handleSubmit = async () => {}
  66. </script>
  67. <style scoped lang="scss">
  68. .prizeDrawBox {
  69. padding: 20px 40px;
  70. background-color: var(--default-bgc);
  71. }
  72. .prizeDraw {
  73. margin: 0 auto;
  74. }
  75. .numberBox {
  76. font-size: 20px;
  77. font-weight: bold;
  78. padding: 2px 38px;
  79. border-bottom: 3px solid var(--v-primary-base);
  80. }
  81. .colorBase {
  82. color: var(--v-primary-base);
  83. margin: 0 6px;
  84. font-size: 22px;
  85. }
  86. </style>