index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view class="home-page">
  3. <!-- 搜索栏 -->
  4. <view class="search-wrapper">
  5. <view class="location-box" @click="onLocationClick">
  6. <text class="location-text">昆明市</text>
  7. <uni-icons type="bottom" size="10" color="#fff"></uni-icons>
  8. </view>
  9. <view class="search-bar" @click="onSearchClick">
  10. <uni-icons type="search" size="16" color="#999"></uni-icons>
  11. <text class="search-placeholder">搜索宠物名/主人</text>
  12. </view>
  13. </view>
  14. <!-- 轮播图 -->
  15. <view class="banner-swipe-wrapper">
  16. <swiper class="my-swipe" :autoplay="true" :interval="3000" :circular="true" indicator-dots
  17. indicator-active-color="#ffffff" indicator-color="rgba(255,255,255,0.5)">
  18. <swiper-item v-for="(image, index) in bannerImages" :key="index">
  19. <image :src="image" class="swipe-img" mode="aspectFill"></image>
  20. </swiper-item>
  21. </swiper>
  22. </view>
  23. <!-- 系统通知栏 -->
  24. <view class="notice-section">
  25. <view class="notice-bar">
  26. <uni-icons type="sound" size="14" color="#ed6a0c"></uni-icons>
  27. <scroll-view scroll-x class="notice-scroll" :show-scrollbar="false">
  28. <text class="notice-text">【重要通知】尊敬的用户,由于近期接送需求激增,请各位宠主尽量提前24小时进行服务预约,感谢您的理解与配合!</text>
  29. </scroll-view>
  30. </view>
  31. </view>
  32. <!-- 服务分类卡片 -->
  33. <view class="service-grid">
  34. <!-- 左侧大块:宠物托运 -->
  35. <view class="grid-item item-transport-large" @click="goToDetail('托运')">
  36. <view class="text-info">
  37. <text class="grid-title">宠物托运</text>
  38. <text class="grid-desc">专车接送 · 全程监护</text>
  39. </view>
  40. <image src="/static/images/transport-3d.png" class="large-3d-icon" mode="aspectFit"></image>
  41. </view>
  42. <!-- 右侧两个小块 -->
  43. <view class="grid-right">
  44. <view class="grid-item item-wash-small" @click="goToDetail('洗护')">
  45. <view class="text-info">
  46. <text class="grid-title">宠物洗护</text>
  47. <text class="sub-text">深度清洁</text>
  48. </view>
  49. <image src="/static/images/wash-3d.png" class="small-3d-icon" mode="aspectFit"></image>
  50. </view>
  51. <view class="grid-item item-feed-small" @click="goToDetail('喂养')">
  52. <view class="text-info">
  53. <text class="grid-title">宠物喂养</text>
  54. <text class="sub-text">贴心陪伴</text>
  55. </view>
  56. <image src="/static/images/feed-3d.png" class="small-3d-icon" mode="aspectFit"></image>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 全部服务列表 -->
  61. <view class="section-header">
  62. <text class="section-title">全部服务</text>
  63. <view class="more-link" @click="goToServices">
  64. <text>查看全部</text>
  65. <uni-icons type="right" size="12" color="#999"></uni-icons>
  66. </view>
  67. </view>
  68. <view class="recommend-list">
  69. <view class="recommend-card" v-for="(item, index) in services.slice(0, 5)" :key="index"
  70. @click="goToDetail(item.name)">
  71. <image :src="item.iconUrl" class="item-img" mode="aspectFill"></image>
  72. <view class="item-info">
  73. <view class="item-header">
  74. <text class="item-title">{{ item.name }}</text>
  75. </view>
  76. <text class="item-desc">{{ item.remark }}</text>
  77. <view class="item-bottom">
  78. <text class="tag" v-if="serviceModeEnum[item.mode]">{{ serviceModeEnum[item.mode] }}</text>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <custom-tabbar></custom-tabbar>
  84. </view>
  85. </template>
  86. <script setup>
  87. import { ref } from 'vue'
  88. import { onShow } from '@dcloudio/uni-app'
  89. import customTabbar from '@/components/custom-tabbar/index.vue'
  90. import mockData from '@/mock/index.json'
  91. import { listAll } from '@/api/service/list'
  92. import serviceModeEnum from '@/json/serviceMode.json'
  93. const bannerImages = mockData.bannerImages
  94. const services = ref([])
  95. const fetchServices = async () => {
  96. try {
  97. const res = await listAll()
  98. services.value = res || []
  99. } catch (error) {
  100. console.error("Failed to fetch services", error)
  101. }
  102. }
  103. onShow(() => {
  104. fetchServices()
  105. })
  106. const onLocationClick = () => {
  107. uni.showToast({ title: '城市选择功能即将上线', icon: 'none' })
  108. }
  109. const onSearchClick = () => {
  110. // 跳转搜索页(预留)
  111. }
  112. const goToServices = () => {
  113. uni.reLaunch({ url: '/pages/service/all/index' })
  114. }
  115. const goToDetail = (type) => {
  116. if (type === '托运') {
  117. uni.reLaunch({ url: '/pages/service/all/index' })
  118. return
  119. }
  120. uni.navigateTo({
  121. url: `/pages/service/detail/index?service=${type}`
  122. })
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .home-page {
  127. background-image: linear-gradient(to bottom, #FFD93D 0%, #FFD93D 440rpx, #f2f2f2 440rpx, #f2f2f2 100%);
  128. min-height: 100vh;
  129. padding-bottom: 120rpx;
  130. }
  131. .search-wrapper {
  132. padding: 24rpx 32rpx;
  133. padding-top: calc(var(--status-bar-height, 44px) + 20rpx);
  134. display: flex;
  135. align-items: center;
  136. gap: 16rpx;
  137. }
  138. .location-box {
  139. display: flex;
  140. align-items: center;
  141. gap: 6rpx;
  142. flex-shrink: 0;
  143. }
  144. .location-text {
  145. font-size: 28rpx;
  146. color: #fff;
  147. font-weight: bold;
  148. }
  149. .search-bar {
  150. flex: 1;
  151. display: flex;
  152. align-items: center;
  153. background: rgba(255, 255, 255, 0.85);
  154. border-radius: 40rpx;
  155. padding: 16rpx 24rpx;
  156. gap: 12rpx;
  157. }
  158. .search-placeholder {
  159. font-size: 26rpx;
  160. color: #999;
  161. }
  162. .banner-swipe-wrapper {
  163. padding: 0 32rpx 24rpx;
  164. }
  165. .my-swipe {
  166. border-radius: 32rpx;
  167. overflow: hidden;
  168. height: 320rpx;
  169. }
  170. .swipe-img {
  171. width: 100%;
  172. height: 320rpx;
  173. }
  174. .notice-section {
  175. padding: 0 32rpx 24rpx;
  176. }
  177. .notice-bar {
  178. display: flex;
  179. align-items: center;
  180. background: #fffbe8;
  181. border-radius: 16rpx;
  182. padding: 12rpx 20rpx;
  183. gap: 12rpx;
  184. height: 64rpx;
  185. overflow: hidden;
  186. }
  187. .notice-scroll {
  188. flex: 1;
  189. white-space: nowrap;
  190. }
  191. .notice-text {
  192. font-size: 24rpx;
  193. color: #ed6a0c;
  194. }
  195. .service-grid {
  196. padding: 0 32rpx;
  197. display: flex;
  198. gap: 24rpx;
  199. margin-bottom: 32rpx;
  200. }
  201. .grid-item {
  202. border-radius: 24rpx;
  203. padding: 32rpx;
  204. position: relative;
  205. overflow: hidden;
  206. }
  207. .item-transport-large {
  208. flex: 1.2;
  209. background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  210. height: 360rpx;
  211. }
  212. .grid-right {
  213. flex: 1;
  214. display: flex;
  215. flex-direction: column;
  216. gap: 24rpx;
  217. }
  218. .item-wash-small {
  219. background: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
  220. height: 168rpx;
  221. }
  222. .item-feed-small {
  223. background: linear-gradient(135deg, #fab1a0 0%, #e17055 100%);
  224. height: 168rpx;
  225. }
  226. .grid-title {
  227. display: block;
  228. font-size: 32rpx;
  229. color: #fff;
  230. font-weight: 800;
  231. }
  232. .grid-desc {
  233. display: block;
  234. margin-top: 8rpx;
  235. font-size: 22rpx;
  236. color: rgba(255, 255, 255, 0.9);
  237. }
  238. .sub-text {
  239. display: block;
  240. font-size: 20rpx;
  241. color: rgba(255, 255, 255, 0.8);
  242. margin-top: 4rpx;
  243. }
  244. .large-3d-icon {
  245. position: absolute;
  246. right: -10rpx;
  247. bottom: -10rpx;
  248. width: 260rpx;
  249. height: 260rpx;
  250. }
  251. .small-3d-icon {
  252. position: absolute;
  253. right: -10rpx;
  254. bottom: -10rpx;
  255. width: 150rpx;
  256. height: 150rpx;
  257. }
  258. .section-header {
  259. padding: 50rpx 32rpx 20rpx;
  260. display: flex;
  261. justify-content: space-between;
  262. align-items: center;
  263. }
  264. .section-title {
  265. font-size: 36rpx;
  266. font-weight: bold;
  267. color: #333;
  268. }
  269. .more-link {
  270. display: flex;
  271. align-items: center;
  272. gap: 4rpx;
  273. font-size: 26rpx;
  274. color: #999;
  275. }
  276. .recommend-list {
  277. padding: 20rpx 32rpx 40rpx;
  278. }
  279. .recommend-card {
  280. background: #fff;
  281. border-radius: 24rpx;
  282. padding: 24rpx;
  283. display: flex;
  284. gap: 24rpx;
  285. margin-bottom: 24rpx;
  286. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  287. }
  288. .item-img {
  289. width: 180rpx;
  290. height: 180rpx;
  291. border-radius: 16rpx;
  292. }
  293. .item-info {
  294. flex: 1;
  295. display: flex;
  296. flex-direction: column;
  297. justify-content: space-between;
  298. }
  299. .item-header {
  300. display: flex;
  301. justify-content: space-between;
  302. align-items: center;
  303. }
  304. .item-title {
  305. font-size: 32rpx;
  306. color: #333;
  307. font-weight: bold;
  308. }
  309. .booked {
  310. font-size: 24rpx;
  311. color: #999;
  312. }
  313. .item-desc {
  314. font-size: 26rpx;
  315. color: #666;
  316. margin: 12rpx 0;
  317. }
  318. .item-bottom {
  319. display: flex;
  320. align-items: center;
  321. }
  322. .tag {
  323. background-color: #e3f2fd;
  324. color: #2196f3;
  325. font-size: 22rpx;
  326. padding: 6rpx 16rpx;
  327. border-radius: 8rpx;
  328. }
  329. </style>