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

67 lines
1.4 KiB

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