// pages/report/report.js import { myReportList } from '../../api/my' import { documentList } from "../../api/document" import { appointmentList } from '../../api/appointment' const app = getApp() Page({ /** * 页面的初始数据 */ data: { reportList: [], showPage: true }, /** * 生命周期函数--监听页面显示 */ onShow() { app.globalData.selectedInex = 1 wx.setStorageSync('selectedInex', 1) this.initReportPage() }, async initReportPage () { await this.getMyReportList() await this.appointmentListFn() }, appointmentListFn () { return new Promise((resolve, reject) => { appointmentList({ status: 1, currentPage: 1 }).then(res => { if (res.data.vos.length !== 0) { app.globalData.hasAppointment = true } else { app.globalData.hasAppointment = false } resolve(res) }) }) }, // 我的报告 getMyReportList () { var that = this wx.showLoading({ title: '加载中...', mask: true }) return new Promise((resolve, rejetct) => { myReportList({}).then(res => { wx.hideLoading() var response = res.data || [] that.setData({ reportList: response }) resolve(res) }).catch(e => { wx.hideLoading() wx.showModal({ content: e, confirmColor: '#333', showCancel: false }) }) }) }, /** * 立即预约 */ handleAppoint() { if (app.globalData.useNumber == 0) { wx.showModal({ content: '您当前的检测次数为0,先充值次数', cancelColor: '#666', cancelText: '卡激活', confirmText: '去充值', confirmColor: '#333', success (res) { if (res.confirm) { wx.navigateTo({ url: '/pages/buy/buy?from=appointment', }) } else if (res.cancel) { wx.navigateTo({ url: '/pages/exchange/exchange', }) } } }) } else { if (app.globalData.hasAppointment) { wx.showModal({ content: '您预约的健康筛查还未体验,请先体验', cancelColor: '#666', cancelText: '取消', confirmText: '我的预约', confirmColor: '#333', success (res) { if (res.confirm) { wx.navigateTo({ url: '/pages/myAppointment/myAppointment', }) } } }) } else { this.getDocumentList() } } }, /** * 点击报告进入详情 */ handleDetail(e) { var reportId = e.currentTarget.dataset.reportid var realName = e.currentTarget.dataset.realname var addTime = e.currentTarget.dataset.addtime wx.navigateTo({ url: '/pages/reportDetail/reportDetail?reportid=' + reportId + '&realName=' + realName + '&addTime=' + addTime }) }, // 获取用户档案信息 getDocumentList () { var that = this wx.showLoading({ title: '加载中...', mask: true }) documentList({ currentPage: 1 }).then(res => { wx.hideLoading() const response = res.data.vos || [] if (response.length == 0) { wx.showModal({ content: '预约用户前需要先添加检测人员信息', cancelColor: '#666', confirmColor: '#333', success (res) { if (res.confirm) { wx.navigateTo({ url: '/pages/createFile/createFile?from=index' }) } } }) } else { wx.navigateTo({ url: '/pages/appointment/appointment', }) } }).catch(e => { wx.hideLoading() wx.showModal({ content: e, confirmColor: '#333', showCancel: false }) }) } })