与牧同行-小程序用户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

364 lines
10 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. import http from '../../../utils/api'
  2. const baseUr = require('../../../utils/baseUrl')
  3. Page({
  4. data: {
  5. // 搜索关键词
  6. searchKeyword: '',
  7. // 当前筛选条件
  8. currentFilter: '全部',
  9. // 所有专家数据
  10. allExperts: [{
  11. id: 1,
  12. name: '张建国',
  13. title: '畜牧学博士',
  14. expertise: '牛类养殖与疾病防治',
  15. experience: 15,
  16. online: true,
  17. senior: true,
  18. phone: '138-0013-8001',
  19. email: 'zhangjg@agri-expert.com',
  20. institution: '国家畜牧业研究所',
  21. address: '北京市朝阳区农业科技大厦',
  22. bio: '15年牛类养殖研究经验,发表SCI论文20余篇,擅长规模化养殖场管理与疾病防控。',
  23. tags: ['肉牛养殖', '疾病预防', '饲料配方', '规模化养殖'],
  24. successRate: 98,
  25. responseTime: '15分钟内响应',
  26. avatar: '/pagesA/images/1.png'
  27. },
  28. {
  29. id: 2,
  30. name: '李秀英',
  31. title: '兽医学硕士',
  32. expertise: '猪病诊断与治疗',
  33. experience: 12,
  34. online: true,
  35. senior: true,
  36. phone: '139-0013-9002',
  37. email: 'lixy@vet-hospital.cn',
  38. institution: '农业大学动物医学院',
  39. address: '上海市徐汇区农业路58号',
  40. bio: '资深猪病防治专家,参与多项国家级科研项目,成功解决多个大规模猪场疫情。',
  41. tags: ['猪病诊疗', '疫苗管理', '养殖场规划', '传染病防治'],
  42. successRate: 96,
  43. responseTime: '20分钟内响应',
  44. avatar: '/pagesA/images/2.png'
  45. },
  46. {
  47. id: 3,
  48. name: '王伟民',
  49. title: '高级畜牧师',
  50. expertise: '羊类繁殖与饲养管理',
  51. experience: 20,
  52. online: false,
  53. senior: true,
  54. phone: '137-0013-7003',
  55. email: 'wangwm@livestock.cn',
  56. institution: '草原畜牧业研究中心',
  57. address: '内蒙古呼和浩特市牧业科技园',
  58. bio: '羊类养殖领域权威专家,拥有20年草原牧区养殖经验,精通各类羊只繁殖技术。',
  59. tags: ['绵羊养殖', '山羊繁殖', '牧草种植', '草原管理'],
  60. successRate: 95,
  61. responseTime: '1小时内响应',
  62. avatar: '/pagesA/images/3.png'
  63. },
  64. {
  65. id: 4,
  66. name: '陈秀兰',
  67. title: '家禽养殖专家',
  68. expertise: '鸡鸭养殖技术',
  69. experience: 18,
  70. online: true,
  71. senior: false,
  72. phone: '136-0013-6004',
  73. email: 'chenxl@poultry-expert.com',
  74. institution: '家禽养殖技术中心',
  75. address: '广东省广州市禽业科技园',
  76. bio: '家禽养殖技术推广专家,帮助300+养殖户实现科学化、标准化养殖管理。',
  77. tags: ['蛋鸡养殖', '肉鸭饲养', '疾病防控', '禽舍设计'],
  78. successRate: 94,
  79. responseTime: '30分钟内响应',
  80. avatar: '/pagesA/images/1.png'
  81. },
  82. {
  83. id: 5,
  84. name: '刘志强',
  85. title: '特种养殖专家',
  86. expertise: '鹿、兔等特种动物养殖',
  87. experience: 10,
  88. online: false,
  89. senior: false,
  90. phone: '135-0013-5005',
  91. email: 'liuzq@special-livestock.cn',
  92. institution: '特种动物养殖研究所',
  93. address: '四川省成都市农业科技园',
  94. bio: '特种动物养殖新兴力量,专注于梅花鹿、肉兔等特种动物的现代化养殖技术。',
  95. tags: ['梅花鹿养殖', '肉兔饲养', '市场分析', '特色养殖'],
  96. successRate: 92,
  97. responseTime: '2小时内响应',
  98. avatar: '/pagesA/images/2.png'
  99. },
  100. {
  101. id: 6,
  102. name: '赵雪梅',
  103. title: '畜牧营养学博士',
  104. expertise: '牲畜饲料配方与营养',
  105. experience: 14,
  106. online: true,
  107. senior: true,
  108. phone: '134-0013-4006',
  109. email: 'zhaoxm@feed-research.cn',
  110. institution: '农业科学院饲料研究所',
  111. address: '江苏省南京市科研路88号',
  112. bio: '饲料营养学专家,研发多个高效饲料配方,帮助养殖户降低30%饲料成本。',
  113. tags: ['饲料配方', '营养管理', '成本控制', '饲料安全'],
  114. successRate: 97,
  115. responseTime: '25分钟内响应',
  116. avatar: '/pagesA/images/3.png'
  117. },
  118. {
  119. id: 7,
  120. name: '孙建国',
  121. title: '养殖场管理专家',
  122. expertise: '现代化养殖场设计与运营',
  123. experience: 22,
  124. online: true,
  125. senior: true,
  126. phone: '133-0013-3007',
  127. email: 'sunjg@farm-management.com',
  128. institution: '现代农业发展中心',
  129. address: '浙江省杭州市创新产业园',
  130. bio: '养殖场规划设计专家,参与设计200+现代化养殖场,精通自动化养殖设备应用。',
  131. tags: ['场舍设计', '设备管理', '成本核算', '环保处理'],
  132. successRate: 99,
  133. responseTime: '10分钟内响应',
  134. avatar: '/pagesA/images/2.png'
  135. },
  136. {
  137. id: 8,
  138. name: '周小芳',
  139. title: '兽医病理学硕士',
  140. expertise: '牲畜常见病与传染病防治',
  141. experience: 11,
  142. online: false,
  143. senior: false,
  144. phone: '132-0013-2008',
  145. email: 'zhouxf@vet-pathology.cn',
  146. institution: '动物疫病防控中心',
  147. address: '湖北省武汉市动物防疫站',
  148. bio: '专攻牲畜病理诊断与传染病防控,在快速诊断和精准治疗方面有丰富经验。',
  149. tags: ['传染病防治', '病理诊断', '用药指导', '疫情处理'],
  150. successRate: 93,
  151. responseTime: '1.5小时内响应',
  152. avatar: '/pagesA/images/3.png'
  153. }
  154. ],
  155. baseUr: baseUr,
  156. formzj: {
  157. isOnline: null,
  158. realName: null,
  159. expert: null,
  160. expertiseArea: null
  161. },
  162. // 筛选后的专家列表
  163. filteredExperts: [],
  164. // 当前选中的专家
  165. currentExpert: null,
  166. // 是否显示联系方式弹窗
  167. showContactDialog: false
  168. },
  169. onLoad() {
  170. this.getexpertsList()
  171. },
  172. onShow() {
  173. },
  174. // 专家列表
  175. getexpertsList() {
  176. http.expertsList({
  177. data: this.data.formzj,
  178. success: res => {
  179. console.log(111, res);
  180. this.setData({
  181. allExperts: res.rows
  182. })
  183. }
  184. })
  185. },
  186. // 处理搜索输入
  187. onSearchInput(e) {
  188. this.setData({
  189. searchKeyword: e.detail.value
  190. });
  191. this.sortAndFilterExperts();
  192. },
  193. // 清空搜索
  194. clearSearch() {
  195. this.setData({
  196. searchKeyword: '',
  197. currentFilter: 'all'
  198. });
  199. this.sortAndFilterExperts();
  200. },
  201. // 更改筛选条件
  202. changeFilter(e) {
  203. console.log(2222, e);
  204. const filter = e.currentTarget.dataset.filter;
  205. this.setData({
  206. currentFilter: filter
  207. });
  208. if (filter == '全部') {
  209. this.data.formzj.isOnline = null
  210. this.getexpertsList()
  211. } else {
  212. this.data.formzj.isOnline = filter
  213. this.getexpertsList()
  214. }
  215. },
  216. // 显示专家联系方式
  217. showContactInfo(e) {
  218. const index = e.currentTarget.dataset.index;
  219. const expert = this.data.allExperts[index];
  220. console.log(33333,expert);
  221. this.setData({
  222. currentExpert: expert,
  223. showContactDialog: true
  224. });
  225. },
  226. // 隐藏联系方式弹窗
  227. hideContactDialog() {
  228. this.setData({
  229. showContactDialog: false
  230. });
  231. },
  232. // 阻止事件冒泡
  233. stopPropagation() {
  234. // 阻止事件冒泡
  235. },
  236. // 拨打电话
  237. makePhoneCall(e) {
  238. const phone = e.currentTarget.dataset.phone;
  239. const cleanPhone = phone.replace(/-/g, '');
  240. wx.showModal({
  241. title: '拨打电话',
  242. content: `确定要拨打 ${phone} 吗?`,
  243. success: (res) => {
  244. if (res.confirm) {
  245. wx.makePhoneCall({
  246. phoneNumber: cleanPhone,
  247. success: () => {
  248. wx.showToast({
  249. title: '拨号成功',
  250. icon: 'success'
  251. });
  252. },
  253. fail: (err) => {
  254. console.error('拨打电话失败:', err);
  255. wx.showToast({
  256. title: '拨号失败',
  257. icon: 'none'
  258. });
  259. }
  260. });
  261. }
  262. }
  263. });
  264. },
  265. // 复制邮箱
  266. copyEmail(e) {
  267. const email = e.currentTarget.dataset.email;
  268. wx.setClipboardData({
  269. data: email,
  270. success: () => {
  271. wx.showToast({
  272. title: '邮箱已复制',
  273. icon: 'success'
  274. });
  275. },
  276. fail: () => {
  277. wx.showToast({
  278. title: '复制失败',
  279. icon: 'none'
  280. });
  281. }
  282. });
  283. },
  284. // 查看位置
  285. viewLocation(e) {
  286. const address = e.currentTarget.dataset.address
  287. wx.showModal({
  288. title: '单位地址',
  289. content: address,
  290. showCancel: false,
  291. confirmText: '知道了'
  292. });
  293. },
  294. // 开始咨询
  295. startConsultation() {
  296. const expert = this.data.currentExpert;
  297. console.log(1111,expert);
  298. wx.showModal({
  299. title: '咨询确认',
  300. content: expert.isOnline=='在线' ?
  301. `确定要立即咨询 ${expert.realName} 专家吗?` : `确定要预约咨询 ${expert.realName} 专家吗?`,
  302. success: (res) => {
  303. if (res.confirm) {
  304. if (expert.isOnline=='在线') {
  305. wx.showToast({
  306. title: '正在为您连接',
  307. icon: 'loading',
  308. duration: 2000
  309. });
  310. setTimeout(() => {
  311. // 跳转一对一咨询专家
  312. wx.navigateTo({
  313. url: `/pagesA/pages/expertChat/expertChat?id=${expert.userId}`,
  314. })
  315. this.hideContactDialog();
  316. }, 2000);
  317. } else {
  318. wx.showToast({
  319. title: '预约成功,专家将尽快回复',
  320. icon: 'success'
  321. });
  322. this.hideContactDialog();
  323. }
  324. }
  325. }
  326. });
  327. },
  328. // 分享专家
  329. onShareAppMessage() {
  330. return {
  331. title: '牲畜专家咨询平台',
  332. path: '/pages/expert/expert',
  333. imageUrl: '/images/share-cover.jpg'
  334. }
  335. }
  336. });