feat: 쿠폰등록

This commit is contained in:
최만억 (Jo)
2025-11-11 06:19:49 +00:00
committed by 김채린
parent 60b306ca90
commit 39fee9ef5f
2 changed files with 355 additions and 171 deletions

View File

@@ -1,5 +1,6 @@
<script setup lang="ts">
import {
globalDateFormat,
getTime,
fromUnixTime,
addMonths,
@@ -22,17 +23,13 @@ const props = defineProps<Props>()
// Configuration
const runtimeConfig = useRuntimeConfig()
const runType = runtimeConfig.public.runType as string
const staticUrl = runtimeConfig.public.staticUrl as string
const stoveApiUrl = runtimeConfig.public.stoveApiUrl as string
const stoveMaintenanceApiUrl = runtimeConfig.public
.stoveMaintenanceApiUrl as string
const multilingualBaseApiUrl = `${staticUrl}/${runType}/test`
const multilingualFileName = 'test_homepage_brand_coupon.json'
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_coupon.json'
// Multilingual
const resultGetMultilingual = await useGetMultilingual({
baseApiUrl: multilingualBaseApiUrl,
baseApiUrl: dataResourcesUrl,
fileName: multilingualFileName,
})
const { t, tm, locale }: any = useI18n({
@@ -41,7 +38,7 @@ const { t, tm, locale }: any = useI18n({
})
// Composables
const { isGameMaintenance, checkGameMaintenance } = useGetGameMaintenance()
// const { isGameMaintenance, checkGameMaintenance } = useGetGameMaintenance()
const { isWebInspection, getInspectionDataExternal } =
useGetInspectionDataExternal()
const breakpoints = useResponsiveBreakpoints()
@@ -63,8 +60,7 @@ const {
setCouponDate,
toUnixTimestamp,
} = useCouponDate()
const { pageNo, pageSize, pageBlock, updatePagination, getPageBlock } =
useCouponPaging()
const { pageNo, pageSize, updatePagination, getPageBlock } = useCouponPaging()
// Store
const gameDataStore = useGameDataStore()
@@ -74,12 +70,7 @@ const { gameData } = storeToRefs(gameDataStore)
const { handleOpenAlert, handleOpenConfirm } = modalStore
const { couponNo, isSelectCharacter, selectCharacter } =
storeToRefs(couponStore)
const {
updateMemberNo,
updateCouponNo,
updateSelectCharacter,
isEmptyCouponNo,
} = couponStore
const { updateCouponNo, updateSelectCharacter, isEmptyCouponNo } = couponStore
// Data
const backgroundData = computed(() =>
@@ -92,17 +83,6 @@ const monthSelectList = ref<Array<number>>([1, 3, 6, 12])
const isSelectCharacterModalOpen = ref(false)
// Computed
const minDate = computed(() => {
const date = new Date()
date.setHours(0, 0, 0, 0)
date.setFullYear(date.getFullYear() - 1)
return date
})
const maxDate = computed(() => {
const date = new Date()
date.setHours(23, 59, 59, 999)
return date
})
const sortedCharacterList = computed(() => {
return characterList.value
.map(characterInfo => {
@@ -266,17 +246,23 @@ const handleCouponUse = async () => {
const validationCheckBeforeResult = await validationCheckBefore()
if (validationCheckBeforeResult !== 0) {
if (
if (validationCheckBeforeResult === COUPON_RESULT.LOGIN_REQUIRED) {
// 미로그인일 경우 : 이미 validationCheckBefore 함수에서 로그인 모달 팝업 노출했으므로 추가 처리 필요 없음
return
} else if (
validationCheckBeforeResult === COUPON_RESULT.SELECT_CHARACTER_REQUIRED
) {
// 캐릭터 미선택일 경우 : 캐릭터 선택 모달 팝업 노출
openSelectCharacterModal()
return false
return
} else if (validationCheckBeforeResult === COUPON_RESULT.SYSTEM_ERROR) {
// 시스템 에러일 경우 : 에러 팝업 노출 (에러코드)
openAlert(t('Coupon_Error', { code: validationCheckBeforeResult }))
return false
return
} else {
// 그 외 오류 팝업 노출
openAlert(tm(`Coupon_Alert_(${validationCheckBeforeResult})`))
return false
return
}
} else {
openSelectCharacterModal()
@@ -291,17 +277,23 @@ const handleCouponRegister = async () => {
const validationCheckBeforeResult = await validationCheckBefore()
if (validationCheckBeforeResult !== 0) {
if (
if (validationCheckBeforeResult === COUPON_RESULT.LOGIN_REQUIRED) {
// 미로그인일 경우 : 이미 validationCheckBefore 함수에서 로그인 모달 팝업 노출했으므로 추가 처리 필요 없음
return
} else if (
validationCheckBeforeResult === COUPON_RESULT.SELECT_CHARACTER_REQUIRED
) {
// 캐릭터 미선택일 경우 : 캐릭터 선택 모달 팝업 노출
openSelectCharacterModal()
return false
return
} else if (validationCheckBeforeResult === COUPON_RESULT.SYSTEM_ERROR) {
// 시스템 에러일 경우 : 에러 팝업 노출 (에러코드)
openAlert(t('Coupon_Error', { code: validationCheckBeforeResult }))
return false
return
} else {
// 그 외 오류 팝업 노출
openAlert(tm(`Coupon_Alert_(${validationCheckBeforeResult})`))
return false
return
}
} else {
await getClientIp()
@@ -356,8 +348,8 @@ const handlePeriodSearch = async () => {
}
const result = differenceInDays(endDate.value, startDate.value)
if (result > 365) {
openAlert(tm('Coupon_Msg_OverDays'))
if (result < 0 || result > 365) {
openAlert(tm('Coupon_Alert_OverDays'))
return
}
@@ -588,8 +580,6 @@ onMounted(async () => {
<BlocksDatePicker
:key="getTime(startDate)"
:date="startDate"
:min-date="minDate"
:max-date="maxDate"
@update:date="
(date: string) => setCouponDate(new Date(date), 'start')
"
@@ -602,8 +592,6 @@ onMounted(async () => {
<BlocksDatePicker
:key="getTime(endDate)"
:date="endDate"
:min-date="minDate"
:max-date="maxDate"
@update:date="
(date: string) => setCouponDate(new Date(date), 'end')
"
@@ -690,7 +678,14 @@ onMounted(async () => {
couponIdx === couponList.length - 1 ? '!border-b-[0]' : ''
"
>
<p>{{ coupon.register_date }}</p>
<p>
{{
globalDateFormat(
new Date(coupon.register_date),
locale.value
)
}}
</p>
</td>
<td
:class="