report.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // pages/report/report.js
  2. import { myReportList } from '../../api/my'
  3. import { documentList } from "../../api/document";
  4. const app = getApp()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. reportList: [],
  11. showPage: true
  12. },
  13. /**
  14. * 生命周期函数--监听页面显示
  15. */
  16. onShow() {
  17. console.log('report onshow');
  18. app.globalData.selectedInex = 1
  19. this.getMyReportList()
  20. },
  21. // 我的报告
  22. getMyReportList () {
  23. var that = this
  24. wx.showLoading({
  25. title: '加载中...',
  26. mask: true
  27. })
  28. myReportList({}).then(res => {
  29. wx.hideLoading()
  30. var response = res.data || []
  31. that.setData({
  32. reportList: response
  33. })
  34. }).catch(e => {
  35. wx.hideLoading()
  36. wx.showModal({
  37. content: e,
  38. confirmColor: '#333',
  39. showCancel: false
  40. })
  41. })
  42. },
  43. /**
  44. * 立即预约
  45. */
  46. handleAppoint() {
  47. this.getDocumentList()
  48. },
  49. /**
  50. * 生命周期函数--监听页面卸载
  51. */
  52. onUnload() {
  53. },
  54. /**
  55. * 页面相关事件处理函数--监听用户下拉动作
  56. */
  57. onPullDownRefresh() {
  58. },
  59. /**
  60. * 页面上拉触底事件的处理函数
  61. */
  62. onReachBottom() {
  63. },
  64. /**
  65. * 点击报告进入详情
  66. */
  67. handleDetail(e) {
  68. var reportId = e.currentTarget.dataset.reportid
  69. var realName = e.currentTarget.dataset.realname
  70. var addTime = e.currentTarget.dataset.addtime
  71. wx.navigateTo({
  72. url: '/pages/reportDetail/reportDetail?reportid=' + reportId + '&realName=' + realName + '&addTime=' + addTime
  73. })
  74. },
  75. // 获取用户档案信息
  76. getDocumentList () {
  77. var that = this
  78. wx.showLoading({
  79. title: '加载中...',
  80. mask: true
  81. })
  82. documentList({
  83. currentPage: 1
  84. }).then(res => {
  85. wx.hideLoading()
  86. const response = res.data.vos || []
  87. if (response.length == 0) {
  88. wx.showModal({
  89. content: '预约用户前需要先添加检测人员信息',
  90. cancelColor: '#666',
  91. confirmColor: '#333',
  92. success (res) {
  93. if (res.confirm) {
  94. wx.navigateTo({
  95. url: '/pages/createFile/createFile?from=index'
  96. })
  97. }
  98. }
  99. })
  100. } else {
  101. wx.navigateTo({
  102. url: '/pages/appointment/appointment',
  103. })
  104. }
  105. }).catch(e => {
  106. wx.hideLoading()
  107. wx.showModal({
  108. content: e,
  109. confirmColor: '#333',
  110. showCancel: false
  111. })
  112. })
  113. }
  114. })