与牧同行-小程序用户端
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.

371 lines
10 KiB

  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. onlineCount: 0,
  166. // 当前选中的专家
  167. currentExpert: null,
  168. // 是否显示联系方式弹窗
  169. showContactDialog: false
  170. },
  171. onLoad() {
  172. this.getexpertsList()
  173. },
  174. onShow() {
  175. },
  176. // 专家列表
  177. getexpertsList() {
  178. http.expertsList({
  179. data: this.data.formzj,
  180. success: res => {
  181. console.log(111, res);
  182. this.setData({
  183. allExperts: res.rows
  184. })
  185. }
  186. })
  187. },
  188. // 处理搜索输入
  189. onSearchInput(e) {
  190. this.setData({
  191. searchKeyword: e.detail.value
  192. });
  193. this.sortAndFilterExperts();
  194. },
  195. // 清空搜索
  196. clearSearch() {
  197. this.setData({
  198. searchKeyword: '',
  199. currentFilter: 'all'
  200. });
  201. this.sortAndFilterExperts();
  202. },
  203. // 更改筛选条件
  204. changeFilter(e) {
  205. console.log(2222, e);
  206. const filter = e.currentTarget.dataset.filter;
  207. this.setData({
  208. currentFilter: filter
  209. });
  210. if (filter == '全部') {
  211. this.data.formzj.isOnline = null
  212. this.getexpertsList()
  213. } else {
  214. this.data.formzj.isOnline = filter
  215. this.getexpertsList()
  216. }
  217. },
  218. // 显示专家联系方式
  219. showContactInfo(e) {
  220. console.log(234,e);
  221. const index = e.currentTarget.dataset.index;
  222. const expert = this.data.allExperts[index];
  223. console.log(33333,expert);
  224. this.setData({
  225. currentExpert: expert,
  226. showContactDialog: true
  227. });
  228. },
  229. // 隐藏联系方式弹窗
  230. hideContactDialog() {
  231. this.setData({
  232. showContactDialog: false
  233. });
  234. },
  235. // 阻止事件冒泡
  236. stopPropagation() {
  237. // 阻止事件冒泡
  238. },
  239. // 拨打电话
  240. makePhoneCall(e) {
  241. const phone = e.currentTarget.dataset.phone;
  242. const cleanPhone = phone.replace(/-/g, '');
  243. wx.showModal({
  244. title: '拨打电话',
  245. content: `确定要拨打 ${phone} 吗?`,
  246. success: (res) => {
  247. if (res.confirm) {
  248. wx.makePhoneCall({
  249. phoneNumber: cleanPhone,
  250. success: () => {
  251. wx.showToast({
  252. title: '拨号成功',
  253. icon: 'success'
  254. });
  255. },
  256. fail: (err) => {
  257. console.error('拨打电话失败:', err);
  258. wx.showToast({
  259. title: '拨号失败',
  260. icon: 'none'
  261. });
  262. }
  263. });
  264. }
  265. }
  266. });
  267. },
  268. // 复制邮箱
  269. copyEmail(e) {
  270. const email = e.currentTarget.dataset.email;
  271. wx.setClipboardData({
  272. data: email,
  273. success: () => {
  274. wx.showToast({
  275. title: '邮箱已复制',
  276. icon: 'success'
  277. });
  278. },
  279. fail: () => {
  280. wx.showToast({
  281. title: '复制失败',
  282. icon: 'none'
  283. });
  284. }
  285. });
  286. },
  287. // 查看位置
  288. viewLocation(e) {
  289. const address = e.currentTarget.dataset.address
  290. wx.showModal({
  291. title: '单位地址',
  292. content: address,
  293. showCancel: false,
  294. confirmText: '知道了'
  295. });
  296. },
  297. // 开始咨询
  298. startConsultation() {
  299. const expert = this.data.currentExpert;
  300. wx.showModal({
  301. title: '咨询确认',
  302. content: expert.online ?
  303. `确定要立即咨询 ${expert.name} 专家吗?` : `确定要预约咨询 ${expert.name} 专家吗?`,
  304. success: (res) => {
  305. if (res.confirm) {
  306. if (expert.online) {
  307. wx.showToast({
  308. title: '正在为您连接专家...',
  309. icon: 'loading',
  310. duration: 2000
  311. });
  312. setTimeout(() => {
  313. // 跳转一对一咨询专家
  314. wx.navigateTo({
  315. url: '/pagesA/pages/expertChat/expertChat',
  316. })
  317. this.hideContactDialog();
  318. }, 2000);
  319. } else {
  320. wx.showToast({
  321. title: '预约成功,专家将尽快回复',
  322. icon: 'success'
  323. });
  324. this.hideContactDialog();
  325. }
  326. }
  327. }
  328. });
  329. },
  330. // 分享专家
  331. onShareAppMessage() {
  332. return {
  333. title: '牲畜专家咨询平台',
  334. path: '/pages/expert/expert',
  335. imageUrl: '/images/share-cover.jpg'
  336. };
  337. }
  338. });