ActivitiesSwiper.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view class="swiper-card">
  3. <view class="swiper-header">
  4. <view class="font-medium"> Promotions</view>
  5. <view class="btn" @click="toActivities">
  6. View All
  7. </view>
  8. </view>
  9. <cwg-wiper :list="bannerList" @click="onSwiperClick" />
  10. </view>
  11. </template>
  12. <script setup lang="ts">
  13. import { computed, ref, onMounted } from 'vue';
  14. import { useI18n } from 'vue-i18n';
  15. const { t, locale } = useI18n();
  16. import { customApi } from '@/service/custom';
  17. import useUserStore from "@/stores/use-user-store";
  18. import useRouter from "@/hooks/useRouter";
  19. const router = useRouter();
  20. const bannerList = ref([
  21. { image: '/static/images/su.png', content: 'Banner 1' },
  22. { image: '/static/images/yue.jpg', content: 'Banner 2' },
  23. { image: '/static/images/cash-carnival.webp', content: 'Banner 3' }
  24. ])
  25. // 活动详情
  26. const onSwiperClick = (index: number) => {
  27. switch (index) {
  28. case 0:
  29. router.push('/pages/activities/index');
  30. break;
  31. case 1:
  32. router.push('/pages/promotions/index');
  33. break;
  34. case 2:
  35. router.push('/pages/news/index');
  36. break;
  37. default:
  38. break;
  39. }
  40. }
  41. const toActivities = () => {
  42. router.push('/pages/activities/index');
  43. }
  44. </script>
  45. <style scoped lang="scss">
  46. @import "@/uni.scss";
  47. .swiper-card {
  48. padding: px2rpx(12);
  49. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  50. display: flex;
  51. flex-direction: column;
  52. min-width: 1px;
  53. overflow-wrap: break-word;
  54. position: relative;
  55. max-width: px2rpx(576);
  56. box-sizing: border-box;
  57. margin: 0 auto;
  58. margin-bottom: px2rpx(20);
  59. .swiper-header {
  60. display: flex;
  61. align-items: center;
  62. justify-content: space-between;
  63. margin-bottom: px2rpx(12);
  64. .font-medium {
  65. font-size: px2rpx(21);
  66. font-weight: 600;
  67. color: #fff;
  68. }
  69. .btn {
  70. font-size: px2rpx(14);
  71. color: var(--color-white);
  72. padding: px2rpx(12) px2rpx(16);
  73. border: none;
  74. background-color: var(--color-error);
  75. cursor: pointer;
  76. }
  77. }
  78. }
  79. .custom-swiper {
  80. width: 100%;
  81. }
  82. .swiper-item {
  83. width: 100%;
  84. height: 100%;
  85. display: flex;
  86. align-items: center;
  87. justify-content: center;
  88. .swiper-image {
  89. width: 100%;
  90. height: 100%;
  91. object-fit: cover;
  92. }
  93. .default-content {
  94. font-size: 28rpx;
  95. color: var(--bs-heading-color);
  96. }
  97. }
  98. // 自定义指示点
  99. .swiper-dots {
  100. position: absolute;
  101. bottom: 20rpx;
  102. left: 0;
  103. right: 0;
  104. display: flex;
  105. align-items: center;
  106. justify-content: center;
  107. gap: 16rpx;
  108. z-index: 10;
  109. .dot {
  110. width: 16rpx;
  111. height: 16rpx;
  112. border-radius: 50%;
  113. background-color: rgba(255, 255, 255, 0.5);
  114. transition: all 0.3s;
  115. &-active {
  116. width: 32rpx;
  117. border-radius: 16rpx;
  118. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  119. }
  120. }
  121. }
  122. // 滚动条
  123. .swiper-scrollbar {
  124. position: absolute;
  125. bottom: 0;
  126. left: 0;
  127. right: 0;
  128. height: 4rpx;
  129. background-color: rgba(0, 0, 0, 0.1);
  130. z-index: 10;
  131. .swiper-scrollbar-drag {
  132. height: 100%;
  133. background-color: rgba(255, 255, 255, 0.8);
  134. border-radius: 4rpx;
  135. transition: transform 0.3s;
  136. }
  137. }
  138. // 导航按钮
  139. .swiper-navigation {
  140. position: absolute;
  141. top: 50%;
  142. left: 0;
  143. right: 0;
  144. transform: translateY(-50%);
  145. display: flex;
  146. align-items: center;
  147. justify-content: space-between;
  148. padding: 0 20rpx;
  149. z-index: 10;
  150. pointer-events: none;
  151. .swiper-button-prev,
  152. .swiper-button-next {
  153. width: 60rpx;
  154. height: 60rpx;
  155. background-color: rgba(0, 0, 0, 0.3);
  156. border-radius: 50%;
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. cursor: pointer;
  161. pointer-events: auto;
  162. transition: all 0.3s;
  163. &.swiper-button-disabled {
  164. opacity: 0.3;
  165. pointer-events: none;
  166. }
  167. &:active {
  168. background-color: rgba(0, 0, 0, 0.5);
  169. }
  170. .swiper-navigation-icon {
  171. width: 24rpx;
  172. height: 40rpx;
  173. color: var(--color-white);
  174. }
  175. }
  176. }
  177. // 深色背景适配
  178. .dark-theme {
  179. .swiper-dots .dot {
  180. background-color: rgba(255, 255, 255, 0.3);
  181. &-active {
  182. background-color: #ffd700;
  183. }
  184. }
  185. .swiper-scrollbar {
  186. background-color: rgba(255, 255, 255, 0.2);
  187. .swiper-scrollbar-drag {
  188. background-color: #ffd700;
  189. }
  190. }
  191. }
  192. </style>