report.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. app.globalData.selectedInex = 1
  18. this.getMyReportList()
  19. },
  20. // 我的报告
  21. getMyReportList () {
  22. var that = this
  23. wx.showLoading({
  24. title: '加载中...',
  25. mask: true
  26. })
  27. myReportList({}).then(res => {
  28. wx.hideLoading()
  29. var response = res.data || []
  30. that.setData({
  31. reportList: response
  32. })
  33. }).catch(e => {
  34. wx.hideLoading()
  35. wx.showModal({
  36. content: e,
  37. confirmColor: '#333',
  38. showCancel: false
  39. })
  40. })
  41. },
  42. /**
  43. * 立即预约
  44. */
  45. handleAppoint() {
  46. if (app.globalData.useNumber == 0) {
  47. wx.showModal({
  48. content: '您当前的检测次数为0,先充值次数',
  49. cancelColor: '#666',
  50. cancelText: '卡激活',
  51. confirmText: '去充值',
  52. confirmColor: '#333',
  53. success (res) {
  54. if (res.confirm) {
  55. wx.navigateTo({
  56. url: '/pages/buy/buy?from=appointment',
  57. })
  58. } else if (res.cancel) {
  59. wx.navigateTo({
  60. url: '/pages/exchange/exchange',
  61. })
  62. }
  63. }
  64. })
  65. } else {
  66. this.getDocumentList()
  67. }
  68. },
  69. /**
  70. * 生命周期函数--监听页面卸载
  71. */
  72. onUnload() {
  73. },
  74. /**
  75. * 页面相关事件处理函数--监听用户下拉动作
  76. */
  77. onPullDownRefresh() {
  78. },
  79. /**
  80. * 页面上拉触底事件的处理函数
  81. */
  82. onReachBottom() {
  83. },
  84. /**
  85. * 点击报告进入详情
  86. */
  87. handleDetail(e) {
  88. var reportId = e.currentTarget.dataset.reportid
  89. var realName = e.currentTarget.dataset.realname
  90. var addTime = e.currentTarget.dataset.addtime
  91. wx.navigateTo({
  92. url: '/pages/reportDetail/reportDetail?reportid=' + reportId + '&realName=' + realName + '&addTime=' + addTime
  93. })
  94. },
  95. // 获取用户档案信息
  96. getDocumentList () {
  97. var that = this
  98. wx.showLoading({
  99. title: '加载中...',
  100. mask: true
  101. })
  102. documentList({
  103. currentPage: 1
  104. }).then(res => {
  105. wx.hideLoading()
  106. const response = res.data.vos || []
  107. if (response.length == 0) {
  108. wx.showModal({
  109. content: '预约用户前需要先添加检测人员信息',
  110. cancelColor: '#666',
  111. confirmColor: '#333',
  112. success (res) {
  113. if (res.confirm) {
  114. wx.navigateTo({
  115. url: '/pages/createFile/createFile?from=index'
  116. })
  117. }
  118. }
  119. })
  120. } else {
  121. wx.navigateTo({
  122. url: '/pages/appointment/appointment',
  123. })
  124. }
  125. }).catch(e => {
  126. wx.hideLoading()
  127. wx.showModal({
  128. content: e,
  129. confirmColor: '#333',
  130. showCancel: false
  131. })
  132. })
  133. }
  134. })