79 lines
2.4 KiB
Vue
79 lines
2.4 KiB
Vue
<template>
|
|||
|
|
<div>
|
||
|
|
<div class="bg-white py-3 px-3 text-black font-bold drop-shadow z-[1999] wrap-fix">کارت هدیه</div>
|
||
|
|
<div class="px-5 pt-26 pb-2">
|
||
|
|
<a-form :model="form" class="!mt-5" name="basic" @finish="registerGiftCard">
|
||
|
|
<div class="border-gray-200 border-1 rounded-xl p-5 trans h-40 relative">
|
||
|
|
<bg_main />
|
||
|
|
<div class="z-100 relative">
|
||
|
|
<a-form-item :rules="[required()]" label="کد کارت هدیه" name="code">
|
||
|
|
<BasicInput
|
||
|
|
v-model:value="form.code"
|
||
|
|
place-holder="کد کارت هدیه را وارد کنید"
|
||
|
|
size="large"
|
||
|
|
type="text"
|
||
|
|
/>
|
||
|
|
</a-form-item>
|
||
|
|
<div class="font-bold text-xs mt-3">
|
||
|
|
کد کارت هدیه خود را در فیلد بالا وارد کنید و سپس دکمه ثبت را بزنید.
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<a-form-item>
|
||
|
|
<BasicButton
|
||
|
|
:disabled="disableButton"
|
||
|
|
class="w-full py-2 mt-5"
|
||
|
|
html-type="submit"
|
||
|
|
type="primary"
|
||
|
|
>
|
||
|
|
<div>
|
||
|
|
<a-spin v-if="loading" size="small" />
|
||
|
|
<div v-else>ثبت کد</div>
|
||
|
|
</div>
|
||
|
|
</BasicButton>
|
||
|
|
</a-form-item>
|
||
|
|
</a-form>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script lang="ts" setup>
|
||
|
|
import { computed, ref } from 'vue'
|
||
|
|
import { loading } from '@/utils'
|
||
|
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||
|
|
import Bg_main from '@/components/bg_main.vue'
|
||
|
|
import { registerCodeGiftCard } from '@/api/giftCard'
|
||
|
|
import { message } from 'ant-design-vue'
|
||
|
|
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||
|
|
import { required } from '@/utils/inputRules'
|
||
|
|
|
||
|
|
const form = ref<{ code: string }>({
|
||
|
|
code: ''
|
||
|
|
})
|
||
|
|
|
||
|
|
const disableButton = computed(() => {
|
||
|
|
if (!loading.value) {
|
||
|
|
return !form.value.code || form.value.code.trim().length === 0
|
||
|
|
} else {
|
||
|
|
return true
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
async function registerGiftCard() {
|
||
|
|
try {
|
||
|
|
loading.value = true
|
||
|
|
await registerCodeGiftCard(form.value.code)
|
||
|
|
message.success('کد کارت هدیه با موفقیت ثبت شد')
|
||
|
|
form.value.code = ''
|
||
|
|
} catch (e: any) {
|
||
|
|
message.error(e?.response?.data?.message || 'خطا در ثبت کد کارت هدیه')
|
||
|
|
} finally {
|
||
|
|
loading.value = false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style scoped>
|
||
|
|
|
||
|
|
</style>
|