myAppointment.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // pages/myAppointment/myAppointment.js
  2. import { appointmentList, cancelAppointment } from '../../api/my'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. navItemActive: '0',
  10. appointmentList: [],
  11. dialogshow: false,
  12. currentPage: 1,
  13. hasNext: false,
  14. globalDataUserName: app.globalData.userInfo.userName,
  15. appointmentId: ''
  16. },
  17. /**
  18. * 生命周期函数--监听页面显示
  19. */
  20. onShow() {
  21. this.setData({
  22. navItemActive: '0'
  23. })
  24. this.getAppointmentList()
  25. },
  26. /**
  27. * 获取预约列表
  28. * 状态 空代表查询全部 ,1:申请(待服务) 2.取消(不做参数) 3.完成
  29. */
  30. getAppointmentList() {
  31. var status = ''
  32. if (this.data.navItemActive == '0' ) {
  33. status = ''
  34. } else if (this.data.navItemActive == '1') {
  35. status = 1
  36. } else if (this.data.navItemActive == '2') {
  37. status = 3
  38. }
  39. var data = {
  40. status: status,
  41. currentPage: this.data.currentPage
  42. }
  43. appointmentList(data).then(res => {
  44. this.setData({
  45. hasNext: res.data.hasNext,
  46. appointmentList: res.data.vos
  47. })
  48. })
  49. },
  50. /**
  51. * 生命周期函数--监听到底
  52. */
  53. onReachBottom() {
  54. if (this.data.hasNext) {
  55. var _currentPag = this.data.currentPag + 1
  56. this.getAppointmentList()
  57. }
  58. },
  59. handleOverlayCancel(e) {
  60. this.setData({
  61. dialogshow: false
  62. })
  63. },
  64. handleoverlayConfirm (e) {
  65. var that = this
  66. cancelAppointment({
  67. appointmentId: this.data.appointmentId
  68. }).then(res => {
  69. wx.showToast({
  70. title: '取消成功',
  71. icon: 'success',
  72. success () {
  73. that.appointmentList()
  74. }
  75. })
  76. })
  77. },
  78. /**
  79. * 取消预约
  80. */
  81. handleCancel(e) {
  82. this.setData({
  83. dialogshow: true,
  84. appointmentId: e.currentTarget.dataset.id
  85. })
  86. },
  87. /**
  88. * 切换nav
  89. * 状态 空代表查询全部 ,1:申请(待服务) 2.取消(不做参数) 3.完成
  90. */
  91. handleChangeNav(e) {
  92. var navItemActive = e.currentTarget.dataset.index
  93. this.setData({
  94. navItemActive: navItemActive,
  95. currentPage: 1
  96. })
  97. this.getAppointmentList()
  98. }
  99. })