expert.vue 9.0 KB

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