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

80 lines
1.8 KiB

  1. import http from '../../../utils/api'
  2. Page({
  3. data: {
  4. diagnosisList: []
  5. },
  6. onLoad: function() {
  7. this.getwzd()
  8. },
  9. // 问诊单
  10. getwzd(){
  11. http.wzd({
  12. data:{},
  13. success:res=>{
  14. console.log(1111,res);
  15. this.setData({
  16. diagnosisList:res.rows
  17. })
  18. }
  19. })
  20. },
  21. // 格式化日期显示
  22. formatDate: function(dateString) {
  23. const date = new Date(dateString);
  24. const now = new Date();
  25. const diff = now - date;
  26. const diffDays = Math.floor(diff / (1000 * 60 * 60 * 24));
  27. const diffHours = Math.floor(diff / (1000 * 60 * 60));
  28. const diffMinutes = Math.floor(diff / (1000 * 60));
  29. if (diffMinutes < 60) {
  30. return `${diffMinutes}分钟前`;
  31. } else if (diffHours < 24) {
  32. return `${diffHours}小时前`;
  33. } else if (diffDays === 1) {
  34. return '昨天';
  35. } else if (diffDays === 2) {
  36. return '前天';
  37. } else if (diffDays < 7) {
  38. return `${diffDays}天前`;
  39. } else {
  40. const month = date.getMonth() + 1;
  41. const day = date.getDate();
  42. return `${month}${day}`;
  43. }
  44. },
  45. // 新增问诊单
  46. showCreateModal: function() {
  47. wx.navigateTo({
  48. url: '/pagesA/pages/askingSyAdd/askingSyAdd',
  49. });
  50. },
  51. // 查看详情
  52. viewDetail: function(e) {
  53. console.log(1111,e);
  54. const status = e.currentTarget.dataset.value.status
  55. const data = e.currentTarget.dataset.value
  56. console.log(data);
  57. if(status=='已回复'){
  58. wx.navigateTo({
  59. url: `/pagesA/pages/askingSyDetails/askingSyDetails?data=${encodeURIComponent(JSON.stringify(data))}`,
  60. });
  61. }else{
  62. wx.showToast({
  63. title: `无回复内容`,
  64. icon: 'none',
  65. duration: 1000
  66. });
  67. }
  68. },
  69. });