farmCalendarPopup.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <popup
  3. v-model:show="showValue"
  4. round
  5. teleport="body"
  6. class="farm-calendar-popup"
  7. :z-index="20000"
  8. :close-on-click-overlay="false"
  9. >
  10. <div class="farm-calendar-popup__title">{{ t("agriFile.completeFarmInfo") }}</div>
  11. <div class="farm-calendar-popup__subtitle">
  12. {{ t("agriFile.getImmediately") }}
  13. <span>{{ t("workExecute.exclusiveFarmCalendar") }}</span>
  14. </div>
  15. <div class="farm-calendar-popup__days">
  16. <div
  17. v-for="(day, index) in weekDays"
  18. :key="day"
  19. class="farm-calendar-popup__day"
  20. :class="{ 'is-active': activeDay === index }"
  21. @click="activeDay = index"
  22. >
  23. {{ t(day) }}
  24. </div>
  25. </div>
  26. <div class="farm-calendar-popup__image">
  27. <img v-if="currentImage" :src="currentImage" alt="" />
  28. <slot v-else name="image" :day="activeDay"></slot>
  29. </div>
  30. <div class="farm-calendar-popup__btn" @click="handleOpen">{{ t("agriFile.goEnable") }}</div>
  31. </popup>
  32. </template>
  33. <script setup>
  34. import { computed, ref } from "vue";
  35. import { Popup } from "vant";
  36. import { useI18n } from "@/i18n";
  37. const { t } = useI18n();
  38. const props = defineProps({
  39. show: {
  40. type: Boolean,
  41. default: false,
  42. },
  43. images: {
  44. type: Array,
  45. default: () => [],
  46. },
  47. });
  48. const emit = defineEmits(["update:show", "confirm"]);
  49. const showValue = computed({
  50. get: () => props.show,
  51. set: (val) => emit("update:show", val),
  52. });
  53. const weekDays = ["week.1", "week.2", "week.3", "week.4", "week.5"];
  54. const activeDay = ref(1);
  55. const currentImage = computed(() => props.images[activeDay.value] || "");
  56. const handleOpen = () => {
  57. emit("confirm");
  58. showValue.value = false;
  59. };
  60. </script>
  61. <style scoped lang="scss">
  62. .farm-calendar-popup {
  63. width: 82%;
  64. padding: 20px 10px;
  65. text-align: center;
  66. background: linear-gradient(360deg, #FFFFFF 1.28%, #D7EEFF 55.76%, #FFFFFF 98.67%);
  67. &__title,
  68. &__subtitle {
  69. font-size: 24px;
  70. font-family: "pangmenzhengdao";
  71. line-height: 28px;
  72. }
  73. &__subtitle {
  74. span {
  75. color: #2199f8;
  76. }
  77. }
  78. &__days {
  79. display: flex;
  80. justify-content: space-between;
  81. gap: 12px;
  82. margin-top: 14px;
  83. }
  84. &__day {
  85. position: relative;
  86. flex: 1;
  87. border-radius: 4px 4px 0 0;
  88. background: #fff;
  89. padding: 4px 0;
  90. &.is-active {
  91. background: linear-gradient(149.44deg, #9FD5FF 2.43%, #2199F8 91.84%);
  92. color: #fff;
  93. border-radius: 4px;
  94. &::after {
  95. content: "";
  96. position: absolute;
  97. left: 50%;
  98. bottom: -5px;
  99. transform: translateX(-50%);
  100. border-left: 6px solid transparent;
  101. border-right: 6px solid transparent;
  102. border-top: 6px solid #2199f8;
  103. }
  104. }
  105. }
  106. &__image {
  107. width: 100%;
  108. height: 142px;
  109. margin: 12px 0 14px;
  110. border-radius: 5px;
  111. background: #f2f4f7;
  112. img {
  113. display: block;
  114. width: 100%;
  115. height: 100%;
  116. }
  117. }
  118. &__btn {
  119. width: 162px;
  120. margin: auto;
  121. padding: 8px 0;
  122. border-radius: 25px;
  123. background: #2199f8;
  124. color: #fff;
  125. font-size: 16px;
  126. }
  127. }
  128. </style>