weizhang.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. var app = getApp()
  2. Page({
  3. data: {
  4. arr: [],
  5. pages: 1,//当前页面
  6. links: '',//下一页地址
  7. },
  8. onLoad: function (options) {
  9. },
  10. detail(e) {
  11. my.navigateTo({
  12. url: '../weizhang_detail/weizhang_detail?no=' + e.currentTarget.dataset.id,
  13. })
  14. },
  15. onReady: function () {
  16. },
  17. onShow: function () {
  18. var that = this;
  19. that.getList()
  20. },
  21. getList: function () {
  22. var that = this;
  23. my.showLoading({
  24. content: '加载中...',
  25. })
  26. let data = { page: that.data.pages }
  27. app.request('/punishment_orders', data, 'GET').then(res => {
  28. if (res.status == 200) {
  29. console.log(res)
  30. let arr1 = res.data.data
  31. var arr = that.data.arr.concat(arr1);
  32. if (arr1.length == 0) {
  33. my.showToast({
  34. content: '暂无更多~',
  35. icon: 'none'
  36. })
  37. } else {
  38. that.setData({
  39. arr,
  40. links: res.data.meta.pagination.links
  41. })
  42. }
  43. }
  44. my.hideLoading({
  45. complete: (res) => { },
  46. })
  47. })
  48. },
  49. onHide: function () {
  50. },
  51. onUnload: function () {
  52. },
  53. onPullDownRefresh: function () {
  54. },
  55. onReachBottom: function () {
  56. if (this.data.links == null) {
  57. my.showToast({
  58. content: '暂无更多',
  59. icon: 'none'
  60. })
  61. return
  62. } else {
  63. let page = this.data.pages++
  64. page++
  65. this.setData({
  66. pages: page
  67. })
  68. this.getList()
  69. }
  70. },
  71. onShareAppMessage: function () {
  72. }
  73. })