You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
6.3 KiB

2 years ago
2 years ago
  1. <template>
  2. <section :class="['tw-relative']">
  3. <div
  4. class="tw-relative tw-grid tw-grid-cols-2 tw-gap-[10px] tw-float-right tw-top-[4px]"
  5. >
  6. <div
  7. :class="[
  8. 'swiper-button-prev trendingServices tw-relative tw-text-black tw-w-[40px] tw-h-[40px] tw-left-0 tw-text-center tw-border-solid tw-border tw-border-neutrals-300 tw-rounded-[10px] tw-p-[8px] tw-hidden xl:tw-block',
  9. ]"
  10. ></div>
  11. <div
  12. :class="[
  13. 'swiper-button-next trendingServices tw-relative tw-text-black tw-w-[40px] tw-h-[40px] tw-right-0 tw-text-center tw-border-solid tw-border tw-border-neutrals-300 tw-rounded-[10px] tw-p-[8px] tw-hidden xl:tw-block',
  14. ]"
  15. ></div>
  16. </div>
  17. <div class="swiper-container trendingServices" ref="trendingServices">
  18. <div :class="['swiper-wrapper']">
  19. <div
  20. v-for="(item, index) in services"
  21. :key="index"
  22. :class="['swiper-slide']"
  23. >
  24. <skeletonSlot>
  25. <template #default
  26. ><TrendingServiceCard
  27. :item="item"
  28. :countryNameList="countryNameList"
  29. :cityNameList="cityNameList"
  30. :regionNameList="regionNameList"
  31. /></template>
  32. <template #fallback
  33. ><TrendingServiceSkeleton></TrendingServiceSkeleton
  34. ></template>
  35. </skeletonSlot>
  36. </div>
  37. </div>
  38. </div>
  39. </section>
  40. </template>
  41. <script>
  42. import Swiper from "swiper/bundle";
  43. import TrendingServiceCard from "~/components/home/TrendingServiceCard.vue";
  44. import TrendingServiceSkeleton from "~/components/newComponent/skeleton/trendingServiceSkeleton.vue";
  45. import skeletonSlot from "~/components/newComponent/skeleton/skeletonSlot.vue";
  46. export default {
  47. components: {
  48. Swiper,
  49. TrendingServiceCard,
  50. TrendingServiceSkeleton,
  51. skeletonSlot,
  52. },
  53. props: {
  54. services: {
  55. type: Array,
  56. },
  57. },
  58. data() {
  59. return {
  60. perColumn: null,
  61. service: {
  62. rating: "4.6",
  63. reviews: "344",
  64. discount: "10",
  65. total: "500"
  66. },
  67. countryNameList: [],
  68. cityNameList: [],
  69. regionNameList: [],
  70. };
  71. },
  72. created() {
  73. // this.getUnSortLocationList();
  74. this.countryNameList = [ 'Vietnam', 'Vietnam' ];
  75. this.cityNameList = [ 'Vietnam', 'Vietnam' ];
  76. this.regionNameList = [ 'Asia', 'Asia' ];
  77. },
  78. mounted() {
  79. let vm = this;
  80. vm.$nextTick(function () {
  81. vm.perColumn = new Swiper(".swiper-container.trendingServices", {
  82. direction: "horizontal",
  83. initialSlide: 0,
  84. slidesPerView: 1.8,
  85. slidesPerGroup: 2,
  86. observer: true, //修改swiper自己或子元素时,自动初始化swiper
  87. observeParents: true, //修改swiper的父元素时,自动初始化swiper
  88. spaceBetween: 15,
  89. preloadImages: false,
  90. lazy: {
  91. loadPrevNext: true,
  92. loadOnTransitionStart: true,
  93. loadPrevNextAmount: 3,
  94. },
  95. navigation: {
  96. prevEl: ".swiper-button-prev.trendingServices",
  97. nextEl: ".swiper-button-next.trendingServices",
  98. },
  99. breakpoints: {
  100. 768: {
  101. spaceBetween: 22,
  102. slidesPerView: 2.45,
  103. lazy: {
  104. loadPrevNext: true,
  105. loadOnTransitionStart: true,
  106. loadPrevNextAmount: 3,
  107. },
  108. },
  109. 1366: {
  110. slidesPerView: 4,
  111. slidesPerGroup: 4,
  112. spaceBetween: 30,
  113. grabCursor: true,
  114. lazy: {
  115. loadPrevNext: true,
  116. loadOnTransitionStart: true,
  117. loadPrevNextAmount: 4,
  118. },
  119. },
  120. },
  121. });
  122. vm.perColumn.lazy.load();
  123. });
  124. },
  125. methods: {
  126. async getUnSortLocationList() {
  127. // await this.$axios
  128. // .get(
  129. // `/t/exhibitions/locations?lang=${this.$i18n.localeProperties["langQuery"]}&sort=false`
  130. // )
  131. // .then((result) => {
  132. // this.countryNameList = result.data.country_name_list;
  133. // this.cityNameList = result.data.city_name_list;
  134. // this.regionNameList = result.data.region_name_list;
  135. // })
  136. // .catch((err) => {
  137. // console.log(err);
  138. // });
  139. },
  140. },
  141. };
  142. </script>
  143. <style lang="scss" scoped>
  144. .swiper-container {
  145. width: 100% !important;
  146. }
  147. .swiper-button {
  148. &-prev.trendingServices {
  149. z-index: 4;
  150. &:focus-visible {
  151. outline: none;
  152. }
  153. &::after {
  154. font-size: 24px;
  155. font-weight: bold;
  156. text-align: center;
  157. color: transparent;
  158. background-image: url("~/assets/svg/u-angle-left-b.svg");
  159. background-position: center;
  160. background-repeat: no-repeat;
  161. background-size: cover;
  162. }
  163. &:focus-visible,
  164. &:focus {
  165. outline: none;
  166. }
  167. }
  168. &-next.trendingServices {
  169. z-index: 4;
  170. &:focus-visible {
  171. outline: none;
  172. }
  173. &::after {
  174. font-size: 24px;
  175. font-weight: bold;
  176. text-align: center;
  177. color: transparent;
  178. background-image: url("~/assets/svg/u-angle-right-b.svg");
  179. background-position: center;
  180. background-repeat: no-repeat;
  181. background-size: cover;
  182. }
  183. &:focus-visible,
  184. &:focus {
  185. outline: none;
  186. }
  187. }
  188. }
  189. .row1 {
  190. position: relative;
  191. }
  192. .right-arrow {
  193. position: absolute;
  194. top: 20%;
  195. right: -20px;
  196. border: 2px solid;
  197. padding: 10px 15px;
  198. border-radius: 10px;
  199. }
  200. .card {
  201. border: 0.5px solid rgba(200, 200, 200, 0.5);
  202. }
  203. .inline-img {
  204. display: inline-block;
  205. }
  206. .card-image {
  207. position: relative;
  208. }
  209. .heart {
  210. position: absolute;
  211. top: 10%;
  212. right: 10%;
  213. }
  214. .text-to-grey {
  215. color: #9c9c9c !important;
  216. }
  217. #carousel:after {
  218. content: "";
  219. display: none;
  220. position: absolute;
  221. /*也可以设置绝对定位*/
  222. top: 0;
  223. left: 0;
  224. height: 320px;
  225. width: 100%;
  226. z-index: 3;
  227. background-image: url("~/assets/img/travelPic2.png");
  228. background-size: 100% 320px;
  229. }
  230. #slide-group:after {
  231. content: "";
  232. display: none;
  233. position: absolute;
  234. /*也可以设置绝对定位*/
  235. top: 0;
  236. left: 0;
  237. height: 350px;
  238. width: 100%;
  239. z-index: 3;
  240. background-image: url("~/assets/img/travelPic2.png");
  241. background-size: inherit 330px;
  242. background-position: 50% 50%;
  243. background-repeat: repeat-y;
  244. }
  245. :deep() {
  246. .v-carousel__controls {
  247. display: none;
  248. }
  249. }
  250. </style>