LeftRightBox.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="main-box main-left-right-box row">
  3. <div class="col col-12 col-lg-6 col-md-6">
  4. <template v-if="left">
  5. <Carousel v-if="rightItems && rightItems.length > 0" v-bind="carousel2Config" class="carousel-light h-100">
  6. <Slide
  7. v-for="(item, index) in rightItems"
  8. :key="index"
  9. @click="() => item.link ? undefined : emit('rightItemDefaultClick', item)"
  10. >
  11. <NuxtLink v-if="item.link" :to="item.link" class="w-100 h-100">
  12. <ImageTitleBlock fit
  13. :image="item.image"
  14. :title="item.title"
  15. :desc="item.desc"
  16. />
  17. </NuxtLink>
  18. <ImageTitleBlock v-else fit
  19. :image="item.image"
  20. :title="item.title"
  21. :desc="item.desc"
  22. />
  23. </Slide>
  24. <template #addons>
  25. <Navigation />
  26. <Pagination />
  27. </template>
  28. </Carousel>
  29. <img v-else :src="image" alt="image" class="h-100" @click="emit('moreClick')" />
  30. </template>
  31. <TitleDescBlock
  32. v-else
  33. :title="title"
  34. :desc="desc"
  35. :descLines="descLines"
  36. :showExpand="showExpand"
  37. :more="showMore"
  38. :moreLink="moreLink"
  39. @moreClick="emit('moreClick')"
  40. />
  41. </div>
  42. <div class="col col-12 col-lg-6 col-md-6">
  43. <TitleDescBlock
  44. v-if="left"
  45. :title="title"
  46. :desc="desc"
  47. :descLines="descLines"
  48. :showExpand="showExpand"
  49. :more="showMore"
  50. :moreLink="moreLink"
  51. @moreClick="emit('moreClick')"
  52. />
  53. <template v-else>
  54. <Carousel v-if="rightItems && rightItems.length > 0" v-bind="carousel2Config" class="carousel-light h-100">
  55. <Slide
  56. v-for="(item, index) in rightItems"
  57. :key="index"
  58. @click="() => item.link ? undefined : emit('rightItemDefaultClick', item)"
  59. >
  60. <NuxtLink v-if="item.link" :to="item.link" class="w-100 h-100">
  61. <ImageTitleBlock fit
  62. :image="item.image"
  63. :title="item.title"
  64. :desc="item.desc"
  65. />
  66. </NuxtLink>
  67. <ImageTitleBlock v-else fit
  68. :image="item.image"
  69. :title="item.title"
  70. :desc="item.desc"
  71. />
  72. </Slide>
  73. <template #addons>
  74. <Navigation />
  75. <Pagination />
  76. </template>
  77. </Carousel>
  78. <NuxtLink v-else-if="moreLink" :to="moreLink">
  79. <img :src="image" alt="image" class="h-100" />
  80. </NuxtLink>
  81. <img v-else :src="image" alt="image" class="h-100" @click="emit('moreClick')" />
  82. </template>
  83. </div>
  84. </div>
  85. </template>
  86. <script setup lang="ts">
  87. import type { PropType } from 'vue';
  88. import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel'
  89. import TitleDescBlock from './TitleDescBlock.vue';
  90. import ImageTitleBlock from '@/components/parts/ImageTitleBlock.vue';
  91. const carousel2Config = {
  92. itemsToShow: 1,
  93. mouseWheel: true,
  94. wrapAround: true
  95. }
  96. defineProps({
  97. title : {
  98. type: String,
  99. default: '',
  100. },
  101. desc: {
  102. type: String,
  103. default: '',
  104. },
  105. image: {
  106. type: String,
  107. default: '',
  108. },
  109. rightItems: {
  110. type: Object as PropType<Array<{
  111. title: string,
  112. desc: string,
  113. image: string ,
  114. link?: string,
  115. }>|null>,
  116. default: null,
  117. },
  118. descLines: {
  119. type: Number,
  120. default: 3,
  121. },
  122. left: {
  123. type: Boolean,
  124. default: false,
  125. },
  126. showExpand: {
  127. type: Boolean,
  128. default: true,
  129. },
  130. showMore: {
  131. type: Boolean,
  132. default: true,
  133. },
  134. moreLink: {
  135. type: String,
  136. default: '',
  137. },
  138. })
  139. const emit = defineEmits([
  140. "moreClick" , 'rightItemDefaultClick'
  141. ])
  142. </script>
  143. <style lang="scss">
  144. .main-left-right-box {
  145. .col {
  146. position: relative;
  147. padding: 0!important;
  148. }
  149. img {
  150. max-width: 100%;
  151. object-fit: cover;
  152. }
  153. .TitleDescBlock {
  154. padding: 25px;
  155. }
  156. .ImageTitleBlock {
  157. height: 100%;
  158. min-height: 250px;
  159. }
  160. }
  161. </style>