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

365 lines
10 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month 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. console.log(234,e);
  219. const index = e.currentTarget.dataset.index;
  220. const expert = this.data.allExperts[index];
  221. console.log(33333,expert);
  222. this.setData({
  223. currentExpert: expert,
  224. showContactDialog: true
  225. });
  226. },
  227. // 隐藏联系方式弹窗
  228. hideContactDialog() {
  229. this.setData({
  230. showContactDialog: false
  231. });
  232. },
  233. // 阻止事件冒泡
  234. stopPropagation() {
  235. // 阻止事件冒泡
  236. },
  237. // 拨打电话
  238. makePhoneCall(e) {
  239. const phone = e.currentTarget.dataset.phone;
  240. const cleanPhone = phone.replace(/-/g, '');
  241. wx.showModal({
  242. title: '拨打电话',
  243. content: `确定要拨打 ${phone} 吗?`,
  244. success: (res) => {
  245. if (res.confirm) {
  246. wx.makePhoneCall({
  247. phoneNumber: cleanPhone,
  248. success: () => {
  249. wx.showToast({
  250. title: '拨号成功',
  251. icon: 'success'
  252. });
  253. },
  254. fail: (err) => {
  255. console.error('拨打电话失败:', err);
  256. wx.showToast({
  257. title: '拨号失败',
  258. icon: 'none'
  259. });
  260. }
  261. });
  262. }
  263. }
  264. });
  265. },
  266. // 复制邮箱
  267. copyEmail(e) {
  268. const email = e.currentTarget.dataset.email;
  269. wx.setClipboardData({
  270. data: email,
  271. success: () => {
  272. wx.showToast({
  273. title: '邮箱已复制',
  274. icon: 'success'
  275. });
  276. },
  277. fail: () => {
  278. wx.showToast({
  279. title: '复制失败',
  280. icon: 'none'
  281. });
  282. }
  283. });
  284. },
  285. // 查看位置
  286. viewLocation(e) {
  287. const address = e.currentTarget.dataset.address
  288. wx.showModal({
  289. title: '单位地址',
  290. content: address,
  291. showCancel: false,
  292. confirmText: '知道了'
  293. });
  294. },
  295. // 开始咨询
  296. startConsultation() {
  297. const expert = this.data.currentExpert;
  298. console.log(1111,expert);
  299. wx.showModal({
  300. title: '咨询确认',
  301. content: expert.isOnline=='在线' ?
  302. `确定要立即咨询 ${expert.realName} 专家吗?` : `确定要预约咨询 ${expert.realName} 专家吗?`,
  303. success: (res) => {
  304. if (res.confirm) {
  305. if (expert.isOnline=='在线') {
  306. wx.showToast({
  307. title: '正在为您连接',
  308. icon: 'loading',
  309. duration: 2000
  310. });
  311. setTimeout(() => {
  312. // 跳转一对一咨询专家
  313. wx.navigateTo({
  314. url: '/pagesA/pages/expertChat/expertChat',
  315. })
  316. this.hideContactDialog();
  317. }, 2000);
  318. } else {
  319. wx.showToast({
  320. title: '预约成功,专家将尽快回复',
  321. icon: 'success'
  322. });
  323. this.hideContactDialog();
  324. }
  325. }
  326. }
  327. });
  328. },
  329. // 分享专家
  330. onShareAppMessage() {
  331. return {
  332. title: '牲畜专家咨询平台',
  333. path: '/pages/expert/expert',
  334. imageUrl: '/images/share-cover.jpg'
  335. }
  336. }
  337. });