FeedForm.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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(['next'])
  12. function handleChooseAnswer(answer: PetCard) {
  13. emits('next', answer)
  14. }
  15. </script>
  16. <template>
  17. <view class="w-full flex justify-center items-center text-[20px] font-bold" :style="{ marginTop: formType === 3 ? '29px' : '69px' }">
  18. {{ props.title }}
  19. </view>
  20. <view v-if="formType === 1" class="flex w-full justify-center items-center mt-[37px] gap-3">
  21. <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)">
  22. <image v-if="index === 0" :src="item?.image" class="w-[76px] h-[69px] mt-[40px]" />
  23. <image v-else :src="item?.image" class="w-[96px] h-[73px] mt-[35px]" />
  24. <text class="mt-3">
  25. {{ item.name }}
  26. </text>
  27. </view>
  28. </view>
  29. <view v-if="formType === 2" class="flex flex-col w-full justify-center items-center mt-[37px] gap-4">
  30. <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)">
  31. {{ item.name }}
  32. </view>
  33. </view>
  34. <view v-if="formType === 3" class="flex flex-wrap w-full justify-center items-center mt-[39px] gap-2.5">
  35. <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)">
  36. <image :src="item.image" class="w-[101px] h-[76px] mt-[21px]" />
  37. <text class="mt-[13px]">
  38. {{ item.name }}
  39. </text>
  40. </view>
  41. </view>
  42. </template>
  43. <style scoped>
  44. </style>