index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="all-services-page">
  3. <nav-bar title="全部分类" :showBack="false"></nav-bar>
  4. <!-- 顶部搜索栏 -->
  5. <view class="header-search">
  6. <view class="location-box">
  7. <text>昆明市</text>
  8. <uni-icons type="bottom" size="12" color="#333"></uni-icons>
  9. </view>
  10. <view class="search-input-wrap">
  11. <uni-icons type="search" size="14" color="#999"></uni-icons>
  12. <input class="search-input" v-model="searchValue" placeholder="搜索服务内容"
  13. placeholder-class="placeholder-style" />
  14. </view>
  15. </view>
  16. <!-- 主体分类区域 -->
  17. <view class="main-content">
  18. <!-- 左侧侧边栏 -->
  19. <scroll-view scroll-y class="sidebar">
  20. <view v-for="(item, index) in allData" :key="index"
  21. :class="['sidebar-item', { active: activeSidebar === index }]" @click="activeSidebar = index">
  22. <text>{{ item.title }}</text>
  23. </view>
  24. </scroll-view>
  25. <!-- 右侧服务列表 -->
  26. <scroll-view scroll-y class="content-view">
  27. <view class="category-section" v-for="(cat, index) in currentCategories" :key="index">
  28. <text class="cat-section-title">{{ cat.name }}</text>
  29. <view class="service-grid">
  30. <view class="service-cell" v-for="(service, sIndex) in cat.items" :key="sIndex"
  31. @click="onServiceClick(service)">
  32. <view class="icon-wrapper">
  33. <image :src="service.icon" class="service-icon" mode="aspectFit"></image>
  34. </view>
  35. <text class="service-name">{{ service.name }}</text>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- 底部客服提示 -->
  40. <view class="contact-footer">
  41. <image src="https://img.icons8.com/?size=100&id=108639&format=png" class="kf-avatar"
  42. mode="aspectFit"></image>
  43. <text class="footer-msg">没有找到想要的服务?可以联系客服哟~</text>
  44. <button size="mini" class="kf-btn">联系客服 ></button>
  45. </view>
  46. </scroll-view>
  47. </view>
  48. <custom-tabbar></custom-tabbar>
  49. </view>
  50. </template>
  51. <script setup>
  52. import { ref, computed } from 'vue'
  53. import navBar from '@/components/nav-bar/index.vue'
  54. import customTabbar from '@/components/custom-tabbar/index.vue'
  55. import servicesMockData from '@/mock/services.json'
  56. const searchValue = ref('')
  57. const activeSidebar = ref(0)
  58. const allData = servicesMockData
  59. const currentCategories = computed(() => allData[activeSidebar.value].categories)
  60. const onServiceClick = (service) => {
  61. if (service.type) {
  62. uni.navigateTo({ url: `/pages/service/detail/index?service=${service.type}` })
  63. } else {
  64. uni.showToast({ title: service.name + ' 功能即将上线', icon: 'none' })
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .all-services-page {
  70. height: 100vh;
  71. display: flex;
  72. flex-direction: column;
  73. background-color: #fff;
  74. }
  75. .header-search {
  76. display: flex;
  77. align-items: center;
  78. padding: 16rpx 32rpx;
  79. background-color: #fff;
  80. border-bottom: 1rpx solid #f2f2f2;
  81. }
  82. .location-box {
  83. display: flex;
  84. align-items: center;
  85. gap: 8rpx;
  86. font-size: 28rpx;
  87. color: #333;
  88. margin-right: 24rpx;
  89. }
  90. .search-input-wrap {
  91. flex: 1;
  92. display: flex;
  93. align-items: center;
  94. background: #f5f5f5;
  95. border-radius: 32rpx;
  96. padding: 12rpx 20rpx;
  97. gap: 12rpx;
  98. }
  99. .search-input {
  100. flex: 1;
  101. font-size: 26rpx;
  102. }
  103. .placeholder-style {
  104. color: #999;
  105. font-size: 26rpx;
  106. }
  107. .main-content {
  108. flex: 1;
  109. display: flex;
  110. overflow: hidden;
  111. }
  112. .sidebar {
  113. width: 200rpx;
  114. background-color: #f7f8fa;
  115. }
  116. .sidebar-item {
  117. padding: 28rpx 0;
  118. text-align: center;
  119. font-size: 26rpx;
  120. color: #666;
  121. position: relative;
  122. }
  123. .sidebar-item.active {
  124. background-color: #fff;
  125. color: #333;
  126. font-weight: bold;
  127. }
  128. .sidebar-item.active::before {
  129. content: '';
  130. position: absolute;
  131. left: 0;
  132. top: 50%;
  133. transform: translateY(-50%);
  134. width: 6rpx;
  135. height: 40rpx;
  136. background-color: #f7ca3e;
  137. border-radius: 0 6rpx 6rpx 0;
  138. }
  139. .content-view {
  140. flex: 1;
  141. padding: 32rpx;
  142. }
  143. .category-section {
  144. margin-bottom: 48rpx;
  145. }
  146. .cat-section-title {
  147. font-size: 28rpx;
  148. font-weight: bold;
  149. color: #333;
  150. display: block;
  151. margin-bottom: 24rpx;
  152. background-color: #f9f9f9;
  153. padding: 8rpx 20rpx;
  154. border-radius: 8rpx;
  155. }
  156. .service-grid {
  157. display: flex;
  158. flex-wrap: wrap;
  159. }
  160. .service-cell {
  161. width: 33.33%;
  162. display: flex;
  163. flex-direction: column;
  164. align-items: center;
  165. margin-bottom: 32rpx;
  166. }
  167. .icon-wrapper {
  168. width: 96rpx;
  169. height: 96rpx;
  170. background-color: #fff;
  171. border-radius: 24rpx;
  172. display: flex;
  173. align-items: center;
  174. justify-content: center;
  175. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  176. margin-bottom: 16rpx;
  177. }
  178. .service-icon {
  179. width: 56rpx;
  180. height: 56rpx;
  181. }
  182. .service-name {
  183. font-size: 24rpx;
  184. color: #666;
  185. text-align: center;
  186. }
  187. .contact-footer {
  188. margin-top: 40rpx;
  189. background-color: #f0f7ff;
  190. border-radius: 24rpx;
  191. padding: 32rpx;
  192. display: flex;
  193. flex-direction: column;
  194. align-items: center;
  195. text-align: center;
  196. gap: 20rpx;
  197. }
  198. .kf-avatar {
  199. width: 80rpx;
  200. height: 80rpx;
  201. }
  202. .footer-msg {
  203. font-size: 26rpx;
  204. color: #333;
  205. }
  206. .kf-btn {
  207. font-size: 24rpx;
  208. color: #1989fa;
  209. background: transparent;
  210. border: 1rpx solid #1989fa;
  211. border-radius: 28rpx;
  212. padding: 8rpx 32rpx;
  213. line-height: 1.5;
  214. }
  215. </style>