expert-detail.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view class="expert-detail-container">
  3. <!-- 专家基本信息卡片 -->
  4. <view class="expert-info-card">
  5. <view class="expert-header">
  6. <view class="avatar-section">
  7. <view class="avatar-container">
  8. <image class="expert-avatar" :src="expertInfo.avatar" mode="aspectFill"></image>
  9. <view class="online-status" v-if="expertInfo.isOnline"></view>
  10. </view>
  11. </view>
  12. <view class="basic-info">
  13. <view class="expert-name">{{ expertInfo.name }}</view>
  14. <view class="expert-title">{{ expertInfo.title }}</view>
  15. <view class="expert-unit">{{ expertInfo.unit }}</view>
  16. <view class="stats-row">
  17. <view class="stat-item">
  18. <text class="stat-number">{{ expertInfo.rating }}</text>
  19. <text class="stat-label">评分</text>
  20. </view>
  21. <view class="stat-item">
  22. <text class="stat-number">{{ expertInfo.consultCount }}</text>
  23. <text class="stat-label">咨询数</text>
  24. </view>
  25. <view class="stat-item">
  26. <text class="stat-number">{{ expertInfo.experience }}</text>
  27. <text class="stat-label">从业年限</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 擅长领域 -->
  34. <view class="expertise-card">
  35. <view class="card-title">
  36. <text>擅长领域</text>
  37. </view>
  38. <view class="expertise-tags">
  39. <view
  40. class="expertise-tag"
  41. v-for="(tag, index) in expertInfo.expertise"
  42. :key="index"
  43. >
  44. {{ tag }}
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 专家简介 -->
  49. <view class="introduction-card">
  50. <view class="card-title">
  51. <text>专家简介</text>
  52. </view>
  53. <view class="introduction-content">
  54. <text class="introduction-text">{{ expertInfo.introduction }}</text>
  55. </view>
  56. </view>
  57. <!-- 服务时间 -->
  58. <view class="service-time-card">
  59. <view class="card-title">
  60. <text>服务时间</text>
  61. </view>
  62. <view class="service-time-content">
  63. <view class="time-item">
  64. <text class="time-label">工作日:</text>
  65. <text class="time-value">{{ expertInfo.serviceTime.weekday }}</text>
  66. </view>
  67. <view class="time-item">
  68. <text class="time-label">周末:</text>
  69. <text class="time-value">{{ expertInfo.serviceTime.weekend }}</text>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 底部咨询按钮 -->
  74. <view class="bottom-action-bar">
  75. <view class="action-btn" @click="startConsult">
  76. <text class="btn-text">在线咨询</text>
  77. </view>
  78. </view>
  79. </view>
  80. </template>
  81. <script setup>
  82. import { ref, onMounted } from 'vue'
  83. const expertId = ref('')
  84. const expertInfo = ref({
  85. id: '',
  86. name: '',
  87. title: '',
  88. unit: '',
  89. avatar: '',
  90. expertise: [],
  91. introduction: '',
  92. isOnline: false,
  93. rating: 0,
  94. consultCount: 0,
  95. experience: 0,
  96. serviceTime: {
  97. weekday: '',
  98. weekend: ''
  99. }
  100. })
  101. // 页面加载
  102. onMounted(() => {
  103. const pages = getCurrentPages()
  104. const currentPage = pages[pages.length - 1]
  105. const options = currentPage.options
  106. if (options.id) {
  107. expertId.value = options.id
  108. loadExpertDetail()
  109. }
  110. })
  111. // 加载专家详情
  112. const loadExpertDetail = () => {
  113. uni.showLoading({ title: '加载中...' })
  114. // 模拟API调用,实际应用中需要根据expertId从API获取数据
  115. setTimeout(() => {
  116. const mockData = {
  117. id: expertId.value,
  118. name: '张教授',
  119. title: '研究员',
  120. unit: '农业科学院植物保护研究所',
  121. avatar: '/static/icons/professor.png',
  122. expertise: ['水稻种植', '病虫害防治', '土壤改良', '绿色防控', '有机农业'],
  123. introduction: '农业技术推广研究员,从事农作物病虫害防治和绿色种植技术研究20余年。主持完成国家和省部级科研项目10余项,发表学术论文50多篇,获得农业技术推广奖3项。擅长水稻、小麦等主要粮食作物的病虫害综合防治,在生物防治、绿色防控等方面有丰富的实践经验。',
  124. isOnline: true,
  125. rating: 4.9,
  126. consultCount: 156,
  127. experience: 20,
  128. serviceTime: {
  129. weekday: '09:00-18:00',
  130. weekend: '09:00-17:00'
  131. }
  132. }
  133. expertInfo.value = mockData
  134. // 设置页面标题
  135. uni.setNavigationBarTitle({
  136. title: `${mockData.name} - 专家详情`
  137. })
  138. uni.hideLoading()
  139. }, 1000)
  140. }
  141. // 开始咨询
  142. const startConsult = () => {
  143. uni.navigateTo({
  144. url: `/pages/service/expert-chat?expertId=${expertInfo.value.id}&expertName=${encodeURIComponent(expertInfo.value.name)}`
  145. })
  146. }
  147. </script>
  148. <style lang="scss">
  149. .expert-detail-container {
  150. min-height: 100vh;
  151. background-color: #f5f5f5;
  152. padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
  153. }
  154. // 专家信息卡片
  155. .expert-info-card {
  156. margin: 20rpx;
  157. background-color: #fff;
  158. border-radius: 16rpx;
  159. padding: 30rpx;
  160. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  161. }
  162. .expert-header {
  163. display: flex;
  164. align-items: center;
  165. gap: 24rpx;
  166. }
  167. .avatar-section {
  168. flex-shrink: 0;
  169. }
  170. .avatar-container {
  171. position: relative;
  172. }
  173. .expert-avatar {
  174. width: 120rpx;
  175. height: 120rpx;
  176. border-radius: 60rpx;
  177. border: 4rpx solid #f0f0f0;
  178. }
  179. .online-status {
  180. position: absolute;
  181. bottom: 0;
  182. right: 0;
  183. width: 32rpx;
  184. height: 32rpx;
  185. background-color: #52c41a;
  186. border-radius: 16rpx;
  187. border: 4rpx solid #fff;
  188. }
  189. .basic-info {
  190. flex: 1;
  191. }
  192. .expert-name {
  193. font-size: 36rpx;
  194. font-weight: bold;
  195. color: #333;
  196. margin-bottom: 8rpx;
  197. }
  198. .expert-title {
  199. font-size: 28rpx;
  200. color: #4CAF50;
  201. margin-bottom: 4rpx;
  202. }
  203. .expert-unit {
  204. font-size: 26rpx;
  205. color: #666;
  206. margin-bottom: 16rpx;
  207. }
  208. .stats-row {
  209. display: flex;
  210. gap: 24rpx;
  211. }
  212. .stat-item {
  213. display: flex;
  214. flex-direction: column;
  215. align-items: center;
  216. }
  217. .stat-number {
  218. font-size: 28rpx;
  219. font-weight: bold;
  220. color: #4CAF50;
  221. }
  222. .stat-label {
  223. font-size: 22rpx;
  224. color: #999;
  225. margin-top: 4rpx;
  226. }
  227. // 通用卡片样式
  228. .expertise-card,
  229. .introduction-card,
  230. .service-time-card {
  231. margin: 0 20rpx 20rpx;
  232. background-color: #fff;
  233. border-radius: 16rpx;
  234. padding: 30rpx;
  235. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  236. }
  237. .card-title {
  238. font-size: 30rpx;
  239. font-weight: bold;
  240. color: #333;
  241. margin-bottom: 20rpx;
  242. padding-bottom: 16rpx;
  243. border-bottom: 2rpx solid #f5f5f5;
  244. }
  245. // 擅长领域
  246. .expertise-tags {
  247. display: flex;
  248. flex-wrap: wrap;
  249. gap: 12rpx;
  250. }
  251. .expertise-tag {
  252. padding: 8rpx 16rpx;
  253. background-color: #e6f7ff;
  254. color: #1890ff;
  255. font-size: 26rpx;
  256. border-radius: 16rpx;
  257. white-space: nowrap;
  258. }
  259. // 专家简介
  260. .introduction-content {
  261. padding: 20rpx;
  262. background-color: #f8f9fa;
  263. border-radius: 12rpx;
  264. border-left: 4rpx solid #4CAF50;
  265. }
  266. .introduction-text {
  267. font-size: 28rpx;
  268. color: #666;
  269. line-height: 1.6;
  270. }
  271. // 服务时间
  272. .service-time-content {
  273. display: flex;
  274. flex-direction: column;
  275. gap: 16rpx;
  276. }
  277. .time-item {
  278. display: flex;
  279. align-items: center;
  280. }
  281. .time-label {
  282. font-size: 28rpx;
  283. color: #666;
  284. width: 120rpx;
  285. }
  286. .time-value {
  287. font-size: 28rpx;
  288. color: #333;
  289. font-weight: 500;
  290. }
  291. // 底部操作按钮
  292. .bottom-action-bar {
  293. position: fixed;
  294. bottom: 0;
  295. left: 0;
  296. right: 0;
  297. padding: 20rpx 30rpx;
  298. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  299. background-color: #fff;
  300. border-top: 1rpx solid #f0f0f0;
  301. z-index: 100;
  302. box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.05);
  303. }
  304. .action-btn {
  305. width: 100%;
  306. height: 88rpx;
  307. background-color: #4CAF50;
  308. border-radius: 44rpx;
  309. display: flex;
  310. align-items: center;
  311. justify-content: center;
  312. transition: background-color 0.2s ease;
  313. &:active {
  314. background-color: #45a049;
  315. }
  316. }
  317. .btn-text {
  318. font-size: 32rpx;
  319. color: #fff;
  320. font-weight: bold;
  321. }
  322. </style>