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

103 lines
2.0 KiB

  1. import http from '../../../utils/api'
  2. const baseUrl = require('../../../utils/baseUrl')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. diagnosisData:{},
  9. replies:[],
  10. baseUrl:baseUrl,
  11. refreshing: false
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad(options) {
  17. if (options.data) {
  18. // 根据id加载兽医回复数据
  19. const data = JSON.parse(decodeURIComponent(options.data));
  20. if(data.images){
  21. const images = data.images.split(',')
  22. this.setData({
  23. images:images
  24. })
  25. }
  26. this.setData({
  27. diagnosisData:data,
  28. })
  29. this.loadDiagnosisData(data.formId);
  30. }
  31. },
  32. // 加载问诊数据
  33. loadDiagnosisData(id) {
  34. console.log('加载问诊数据:', id);
  35. http.wzdxq({
  36. data:{
  37. consultationId:id
  38. },
  39. success:res=>{
  40. console.log(111111111,res);
  41. this.setData({
  42. replies:res.rows
  43. })
  44. }
  45. })
  46. },
  47. // 返回上一页
  48. goBack() {
  49. wx.navigateBack();
  50. },
  51. // 分享
  52. onShare() {
  53. wx.showActionSheet({
  54. itemList: ['分享给好友', '保存到相册'],
  55. success: (res) => {
  56. if (res.tapIndex === 0) {
  57. wx.showToast({
  58. title: '已分享',
  59. icon: 'success'
  60. });
  61. }
  62. }
  63. });
  64. },
  65. // 下拉刷新
  66. onRefresh() {
  67. this.setData({
  68. refreshing: true
  69. });
  70. this.loadDiagnosisData(this.data.diagnosisData.formId)
  71. setTimeout(() => {
  72. this.setData({
  73. refreshing: false
  74. });
  75. wx.showToast({
  76. title: '刷新成功',
  77. icon: 'success'
  78. });
  79. }, 1000);
  80. },
  81. // 预览图片
  82. previewImage(e) {
  83. const current = e.currentTarget.dataset.url;
  84. const urls = e.currentTarget.dataset.urls;
  85. const urlsArray = urls.map(item=>{
  86. return baseUrl+item
  87. })
  88. console.log(666,urlsArray);
  89. wx.previewImage({
  90. current:current,
  91. urls:urlsArray
  92. });
  93. },
  94. });