index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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" :key="index" @click="goToDetail(item.name)">
  70. <image :src="item.iconUrl" class="item-img" mode="aspectFill"></image>
  71. <view class="item-info">
  72. <view class="item-header">
  73. <text class="item-title">{{ item.name }}</text>
  74. </view>
  75. <text class="item-desc">{{ item.remark }}</text>
  76. <view class="item-bottom">
  77. <text class="tag" v-if="serviceModeEnum[item.mode]">{{ serviceModeEnum[item.mode] }}</text>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <custom-tabbar></custom-tabbar>
  83. </view>
  84. </template>
  85. <script setup>
  86. import { ref } from 'vue'
  87. import { onShow } from '@dcloudio/uni-app'
  88. import customTabbar from '@/components/custom-tabbar/index.vue'
  89. import mockData from '@/mock/index.json'
  90. import { listAll } from '@/api/service/list'
  91. import serviceModeEnum from '@/json/serviceMode.json'
  92. const bannerImages = mockData.bannerImages
  93. const services = ref([])
  94. const fetchServices = async () => {
  95. try {
  96. const res = await listAll()
  97. services.value = res || []
  98. } catch (error) {
  99. console.error("Failed to fetch services", error)
  100. }
  101. }
  102. onShow(() => {
  103. fetchServices()
  104. })
  105. const onLocationClick = () => {
  106. uni.showToast({ title: '城市选择功能即将上线', icon: 'none' })
  107. }
  108. const onSearchClick = () => {
  109. // 跳转搜索页(预留)
  110. }
  111. const goToServices = () => {
  112. uni.reLaunch({ url: '/pages/service/all/index' })
  113. }
  114. const goToDetail = (type) => {
  115. if (type === '托运') {
  116. uni.reLaunch({ url: '/pages/service/all/index' })
  117. return
  118. }
  119. uni.navigateTo({
  120. url: `/pages/service/detail/index?service=${type}`
  121. })
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .home-page {
  126. background-image: linear-gradient(to bottom, #FFD93D 0%, #FFD93D 440rpx, #f2f2f2 440rpx, #f2f2f2 100%);
  127. min-height: 100vh;
  128. padding-bottom: 120rpx;
  129. }
  130. .search-wrapper {
  131. padding: 24rpx 32rpx;
  132. padding-top: calc(var(--status-bar-height, 44px) + 20rpx);
  133. display: flex;
  134. align-items: center;
  135. gap: 16rpx;
  136. }
  137. .location-box {
  138. display: flex;
  139. align-items: center;
  140. gap: 6rpx;
  141. flex-shrink: 0;
  142. }
  143. .location-text {
  144. font-size: 28rpx;
  145. color: #fff;
  146. font-weight: bold;
  147. }
  148. .search-bar {
  149. flex: 1;
  150. display: flex;
  151. align-items: center;
  152. background: rgba(255, 255, 255, 0.85);
  153. border-radius: 40rpx;
  154. padding: 16rpx 24rpx;
  155. gap: 12rpx;
  156. }
  157. .search-placeholder {
  158. font-size: 26rpx;
  159. color: #999;
  160. }
  161. .banner-swipe-wrapper {
  162. padding: 0 32rpx 24rpx;
  163. }
  164. .my-swipe {
  165. border-radius: 32rpx;
  166. overflow: hidden;
  167. height: 320rpx;
  168. }
  169. .swipe-img {
  170. width: 100%;
  171. height: 320rpx;
  172. }
  173. .notice-section {
  174. padding: 0 32rpx 24rpx;
  175. }
  176. .notice-bar {
  177. display: flex;
  178. align-items: center;
  179. background: #fffbe8;
  180. border-radius: 16rpx;
  181. padding: 12rpx 20rpx;
  182. gap: 12rpx;
  183. height: 64rpx;
  184. overflow: hidden;
  185. }
  186. .notice-scroll {
  187. flex: 1;
  188. white-space: nowrap;
  189. }
  190. .notice-text {
  191. font-size: 24rpx;
  192. color: #ed6a0c;
  193. }
  194. .service-grid {
  195. padding: 0 32rpx;
  196. display: flex;
  197. gap: 24rpx;
  198. margin-bottom: 32rpx;
  199. }
  200. .grid-item {
  201. border-radius: 24rpx;
  202. padding: 32rpx;
  203. position: relative;
  204. overflow: hidden;
  205. }
  206. .item-transport-large {
  207. flex: 1.2;
  208. background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  209. height: 360rpx;
  210. }
  211. .grid-right {
  212. flex: 1;
  213. display: flex;
  214. flex-direction: column;
  215. gap: 24rpx;
  216. }
  217. .item-wash-small {
  218. background: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
  219. height: 168rpx;
  220. }
  221. .item-feed-small {
  222. background: linear-gradient(135deg, #fab1a0 0%, #e17055 100%);
  223. height: 168rpx;
  224. }
  225. .grid-title {
  226. display: block;
  227. font-size: 32rpx;
  228. color: #fff;
  229. font-weight: 800;
  230. }
  231. .grid-desc {
  232. display: block;
  233. margin-top: 8rpx;
  234. font-size: 22rpx;
  235. color: rgba(255, 255, 255, 0.9);
  236. }
  237. .sub-text {
  238. display: block;
  239. font-size: 20rpx;
  240. color: rgba(255, 255, 255, 0.8);
  241. margin-top: 4rpx;
  242. }
  243. .large-3d-icon {
  244. position: absolute;
  245. right: -10rpx;
  246. bottom: -10rpx;
  247. width: 260rpx;
  248. height: 260rpx;
  249. }
  250. .small-3d-icon {
  251. position: absolute;
  252. right: -10rpx;
  253. bottom: -10rpx;
  254. width: 150rpx;
  255. height: 150rpx;
  256. }
  257. .section-header {
  258. padding: 50rpx 32rpx 20rpx;
  259. display: flex;
  260. justify-content: space-between;
  261. align-items: center;
  262. }
  263. .section-title {
  264. font-size: 36rpx;
  265. font-weight: bold;
  266. color: #333;
  267. }
  268. .more-link {
  269. display: flex;
  270. align-items: center;
  271. gap: 4rpx;
  272. font-size: 26rpx;
  273. color: #999;
  274. }
  275. .recommend-list {
  276. padding: 20rpx 32rpx 40rpx;
  277. }
  278. .recommend-card {
  279. background: #fff;
  280. border-radius: 24rpx;
  281. padding: 24rpx;
  282. display: flex;
  283. gap: 24rpx;
  284. margin-bottom: 24rpx;
  285. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  286. }
  287. .item-img {
  288. width: 180rpx;
  289. height: 180rpx;
  290. border-radius: 16rpx;
  291. }
  292. .item-info {
  293. flex: 1;
  294. display: flex;
  295. flex-direction: column;
  296. justify-content: space-between;
  297. }
  298. .item-header {
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. }
  303. .item-title {
  304. font-size: 32rpx;
  305. color: #333;
  306. font-weight: bold;
  307. }
  308. .booked {
  309. font-size: 24rpx;
  310. color: #999;
  311. }
  312. .item-desc {
  313. font-size: 26rpx;
  314. color: #666;
  315. margin: 12rpx 0;
  316. }
  317. .item-bottom {
  318. display: flex;
  319. align-items: center;
  320. }
  321. .tag {
  322. background-color: #e3f2fd;
  323. color: #2196f3;
  324. font-size: 22rpx;
  325. padding: 6rpx 16rpx;
  326. border-radius: 8rpx;
  327. }
  328. </style>