queue.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // pages/queue/queue.js
  2. const util = require("../../utils/util")
  3. const urlDef = require("../../utils/urls")
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. planId: undefined,
  10. orgId: undefined,
  11. waitDate: undefined,
  12. list: [
  13. ],
  14. loading: '上拉加载',
  15. flag: 0,
  16. pageNum: 0,
  17. hasNextPage: true,
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. this.setData({ planId: options.planId, orgId: options.orgId, waitDate: options.visitDate })
  24. this.queryList()
  25. },
  26. /**
  27. * 生命周期函数--监听页面初次渲染完成
  28. */
  29. onReady: function () {
  30. },
  31. /**
  32. * 生命周期函数--监听页面显示
  33. */
  34. onShow: function () {
  35. },
  36. /**
  37. * 生命周期函数--监听页面隐藏
  38. */
  39. onHide: function () {
  40. },
  41. /**
  42. * 生命周期函数--监听页面卸载
  43. */
  44. onUnload: function () {
  45. },
  46. /**
  47. * 页面相关事件处理函数--监听用户下拉动作
  48. */
  49. onPullDownRefresh: function () {
  50. },
  51. /**
  52. * 页面上拉触底事件的处理函数
  53. */
  54. onReachBottom: function () {
  55. if (this.data.hasNextPage) {
  56. let pn = this.data.pageNum
  57. this.setData({ loading: '加载中', 'pageNum': ++pn })
  58. this.queryList()
  59. }
  60. },
  61. /**
  62. * 用户点击右上角分享
  63. */
  64. onShareAppMessage: function () {
  65. },
  66. doQueueUp: function () {
  67. wx.showLoading({
  68. title: '处理中',
  69. mask: true
  70. })
  71. const urls = urlDef.urls;
  72. let stu = wx.getStorageSync('student');
  73. this.setData({studentId: stu.studentId})
  74. util.apiPost(urls.queueUp, this.data).then(rs => {
  75. wx.hideLoading({});
  76. if(rs.message ) {
  77. wx.showToast({
  78. title: rs.message,
  79. icon: 'none'
  80. })
  81. }else{
  82. wx.showToast({
  83. title: '排队成功',
  84. icon: 'success'
  85. })
  86. }
  87. })
  88. },
  89. queryList: function () {
  90. const urls = urlDef.urls;
  91. let params = { 'q.orgId': this.data.orgId, 'q.visitDate': this.data.waitDate, 'q.planId': this.data.planId }
  92. params.pageNum = this.data.pageNum
  93. util.apiPost(urls.queue_list, params).then(rs => {
  94. let list = rs.list
  95. this.setData({
  96. 'hasNextPage': rs.hasNextPage,
  97. 'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
  98. 'list': this.data.list.concat(list)
  99. })
  100. })
  101. },
  102. })