123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- // 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 () {
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- await this.getMyReportList()
- await this.appointmentListFn()
- wx.hideLoading()
- },
- 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
- return new Promise((resolve, rejetct) => {
- myReportList({}).then(res => {
- var response = res.data || []
- that.setData({
- reportList: response
- })
- resolve(res)
- }).catch(e => {
- 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
- })
- })
- }
- })
|