expert.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <view class="expert-container">
  3. <!-- 分类筛选区域 -->
  4. <view class="category-section">
  5. <scroll-view class="category-scroll" scroll-x show-scrollbar="false">
  6. <view class="category-list">
  7. <view
  8. class="category-item"
  9. :class="{ active: selectedCategory === item.value }"
  10. v-for="item in categoryList"
  11. :key="item.value"
  12. @click="selectCategory(item.value)"
  13. >
  14. <text class="category-text">{{ item.label }}</text>
  15. </view>
  16. </view>
  17. </scroll-view>
  18. </view>
  19. <!-- 搜索区域 -->
  20. <view class="search-section">
  21. <view class="search-box">
  22. <image class="search-icon" src="/static/icons/search.png" mode="aspectFit"></image>
  23. <input
  24. class="search-input"
  25. placeholder="搜索专家姓名或擅长方向"
  26. placeholder-style="color: #999;"
  27. v-model="searchKeyword"
  28. @confirm="handleSearch"
  29. />
  30. </view>
  31. </view>
  32. <!-- 专家列表 -->
  33. <view class="expert-list-container">
  34. <view class="expert-list">
  35. <view
  36. class="expert-card"
  37. v-for="expert in filteredExpertList"
  38. :key="expert.id"
  39. @click="navigateToDetail(expert)"
  40. >
  41. <view class="expert-info">
  42. <!-- 左侧头像和基本信息 -->
  43. <view class="expert-basic">
  44. <view class="avatar-container">
  45. <image class="expert-avatar" :src="expert.avatar" mode="aspectFill"></image>
  46. <view class="online-status" v-if="expert.isOnline"></view>
  47. </view>
  48. <view class="expert-details">
  49. <view class="expert-name">{{ expert.name }}</view>
  50. <view class="expert-title">{{ expert.title }}</view>
  51. <view class="expert-unit">{{ expert.unit }}</view>
  52. </view>
  53. </view>
  54. <!-- 右侧擅长领域和咨询按钮 -->
  55. <view class="expert-actions">
  56. <view class="expertise-tags">
  57. <view
  58. class="expertise-tag"
  59. v-for="(tag, index) in expert.expertise.slice(0, 3)"
  60. :key="index"
  61. >
  62. {{ tag }}
  63. </view>
  64. </view>
  65. <view class="consult-btn" @click.stop="startConsult(expert)">
  66. <text class="consult-text">咨询</text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script setup>
  76. import { ref, computed } from 'vue'
  77. const selectedCategory = ref('all')
  78. const searchKeyword = ref('')
  79. // 分类选项
  80. const categoryList = [
  81. { label: '全部', value: 'all' },
  82. { label: '种植技术', value: 'planting' },
  83. { label: '植物保护', value: 'protection' },
  84. { label: '土壤肥料', value: 'soil' },
  85. { label: '气象指导', value: 'weather' },
  86. { label: '病虫害防治', value: 'pest' },
  87. { label: '农机使用', value: 'machinery' }
  88. ]
  89. // 专家列表数据
  90. const expertList = ref([
  91. {
  92. id: 1,
  93. name: '张教授',
  94. title: '研究员',
  95. unit: '农业科学院',
  96. avatar: '/static/icons/professor.png',
  97. expertise: ['水稻种植', '病虫害防治', '土壤改良'],
  98. category: 'planting',
  99. isOnline: true,
  100. rating: 4.9,
  101. consultCount: 156
  102. },
  103. {
  104. id: 2,
  105. name: '李专家',
  106. title: '高级农艺师',
  107. unit: '植保站',
  108. avatar: '/static/icons/professor.png',
  109. expertise: ['植物保护', '农药使用', '生物防治'],
  110. category: 'protection',
  111. isOnline: false,
  112. rating: 4.8,
  113. consultCount: 203
  114. },
  115. {
  116. id: 3,
  117. name: '王老师',
  118. title: '副教授',
  119. unit: '农业大学',
  120. avatar: '/static/icons/professor.png',
  121. expertise: ['土壤检测', '施肥技术', '营养诊断'],
  122. category: 'soil',
  123. isOnline: true,
  124. rating: 4.7,
  125. consultCount: 89
  126. },
  127. {
  128. id: 4,
  129. name: '陈工程师',
  130. title: '农机专家',
  131. unit: '农机推广站',
  132. avatar: '/static/icons/professor.png',
  133. expertise: ['农机维修', '设备选型', '机械化作业'],
  134. category: 'machinery',
  135. isOnline: true,
  136. rating: 4.6,
  137. consultCount: 134
  138. },
  139. {
  140. id: 5,
  141. name: '刘博士',
  142. title: '气象专家',
  143. unit: '气象局',
  144. avatar: '/static/icons/professor.png',
  145. expertise: ['天气预报', '灾害预警', '农业气象'],
  146. category: 'weather',
  147. isOnline: false,
  148. rating: 4.8,
  149. consultCount: 178
  150. }
  151. ])
  152. const filteredExpertList = computed(() => {
  153. let list = expertList.value
  154. // 按分类筛选
  155. if (selectedCategory.value !== 'all') {
  156. list = list.filter(expert => expert.category === selectedCategory.value)
  157. }
  158. // 按搜索关键词筛选
  159. if (searchKeyword.value.trim()) {
  160. const keyword = searchKeyword.value.trim().toLowerCase()
  161. list = list.filter(expert =>
  162. expert.name.toLowerCase().includes(keyword) ||
  163. expert.expertise.some(tag => tag.toLowerCase().includes(keyword)) ||
  164. expert.title.toLowerCase().includes(keyword) ||
  165. expert.unit.toLowerCase().includes(keyword)
  166. )
  167. }
  168. return list
  169. })
  170. // 选择分类
  171. const selectCategory = (category) => {
  172. selectedCategory.value = category
  173. }
  174. // 搜索处理
  175. const handleSearch = () => {
  176. // 搜索逻辑已在computed中处理
  177. }
  178. // 导航到专家详情页
  179. const navigateToDetail = (expert) => {
  180. uni.navigateTo({
  181. url: `/pages/service/expert-detail?id=${expert.id}&name=${encodeURIComponent(expert.name)}`
  182. })
  183. }
  184. // 开始咨询
  185. const startConsult = (expert) => {
  186. uni.navigateTo({
  187. url: `/pages/service/expert-chat?expertId=${expert.id}&expertName=${encodeURIComponent(expert.name)}`
  188. })
  189. }
  190. </script>
  191. <style lang="scss">
  192. .expert-container {
  193. min-height: 100vh;
  194. background-color: #f5f5f5;
  195. }
  196. // 分类筛选区域
  197. .category-section {
  198. background-color: #fff;
  199. border-bottom: 1rpx solid #f0f0f0;
  200. }
  201. .category-scroll {
  202. white-space: nowrap;
  203. }
  204. .category-list {
  205. display: inline-flex;
  206. padding: 0 20rpx;
  207. }
  208. .category-item {
  209. flex-shrink: 0;
  210. padding: 24rpx 32rpx;
  211. margin-right: 8rpx;
  212. font-size: 28rpx;
  213. color: #666;
  214. border-radius: 32rpx;
  215. transition: all 0.2s ease;
  216. &.active {
  217. color: #4CAF50;
  218. background-color: #f0fdf4;
  219. font-weight: bold;
  220. }
  221. }
  222. // 搜索区域
  223. .search-section {
  224. background-color: #fff;
  225. padding: 20rpx;
  226. border-bottom: 1rpx solid #f0f0f0;
  227. }
  228. .search-box {
  229. display: flex;
  230. align-items: center;
  231. background-color: #f8f8f8;
  232. border-radius: 32rpx;
  233. padding: 16rpx 24rpx;
  234. }
  235. .search-icon {
  236. width: 32rpx;
  237. height: 32rpx;
  238. margin-right: 16rpx;
  239. }
  240. .search-input {
  241. flex: 1;
  242. font-size: 28rpx;
  243. line-height: 1.5;
  244. }
  245. // 专家列表
  246. .expert-list-container {
  247. padding: 20rpx;
  248. }
  249. .expert-list {
  250. display: flex;
  251. flex-direction: column;
  252. gap: 16rpx;
  253. }
  254. .expert-card {
  255. background-color: #fff;
  256. border-radius: 16rpx;
  257. padding: 24rpx;
  258. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  259. transition: transform 0.2s ease;
  260. &:active {
  261. transform: scale(0.98);
  262. }
  263. }
  264. .expert-info {
  265. display: flex;
  266. justify-content: space-between;
  267. align-items: flex-start;
  268. }
  269. // 左侧基本信息
  270. .expert-basic {
  271. display: flex;
  272. align-items: center;
  273. flex: 1;
  274. margin-right: 20rpx;
  275. }
  276. .avatar-container {
  277. position: relative;
  278. margin-right: 20rpx;
  279. }
  280. .expert-avatar {
  281. width: 100rpx;
  282. height: 100rpx;
  283. border-radius: 50rpx;
  284. border: 3rpx solid #f0f0f0;
  285. }
  286. .online-status {
  287. position: absolute;
  288. bottom: 0;
  289. right: 0;
  290. width: 24rpx;
  291. height: 24rpx;
  292. background-color: #52c41a;
  293. border-radius: 12rpx;
  294. border: 3rpx solid #fff;
  295. }
  296. .expert-details {
  297. flex: 1;
  298. }
  299. .expert-name {
  300. font-size: 32rpx;
  301. font-weight: bold;
  302. color: #333;
  303. margin-bottom: 8rpx;
  304. }
  305. .expert-title {
  306. font-size: 26rpx;
  307. color: #4CAF50;
  308. margin-bottom: 4rpx;
  309. }
  310. .expert-unit {
  311. font-size: 24rpx;
  312. color: #999;
  313. }
  314. // 右侧操作区域
  315. .expert-actions {
  316. display: flex;
  317. flex-direction: column;
  318. align-items: flex-end;
  319. gap: 16rpx;
  320. }
  321. .expertise-tags {
  322. display: flex;
  323. flex-wrap: wrap;
  324. gap: 8rpx;
  325. justify-content: flex-end;
  326. }
  327. .expertise-tag {
  328. padding: 6rpx 12rpx;
  329. background-color: #e6f7ff;
  330. color: #1890ff;
  331. font-size: 22rpx;
  332. border-radius: 12rpx;
  333. white-space: nowrap;
  334. }
  335. .consult-btn {
  336. padding: 12rpx 24rpx;
  337. background-color: #4CAF50;
  338. border-radius: 20rpx;
  339. transition: background-color 0.2s ease;
  340. &:active {
  341. background-color: #45a049;
  342. }
  343. }
  344. .consult-text {
  345. font-size: 26rpx;
  346. color: #fff;
  347. font-weight: bold;
  348. }
  349. </style>