index.vue 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="all-services-page">
  3. <!-- 顶部搜索栏 -->
  4. <view class="header-search">
  5. <view class="location-box">
  6. <text>昆明市</text>
  7. <uni-icons type="bottom" size="12" color="#333"></uni-icons>
  8. </view>
  9. <view class="search-input-wrap">
  10. <uni-icons type="search" size="14" color="#999"></uni-icons>
  11. <input class="search-input" v-model="searchValue" placeholder="搜索服务内容"
  12. placeholder-class="placeholder-style" />
  13. </view>
  14. </view>
  15. <!-- 主体分类区域 -->
  16. <view class="main-content">
  17. <!-- 左侧侧边栏 -->
  18. <scroll-view scroll-y class="sidebar">
  19. <view v-for="(item, index) in allData" :key="index"
  20. :class="['sidebar-item', { active: activeSidebar === index }]" @click="activeSidebar = index">
  21. <text>{{ item.title }}</text>
  22. </view>
  23. </scroll-view>
  24. <!-- 右侧服务列表 -->
  25. <scroll-view scroll-y class="content-view">
  26. <view class="category-section" v-for="(cat, index) in currentCategories" :key="index">
  27. <text class="cat-section-title">{{ cat.name }}</text>
  28. <view class="service-grid">
  29. <view class="service-cell" v-for="(service, sIndex) in cat.items" :key="sIndex"
  30. @click="onServiceClick(service)">
  31. <view class="icon-wrapper">
  32. <image :src="service.icon" class="service-icon" mode="aspectFit"></image>
  33. </view>
  34. <text class="service-name">{{ service.name }}</text>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 底部客服提示 -->
  39. <view class="contact-footer">
  40. <image src="https://img.icons8.com/?size=100&id=108639&format=png" class="kf-avatar"
  41. mode="aspectFit"></image>
  42. <text class="footer-msg">没有找到想要的服务?可以联系客服哟~</text>
  43. <button size="mini" class="kf-btn">联系客服 ></button>
  44. </view>
  45. </scroll-view>
  46. </view>
  47. <custom-tabbar></custom-tabbar>
  48. </view>
  49. </template>
  50. <script setup>
  51. import { ref, computed } from 'vue'
  52. import customTabbar from '@/components/custom-tabbar/index.vue'
  53. import servicesMockData from '@/mock/services.json'
  54. const searchValue = ref('')
  55. const activeSidebar = ref(0)
  56. const allData = servicesMockData
  57. const currentCategories = computed(() => allData[activeSidebar.value].categories)
  58. const onServiceClick = (service) => {
  59. if (service.type) {
  60. uni.navigateTo({ url: `/pages/service/detail/index?service=${service.type}` })
  61. } else {
  62. uni.showToast({ title: service.name + ' 功能即将上线', icon: 'none' })
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .all-services-page { height: 100vh; display: flex; flex-direction: column; background-color: #fff; }
  68. .header-search { display: flex; align-items: center; padding: 16rpx 32rpx; background-color: #fff; border-bottom: 1rpx solid #f2f2f2; }
  69. .location-box { display: flex; align-items: center; gap: 8rpx; font-size: 28rpx; color: #333; margin-right: 24rpx; }
  70. .search-input-wrap { flex: 1; display: flex; align-items: center; background: #f5f5f5; border-radius: 32rpx; padding: 12rpx 20rpx; gap: 12rpx; }
  71. .search-input { flex: 1; font-size: 26rpx; }
  72. .placeholder-style { color: #999; font-size: 26rpx; }
  73. .main-content { flex: 1; display: flex; overflow: hidden; }
  74. .sidebar { width: 200rpx; background-color: #f7f8fa; }
  75. .sidebar-item { padding: 28rpx 0; text-align: center; font-size: 26rpx; color: #666; position: relative; }
  76. .sidebar-item.active { background-color: #fff; color: #333; font-weight: bold; }
  77. .sidebar-item.active::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 6rpx; height: 40rpx; background-color: #f7ca3e; border-radius: 0 6rpx 6rpx 0; }
  78. .content-view { flex: 1; padding: 32rpx; }
  79. .category-section { margin-bottom: 48rpx; }
  80. .cat-section-title { font-size: 28rpx; font-weight: bold; color: #333; display: block; margin-bottom: 24rpx; background-color: #f9f9f9; padding: 8rpx 20rpx; border-radius: 8rpx; }
  81. .service-grid { display: flex; flex-wrap: wrap; }
  82. .service-cell { width: 33.33%; display: flex; flex-direction: column; align-items: center; margin-bottom: 32rpx; }
  83. .icon-wrapper { width: 96rpx; height: 96rpx; background-color: #fff; border-radius: 24rpx; display: flex; align-items: center; justify-content: center; box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04); margin-bottom: 16rpx; }
  84. .service-icon { width: 56rpx; height: 56rpx; }
  85. .service-name { font-size: 24rpx; color: #666; text-align: center; }
  86. .contact-footer { margin-top: 40rpx; background-color: #f0f7ff; border-radius: 24rpx; padding: 32rpx; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 20rpx; }
  87. .kf-avatar { width: 80rpx; height: 80rpx; }
  88. .footer-msg { font-size: 26rpx; color: #333; }
  89. .kf-btn { font-size: 24rpx; color: #1989fa; background: transparent; border: 1rpx solid #1989fa; border-radius: 28rpx; padding: 8rpx 32rpx; line-height: 1.5; }
  90. </style>