report.js 3.9 KB

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