report.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // pages/report/report.js
  2. import { myReportList } from '../../api/my'
  3. import { documentList } from "../../api/document"
  4. import { appointmentList } from '../../api/appointment'
  5. const app = getApp()
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. reportList: [],
  12. showPage: true
  13. },
  14. /**
  15. * 生命周期函数--监听页面显示
  16. */
  17. onShow() {
  18. console.log(app.globalData.hasAppointment);
  19. app.globalData.selectedInex = 1
  20. this.getMyReportList()
  21. this.appointmentListFn()
  22. },
  23. appointmentListFn () {
  24. appointmentList({
  25. status: 1,
  26. currentPage: 1
  27. }).then(res => {
  28. if (res.data.vos.length !== 0) {
  29. app.globalData.hasAppointment = true
  30. } else {
  31. app.globalData.hasAppointment = false
  32. }
  33. })
  34. },
  35. // 我的报告
  36. getMyReportList () {
  37. var that = this
  38. wx.showLoading({
  39. title: '加载中...',
  40. mask: true
  41. })
  42. myReportList({}).then(res => {
  43. wx.hideLoading()
  44. var response = res.data || []
  45. that.setData({
  46. reportList: response
  47. })
  48. }).catch(e => {
  49. wx.hideLoading()
  50. wx.showModal({
  51. content: e,
  52. confirmColor: '#333',
  53. showCancel: false
  54. })
  55. })
  56. },
  57. /**
  58. * 立即预约
  59. */
  60. handleAppoint() {
  61. if (app.globalData.useNumber == 0) {
  62. wx.showModal({
  63. content: '您当前的检测次数为0,先充值次数',
  64. cancelColor: '#666',
  65. cancelText: '卡激活',
  66. confirmText: '去充值',
  67. confirmColor: '#333',
  68. success (res) {
  69. if (res.confirm) {
  70. wx.navigateTo({
  71. url: '/pages/buy/buy?from=appointment',
  72. })
  73. } else if (res.cancel) {
  74. wx.navigateTo({
  75. url: '/pages/exchange/exchange',
  76. })
  77. }
  78. }
  79. })
  80. } else {
  81. if (app.globalData.hasAppointment) {
  82. wx.showModal({
  83. content: '您预约的健康筛查还未体验,请先体验',
  84. cancelColor: '#666',
  85. cancelText: '取消',
  86. confirmText: '我的预约',
  87. confirmColor: '#333',
  88. success (res) {
  89. if (res.confirm) {
  90. wx.navigateTo({
  91. url: '/pages/myAppointment/myAppointment',
  92. })
  93. }
  94. }
  95. })
  96. } else {
  97. this.getDocumentList()
  98. }
  99. }
  100. },
  101. /**
  102. * 点击报告进入详情
  103. */
  104. handleDetail(e) {
  105. var reportId = e.currentTarget.dataset.reportid
  106. var realName = e.currentTarget.dataset.realname
  107. var addTime = e.currentTarget.dataset.addtime
  108. wx.navigateTo({
  109. url: '/pages/reportDetail/reportDetail?reportid=' + reportId + '&realName=' + realName + '&addTime=' + addTime
  110. })
  111. },
  112. // 获取用户档案信息
  113. getDocumentList () {
  114. var that = this
  115. wx.showLoading({
  116. title: '加载中...',
  117. mask: true
  118. })
  119. documentList({
  120. currentPage: 1
  121. }).then(res => {
  122. wx.hideLoading()
  123. const response = res.data.vos || []
  124. if (response.length == 0) {
  125. wx.showModal({
  126. content: '预约用户前需要先添加检测人员信息',
  127. cancelColor: '#666',
  128. confirmColor: '#333',
  129. success (res) {
  130. if (res.confirm) {
  131. wx.navigateTo({
  132. url: '/pages/createFile/createFile?from=index'
  133. })
  134. }
  135. }
  136. })
  137. } else {
  138. wx.navigateTo({
  139. url: '/pages/appointment/appointment',
  140. })
  141. }
  142. }).catch(e => {
  143. wx.hideLoading()
  144. wx.showModal({
  145. content: e,
  146. confirmColor: '#333',
  147. showCancel: false
  148. })
  149. })
  150. }
  151. })