FeedForm.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script setup lang="ts">
  2. import type { PetCard } from '@/model/pet-manual'
  3. const props = withDefaults(defineProps<{
  4. title: string
  5. formType: number
  6. answerList: PetCard[]
  7. }>(), {
  8. title: '',
  9. formType: 1,
  10. })
  11. const emits = defineEmits<{
  12. next: [PetCard]
  13. }>()
  14. function handleChooseAnswer(answer: PetCard) {
  15. emits('next', answer)
  16. }
  17. </script>
  18. <template>
  19. <view class="w-full flex justify-center items-center text-[20px] font-bold" :style="{ marginTop: formType === 3 ? '29px' : '69px' }">
  20. {{ props.title }}
  21. </view>
  22. <view v-if="formType === 1" class="flex w-full justify-center items-center mt-[37px] gap-3">
  23. <view v-for="(item, index) in props.answerList" :key="index" class="w-[136px] h-[154px] bg-[white] rounded-lg flex flex-col items-center " @click="handleChooseAnswer(item)">
  24. <image v-if="index === 0" :src="item?.image" class="w-[76px] h-[69px] mt-[40px]" />
  25. <image v-else :src="item?.image" class="w-[96px] h-[73px] mt-[35px]" />
  26. <text class="mt-3">
  27. {{ item.name }}
  28. </text>
  29. </view>
  30. </view>
  31. <view v-if="formType === 2" class="flex flex-col w-full justify-center items-center mt-[37px] gap-4">
  32. <view v-for="(item, index) in props.answerList" :key="index" class="w-[200px] h-[56px] bg-[white] rounded-3 flex items-center justify-center" @click="handleChooseAnswer(item)">
  33. {{ item.name }}
  34. </view>
  35. </view>
  36. <view v-if="formType === 3" class="flex flex-wrap w-full justify-center items-center mt-[39px] gap-2.5">
  37. <view v-for="(item, index) in answerList" :key="index" class="w-[143px] h-[134px] bg-[white] rounded-5 flex flex-col items-center text-[12px]" @click="handleChooseAnswer(item)">
  38. <image :src="item.image" class="w-[101px] h-[76px] mt-[21px]" />
  39. <text class="mt-[13px]">
  40. {{ item.name }}
  41. </text>
  42. </view>
  43. </view>
  44. </template>
  45. <style scoped>
  46. </style>