import { createSubscribe } from 'applet-page-component'; import { getOrderList, getVisitList, getPayList } from '../utils/service'; import { navigateTo } from '../utils/index'; import { reportCmPV_YL } from '../utils/cloudMonitorHelper'; const config = { order: { title: '预约记录' }, visit: { title: '就诊记录' }, charge: { title: '充值记录' } }; Component(createSubscribe({ onShow() { const { type } = this.data; if (type === 'order' && getApp().globalData.cancelReservation) { getApp().globalData.cancelReservation = false; this.scrollFetch && this.scrollFetch.fetchList({ pageIndex: 1 }, true, true); } } })({ data: { type: '' }, didMount() { const { type, serviceCode } = getCurrentPages().pop().options; reportCmPV_YL({ title: config[type].title, query: { serviceCode, type } }); this.setData({ type }); }, methods: { saveRef(ref) { this.scrollFetch = ref; }, onService({ pageIndex, pageSize, ...other }) { const { type } = this.data; if (type === 'order') { my.setNavigationBar({ title: '预约记录' }); return getOrderList({ pageIndex, pageSize, ...other }); } else if (type === 'visit') { my.setNavigationBar({ title: '就诊记录' }); return getVisitList({ pageIndex, pageSize, ...other }); } else if (type === 'charge') { my.setNavigationBar({ title: '充值记录' }); return getPayList({ status: 1, type: 2, pageIndex, pageSize, ...other }); } }, toDetail(orderId) { navigateTo({ url: `/pages/page-detail/index?queryId=${orderId}&type=${this.data.type}` }); } } }));