report.js 3.8 KB

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