index.vue 6.0 KB

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