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

72 lines
1.5 KiB

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