index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view class="container">
  3. <!-- 上半部分:轮播图区域 -->
  4. <view class="top-section">
  5. <swiper class="swiper"
  6. :indicator-dots="true"
  7. :autoplay="true"
  8. :interval="3000"
  9. :duration="1000"
  10. :circular="true"
  11. indicator-active-color="#1B64F0"
  12. indicator-color="rgba(255, 255, 255, 0.6)"
  13. indicator-class="swiper-indicator"
  14. active-class="swiper-indicator-active">
  15. <swiper-item v-for="(item, index) in swiperList" :key="index">
  16. <view class="swiper-item">
  17. <image class="swiper-img" :src="item.imageUrl" mode="aspectFill" />
  18. </view>
  19. </swiper-item>
  20. </swiper>
  21. </view>
  22. <view class="btn-container">
  23. <view class="btn-item" @click="handleExpress('2')">
  24. <image class="button-icon" src="/static/img/index-time.png" />
  25. <view class="button-right">
  26. <view class="button-title">瑞鲸速达(顺丰)</view>
  27. <view class="button-desc">一小时下单取件</view>
  28. </view>
  29. </view>
  30. <view class="btn-item" @click="handleExpress('1')">
  31. <image class="button-icon" src="/static/img/index-un-time.png" />
  32. <view class="button-right">
  33. <view class="button-title">瑞鲸速达(京东)</view>
  34. <view class="button-desc">下单当日取件</view>
  35. </view>
  36. </view>
  37. <view class="btn-item" @click="showExpressDialog">
  38. <image class="button-icon" src="/static/img/index-personal.png" />
  39. <view class="button-right">
  40. <view class="button-title">个人寄件</view>
  41. <view class="button-desc">支持顺丰和京东</view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 使用 u-popup 弹框组件 -->
  46. <PersonalExpressDialog :visible="showDialog" @update:visible="showDialog = $event"
  47. @select="handleExpressSelect" />
  48. </view>
  49. </template>
  50. <script setup>
  51. import {
  52. ref,onMounted
  53. } from 'vue'
  54. // 导入 u-popup 弹框组件
  55. import PersonalExpressDialog from './components/PersonalExpressDialog.vue'
  56. import { bannerList } from '../../api/user'
  57. const showDialog = ref(false)
  58. // 轮播图数据
  59. const swiperList = ref([])
  60. onMounted(()=>{
  61. getBannerList()
  62. })
  63. const getBannerList = ()=>{
  64. bannerList().then(res=>{
  65. if(res.code == 200){
  66. swiperList.value = res.data
  67. }
  68. },{})
  69. }
  70. const showExpressDialog = () => {
  71. console.log('显示个人寄件弹框')
  72. showDialog.value = true
  73. }
  74. const handleExpressSelect = (company) => {
  75. uni.showToast({
  76. title: `已选择${company}物流`,
  77. icon: 'success',
  78. duration: 1500
  79. })
  80. // 模拟跳转到下单页面
  81. setTimeout(() => {
  82. uni.showLoading({
  83. title: '正在跳转...'
  84. })
  85. setTimeout(() => {
  86. uni.hideLoading()
  87. // 实际跳转代码
  88. // uni.navigateTo({
  89. // url: `/pages/order/create?company=${company}`
  90. // })
  91. }, 800)
  92. }, 500)
  93. }
  94. const handleExpress = (company) => {
  95. uni.navigateTo({
  96. url: `/pages/order/create_order?product=${company}`
  97. })
  98. // 实际跳转代码
  99. // setTimeout(() => {
  100. // uni.navigateTo({
  101. // url: `/pages/order/create?company=${company}`
  102. // })
  103. // }, 1500)
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .container {
  108. display: flex;
  109. flex-direction: column;
  110. height: 100vh;
  111. background-color: #F5F7FA;
  112. }
  113. .top-section {
  114. height: 563rpx;
  115. position: relative;
  116. }
  117. .swiper {
  118. width: 100%;
  119. height: 100%;
  120. position: relative;
  121. }
  122. .swiper-item {
  123. width: 100%;
  124. height: 100%;
  125. position: relative;
  126. }
  127. .swiper-img {
  128. width: 100%;
  129. height: 100%;
  130. object-fit: cover;
  131. }
  132. /* 自定义指示点样式 - 通过定位调整位置 */
  133. /* 方法一:调整整个指示器容器的位置 */
  134. /* 注意:在不同平台可能需要使用不同的选择器 */
  135. /* 微信小程序 */
  136. ::v-deep .wx-swiper-dots {
  137. bottom: 80rpx !important; /* 调整指示器容器的位置 */
  138. display: flex !important;
  139. justify-content: center !important;
  140. align-items: center !important;
  141. }
  142. /* H5平台 */
  143. ::v-deep .uni-swiper-dots {
  144. bottom: 80rpx !important; /* 调整指示器容器的位置 */
  145. display: flex !important;
  146. justify-content: center !important;
  147. align-items: center !important;
  148. }
  149. /* 方法二:直接修改指示点样式,通过调整父容器样式 */
  150. .swiper-indicator {
  151. width: 8rpx !important;
  152. height: 8rpx !important;
  153. border-radius: 50% !important;
  154. background: rgba(255, 255, 255, 0.6) !important;
  155. margin: 0 4rpx !important;
  156. }
  157. .swiper-indicator-active {
  158. width: 32rpx !important;
  159. height: 8rpx !important;
  160. background: #1B64F0 !important;
  161. border-radius: 4rpx !important;
  162. }
  163. /* 方法三:如果上述方法都不生效,可以使用绝对定位自定义指示器 */
  164. .custom-indicator {
  165. position: absolute;
  166. left: 0;
  167. right: 0;
  168. bottom: 80rpx; /* 调整指示器的垂直位置 */
  169. z-index: 10;
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. }
  174. .custom-indicator-dot {
  175. width: 8rpx;
  176. height: 8rpx;
  177. border-radius: 50%;
  178. background: rgba(255, 255, 255, 0.6);
  179. margin: 0 4rpx;
  180. transition: all 0.3s ease;
  181. }
  182. .custom-indicator-dot.active {
  183. width: 32rpx;
  184. height: 8rpx;
  185. background: #1B64F0;
  186. border-radius: 4rpx;
  187. }
  188. .btn-container{
  189. display: flex;
  190. flex-wrap: wrap;
  191. justify-content: space-between;
  192. position: relative;
  193. top: -40rpx;
  194. padding: 0rpx 20rpx;
  195. .btn-item{
  196. width: 339rpx;
  197. height: 172rpx;
  198. background: #FFFFFF;
  199. box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(27,100,240,0.08), 0rpx 0rpx 8rpx 0rpx rgba(27,100,240,0.08);
  200. border-radius: 32rpx;
  201. border: 2rpx solid #FFFFFF;
  202. display: flex;
  203. justify-content: center;
  204. align-items: center;
  205. padding: 20rpx 0rpx 20rpx 20rpx;
  206. margin-bottom: 32rpx;
  207. .button-icon{
  208. width: 88rpx;
  209. height: 88rpx;
  210. }
  211. .button-right{
  212. display: flex;
  213. flex-direction: column;
  214. flex: 1;
  215. margin-left: 16rpx;
  216. .button-title {
  217. height: 48rpx;
  218. line-height: 48rpx;
  219. font-size: 28rpx;
  220. font-weight: bold;
  221. color: #333;
  222. flex-shrink: 0;
  223. }
  224. .button-desc {
  225. height: 44rpx;
  226. line-height: 44rpx;
  227. font-size: 24rpx;
  228. color: #666;
  229. margin-top: 8rpx;
  230. }
  231. }
  232. }
  233. }
  234. </style>