// pages/myAppointment/myAppointment.js import { appointmentList, cancelAppointment } from '../../api/my' const app = getApp() Page({ /** * 页面的初始数据 */ data: { navItemActive: '0', appointmentList: [], dialogshow: false, currentPage: 1, hasNext: false, globalDataUserName: app.globalData.userInfo.userName, appointmentId: '' }, /** * 生命周期函数--监听页面显示 */ onShow() { this.setData({ navItemActive: '0' }) this.getAppointmentList() }, /** * 获取预约列表 * 状态 空代表查询全部 ,1:申请(待服务) 2.取消(不做参数) 3.完成 */ getAppointmentList() { var status = '' if (this.data.navItemActive == '0' ) { status = '' } else if (this.data.navItemActive == '1') { status = 1 } else if (this.data.navItemActive == '2') { status = 3 } var data = { status: status, currentPage: this.data.currentPage } appointmentList(data).then(res => { this.setData({ hasNext: res.data.hasNext, appointmentList: res.data.vos }) }) }, /** * 生命周期函数--监听到底 */ onReachBottom() { if (this.data.hasNext) { var _currentPag = this.data.currentPag + 1 this.getAppointmentList() } }, handleOverlayCancel(e) { this.setData({ dialogshow: false }) }, handleoverlayConfirm (e) { var that = this cancelAppointment({ appointmentId: this.data.appointmentId }).then(res => { wx.showToast({ title: '取消成功', icon: 'success', success () { that.appointmentList() } }) }) }, /** * 取消预约 */ handleCancel(e) { this.setData({ dialogshow: true, appointmentId: e.currentTarget.dataset.id }) }, /** * 切换nav * 状态 空代表查询全部 ,1:申请(待服务) 2.取消(不做参数) 3.完成 */ handleChangeNav(e) { var navItemActive = e.currentTarget.dataset.index this.setData({ navItemActive: navItemActive, currentPage: 1 }) this.getAppointmentList() } })