index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import {
  2. myMeeting,
  3. } from '../../../utils/api/meeting'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. list: [],
  10. //tab的current
  11. currentPage: 0,
  12. searchData: {
  13. data: {
  14. appointmentStatus: null,
  15. },
  16. pageNum: 1,
  17. pageSize: 8,
  18. },
  19. total: null,
  20. type: ''
  21. },
  22. // 获取列表 type-> 1:初始化 2:下拉加载 currentPage-> 0全部1审核中2通过3不通过
  23. getList(type) {
  24. let {
  25. searchData,
  26. list,
  27. currentPage
  28. } = this.data
  29. if (currentPage == 0) {
  30. searchData.data.appointmentStatus = null
  31. } else {
  32. searchData.data.appointmentStatus = currentPage
  33. }
  34. searchData.pageNum = type === 1 ? 1 : (searchData.pageNum + 1)
  35. this.setData({
  36. 'searchData.pageNum': searchData.pageNum
  37. })
  38. wx.showLoading({
  39. title: '加载中',
  40. })
  41. myMeeting(searchData).then(res => {
  42. res.data.records.forEach(item=>{
  43. item.status=item.appointmentStatus
  44. })
  45. list = type === 1 ? res.data.records : list.concat(res.data.records)
  46. wx.hideLoading()
  47. this.setData({
  48. list: list,
  49. total: res.data.total,
  50. })
  51. })
  52. },
  53. // scrollView触底事件
  54. reachBottom(e) {
  55. this.getList(e.currentTarget.dataset.type)
  56. },
  57. //获得切换tab的index
  58. changeSwiper(e) {
  59. var {
  60. currentPage
  61. } = this.data;
  62. switch (e.currentTarget.dataset.type) {
  63. case 'click':
  64. currentPage = e.currentTarget.dataset.index
  65. break;
  66. case 'slide':
  67. currentPage = e.detail.current
  68. break;
  69. default:
  70. break;
  71. };
  72. this.setData({
  73. currentPage
  74. })
  75. this.getList(1)
  76. },
  77. /**
  78. * 生命周期函数--监听页面加载
  79. */
  80. onLoad(options) {
  81. if (options.type) {
  82. this.setData({
  83. type: options.type
  84. })
  85. }
  86. },
  87. /**
  88. * 生命周期函数--监听页面初次渲染完成
  89. */
  90. onReady() {
  91. },
  92. /**
  93. * 生命周期函数--监听页面显示
  94. */
  95. onShow() {
  96. this.getList(1)
  97. },
  98. /**
  99. * 生命周期函数--监听页面隐藏
  100. */
  101. onHide() {
  102. },
  103. /**
  104. * 生命周期函数--监听页面卸载
  105. */
  106. onUnload() {
  107. },
  108. /**
  109. * 页面相关事件处理函数--监听用户下拉动作
  110. */
  111. onPullDownRefresh() {
  112. },
  113. /**
  114. * 页面上拉触底事件的处理函数
  115. */
  116. onReachBottom() {
  117. },
  118. /**
  119. * 用户点击右上角分享
  120. */
  121. onShareAppMessage() {
  122. }
  123. })