knowledgeList.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="sub-page">
  3. <TopBar title="行业知识" show-back />
  4. <view class="px-4 pt-3">
  5. <!-- 搜索栏:默认白底灰边 -->
  6. <view class="search-bar mb-3">
  7. <text class="uni-icons uniui-search search-icon"></text>
  8. <input
  9. v-model="searchText"
  10. class="search-input"
  11. placeholder="搜索知识标题或关键词"
  12. />
  13. </view>
  14. <!-- 分类筛选 -->
  15. <view class="filter-bar mb-3">
  16. <view
  17. v-for="cat in categories"
  18. :key="cat.value"
  19. class="filter-chip"
  20. :class="{ 'filter-chip-active': currentCategory === cat.value }"
  21. @click="currentCategory = cat.value"
  22. >
  23. {{ cat.label }}
  24. </view>
  25. </view>
  26. <view v-if="loading" class="py-10 text-center">
  27. <text class="empty-text">加载中...</text>
  28. </view>
  29. <view v-else-if="filteredKnowledges.length === 0">
  30. <EmptyState message="暂无知识内容" />
  31. </view>
  32. <view v-else class="glass-card">
  33. <view
  34. v-for="item in filteredKnowledges"
  35. :key="item.id"
  36. class="notice-row"
  37. hover-class="row-hover"
  38. :hover-start-time="0"
  39. :hover-stay-time="120"
  40. @click="goToDetail(item.id)"
  41. >
  42. <view class="flex items-center justify-between mb-2">
  43. <text class="row-title truncate flex-1 min-w-0 mr-2">{{ item.title }}</text>
  44. <text class="type-tag flex-shrink-0">{{ item.category }}</text>
  45. </view>
  46. <text class="row-sub notice-content">{{ item.summary }}</text>
  47. <view class="flex items-center justify-between mt-2">
  48. <view class="flex items-center">
  49. <text class="uni-icons uniui-calendar-filled meta-icon mr-1"></text>
  50. <text class="row-date">{{ formatDate(item.createTime) }}</text>
  51. </view>
  52. <view class="flex items-center">
  53. <text class="uni-icons uniui-eye-filled meta-icon mr-1"></text>
  54. <text class="row-date">{{ item.viewCount }}</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script setup lang="ts">
  63. import { ref, computed, onMounted } from 'vue'
  64. import TopBar from '../../components/common/TopBar.vue'
  65. import EmptyState from '../../components/common/EmptyState.vue'
  66. import { formatDate } from '../../utils'
  67. const loading = ref(false)
  68. const searchText = ref('')
  69. const currentCategory = ref('all')
  70. const categories = [
  71. { value: 'all', label: '全部' },
  72. { value: 'operation', label: '操作规范' },
  73. { value: 'safety', label: '安全知识' },
  74. { value: 'equipment', label: '设备维护' },
  75. { value: 'technology', label: '技术文档' },
  76. ]
  77. const knowledges = ref([
  78. { id: '1', title: '化粪池清掏操作规范', category: '操作规范', summary: '详细介绍了化粪池清掏的标准操作流程、安全注意事项及应急处理方案...', createTime: '2026-06-20', viewCount: 128 },
  79. { id: '2', title: '管道疏通技术要点', category: '技术文档', summary: '管道疏通的常用方法、设备选型及常见问题解决方案...', createTime: '2026-06-18', viewCount: 95 },
  80. { id: '3', title: '施工现场安全守则', category: '安全知识', summary: '施工现场的安全防护要求、危险源识别及个人防护措施...', createTime: '2026-06-15', viewCount: 210 },
  81. { id: '4', title: '高压清洗车维护指南', category: '设备维护', summary: '高压清洗车的日常保养、常见故障排查及维修方法...', createTime: '2026-06-10', viewCount: 76 },
  82. ])
  83. const filteredKnowledges = computed(() => {
  84. let result = knowledges.value
  85. if (currentCategory.value !== 'all') {
  86. result = result.filter(k => k.category === categories.find(c => c.value === currentCategory.value)?.label)
  87. }
  88. if (searchText.value) {
  89. const keyword = searchText.value.toLowerCase()
  90. result = result.filter(k => k.title.toLowerCase().includes(keyword) || k.summary.toLowerCase().includes(keyword))
  91. }
  92. return result
  93. })
  94. function goToDetail(id: string) {
  95. uni.navigateTo({ url: `/subPackages/pages-sales/knowledgeDetail?id=${id}` })
  96. }
  97. onMounted(() => {
  98. loading.value = false
  99. })
  100. </script>
  101. <style scoped>
  102. .sub-page {
  103. max-width: 430px;
  104. margin: 0 auto;
  105. min-height: 100vh;
  106. background-color: #f6fbf9;
  107. padding-bottom: 24px;
  108. }
  109. .search-bar {
  110. display: flex;
  111. align-items: center;
  112. padding: 0 12px;
  113. height: 40px;
  114. border-radius: 999px;
  115. background-color: #ffffff;
  116. border: 1px solid #e5e7eb;
  117. }
  118. .search-icon {
  119. font-size: 16px;
  120. color: #9ca3af;
  121. margin-right: 8px;
  122. }
  123. .search-input {
  124. flex: 1;
  125. font-size: 14px;
  126. color: #1f2937;
  127. }
  128. /* 筛选条:默认白底灰边,激活态绿色 */
  129. .filter-bar {
  130. display: flex;
  131. gap: 8px;
  132. overflow-x: auto;
  133. }
  134. .filter-chip {
  135. padding: 6px 16px;
  136. border-radius: 999px;
  137. font-size: 13px;
  138. color: #6b7280;
  139. background-color: #ffffff;
  140. border: 1px solid #e5e7eb;
  141. flex-shrink: 0;
  142. }
  143. .filter-chip-active {
  144. color: #ffffff;
  145. font-weight: 600;
  146. background: linear-gradient(135deg, #368f6f 0%, #4ba98a 100%);
  147. border-color: transparent;
  148. }
  149. .glass-card {
  150. background-color: rgba(255, 255, 255, 0.85);
  151. backdrop-filter: blur(14px);
  152. -webkit-backdrop-filter: blur(14px);
  153. border: 1px solid rgba(164, 216, 152, 0.35);
  154. border-radius: 24px;
  155. box-shadow: 0 18px 50px -12px rgba(54, 143, 111, 0.28);
  156. overflow: hidden;
  157. margin-bottom: 12px;
  158. }
  159. .notice-row {
  160. padding: 14px 16px;
  161. border-top: 1px solid rgba(164, 216, 152, 0.18);
  162. }
  163. .notice-row:first-child {
  164. border-top: none;
  165. }
  166. .row-hover {
  167. background-color: rgba(164, 216, 152, 0.1);
  168. }
  169. .row-title {
  170. font-size: 14px;
  171. font-weight: 600;
  172. color: #1f2937;
  173. }
  174. .row-sub {
  175. font-size: 12px;
  176. color: #9ca3af;
  177. }
  178. .notice-content {
  179. display: -webkit-box;
  180. -webkit-line-clamp: 2;
  181. -webkit-box-orient: vertical;
  182. overflow: hidden;
  183. }
  184. .row-date {
  185. font-size: 12px;
  186. color: #9ca3af;
  187. }
  188. .meta-icon {
  189. font-size: 12px;
  190. color: #9ca3af;
  191. }
  192. .type-tag {
  193. padding: 2px 10px;
  194. border-radius: 999px;
  195. font-size: 11px;
  196. font-weight: 600;
  197. color: #368f6f;
  198. background-color: rgba(164, 216, 152, 0.24);
  199. }
  200. .empty-text {
  201. font-size: 13px;
  202. color: #9ca3af;
  203. }
  204. </style>