help.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. issueList: [],
  10. page: 1,
  11. limit: 10,
  12. count: 0,
  13. showPage: false
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. this.getIssue();
  20. },
  21. /**
  22. * 生命周期函数--监听页面初次渲染完成
  23. */
  24. onReady: function () {
  25. },
  26. /**
  27. * 生命周期函数--监听页面显示
  28. */
  29. onShow: function () {
  30. },
  31. /**
  32. * 生命周期函数--监听页面隐藏
  33. */
  34. onHide: function () {
  35. },
  36. /**
  37. * 生命周期函数--监听页面卸载
  38. */
  39. onUnload: function () {
  40. },
  41. /**
  42. * 页面相关事件处理函数--监听用户下拉动作
  43. */
  44. onPullDownRefresh: function () {
  45. },
  46. /**
  47. * 页面上拉触底事件的处理函数
  48. */
  49. onReachBottom: function () {
  50. },
  51. /**
  52. * 用户点击右上角分享
  53. */
  54. onShareAppMessage: function () {
  55. },
  56. nextPage: function (event) {
  57. var that = this;
  58. if (this.data.page > that.data.count / that.data.limit) {
  59. return true;
  60. }
  61. that.setData({
  62. page: that.data.page + 1
  63. });
  64. this.getIssue();
  65. },
  66. getIssue: function () {
  67. let that = this;
  68. that.setData({
  69. showPage: false,
  70. issueList: []
  71. });
  72. util.request(api.IssueList, {
  73. page: that.data.page,
  74. limit: that.data.limit
  75. }).then(function (res) {
  76. if (res.errno === 0) {
  77. that.setData({
  78. issueList: res.data.list,
  79. showPage: true,
  80. count: res.data.total
  81. });
  82. }
  83. });
  84. },
  85. prevPage: function (event) {
  86. if (this.data.page <= 1) {
  87. return false;
  88. }
  89. var that = this;
  90. that.setData({
  91. page: that.data.page - 1
  92. });
  93. this.getIssue();
  94. }
  95. })