index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="container">
  3. <!-- 上半部分:轮播图区域 -->
  4. <view class="top-section">
  5. <swiper class="swiper" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000"
  6. :circular="true" indicator-active-color="#1B64F0" indicator-color="rgba(255, 255, 255, 0.6)"
  7. indicator-class="swiper-indicator" active-class="swiper-indicator-active">
  8. <swiper-item v-for="(item, index) in swiperList" :key="index">
  9. <view class="swiper-item">
  10. <image class="swiper-img" :src="item.imageUrl" mode="aspectFill" />
  11. </view>
  12. </swiper-item>
  13. </swiper>
  14. </view>
  15. <view class="btn-container">
  16. <view class="btn-item" @click="handleExpress('2')">
  17. <image class="button-icon" src="/static/img/index-time.png" />
  18. <view class="button-right">
  19. <view class="button-title">瑞鲸速达(顺丰)</view>
  20. <view class="button-desc">一小时下单取件</view>
  21. </view>
  22. </view>
  23. <view class="btn-item" @click="handleExpress('1')">
  24. <image class="button-icon" src="/static/img/index-un-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="showExpressDialog">
  31. <image class="button-icon" src="/static/img/index-personal.png" />
  32. <view class="button-right">
  33. <view class="button-title">个人寄件</view>
  34. <view class="button-desc">支持顺丰和京东</view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 使用 u-popup 弹框组件 -->
  39. <PersonalExpressDialog :visible="showDialog" @update:visible="showDialog = $event"
  40. @select="handleExpressSelect" />
  41. </view>
  42. </template>
  43. <script setup>
  44. import {
  45. ref,
  46. onMounted
  47. } from 'vue'
  48. import {
  49. onShow
  50. } from '@dcloudio/uni-app'
  51. // 导入 u-popup 弹框组件
  52. import PersonalExpressDialog from './components/PersonalExpressDialog.vue'
  53. import {
  54. bannerList
  55. } from '../../api/user'
  56. import {
  57. checkLoginShowModal,
  58. quickLogin
  59. } from "@/utils/util.js";
  60. const showDialog = ref(false)
  61. // 轮播图数据
  62. const swiperList = ref([])
  63. onShow(() => {
  64. getBannerList()
  65. })
  66. const getBannerList = () => {
  67. bannerList().then(res => {
  68. if (res.code == 200) {
  69. swiperList.value = res.data
  70. }
  71. }, {})
  72. }
  73. const showExpressDialog = () => {
  74. console.log('显示个人寄件弹框')
  75. showDialog.value = true
  76. }
  77. const handleExpressSelect = (company) => {
  78. uni.showToast({
  79. title: `已选择${company}物流`,
  80. icon: 'success',
  81. duration: 1500
  82. })
  83. // 模拟跳转到下单页面
  84. setTimeout(() => {
  85. uni.showLoading({
  86. title: '正在跳转...'
  87. })
  88. setTimeout(() => {
  89. uni.hideLoading()
  90. // 实际跳转代码
  91. // uni.navigateTo({
  92. // url: `/pages/order/create?company=${company}`
  93. // })
  94. }, 800)
  95. }, 500)
  96. }
  97. const handleExpress = async (company) => {
  98. if (!await checkLoginShowModal()) return;
  99. uni.navigateTo({
  100. url: `/pages/order/create_order?product=${company}`
  101. })
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .container {
  106. display: flex;
  107. flex-direction: column;
  108. height: 100vh;
  109. background-color: #F5F7FA;
  110. }
  111. .top-section {
  112. height: 563rpx;
  113. position: relative;
  114. }
  115. .swiper {
  116. width: 100%;
  117. height: 100%;
  118. position: relative;
  119. }
  120. .swiper-item {
  121. width: 100%;
  122. height: 100%;
  123. position: relative;
  124. }
  125. .swiper-img {
  126. width: 100%;
  127. height: 100%;
  128. object-fit: cover;
  129. }
  130. /* 自定义指示点样式 - 通过定位调整位置 */
  131. /* 方法一:调整整个指示器容器的位置 */
  132. /* 注意:在不同平台可能需要使用不同的选择器 */
  133. /* 微信小程序 */
  134. ::v-deep .wx-swiper-dots {
  135. bottom: 80rpx !important;
  136. /* 调整指示器容器的位置 */
  137. display: flex !important;
  138. justify-content: center !important;
  139. align-items: center !important;
  140. }
  141. /* H5平台 */
  142. ::v-deep .uni-swiper-dots {
  143. bottom: 80rpx !important;
  144. /* 调整指示器容器的位置 */
  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. /* 调整指示器的垂直位置 */
  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>