weizhang.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.setData({
  20. arr: []
  21. })
  22. that.getList()
  23. },
  24. getList: function () {
  25. var that = this;
  26. my.showLoading({
  27. content: '加载中...',
  28. })
  29. let data = { page: that.data.pages }
  30. app.request('/punishment_orders', data, 'GET').then(res => {
  31. if (res.status == 200) {
  32. console.log(res)
  33. let arr1 = res.data.data
  34. var arr = that.data.arr.concat(arr1);
  35. if (arr1.length == 0) {
  36. my.showToast({
  37. content: '暂无更多~',
  38. icon: 'none'
  39. })
  40. } else {
  41. that.setData({
  42. arr,
  43. links: res.data.meta.pagination.links
  44. })
  45. }
  46. }
  47. my.hideLoading({
  48. complete: (res) => { },
  49. })
  50. })
  51. },
  52. onHide: function () {
  53. },
  54. onUnload: function () {
  55. },
  56. onPullDownRefresh: function () {
  57. },
  58. onReachBottom: function () {
  59. if (this.data.links == null) {
  60. my.showToast({
  61. content: '暂无更多',
  62. icon: 'none'
  63. })
  64. return
  65. } else {
  66. let page = this.data.pages++
  67. page++
  68. this.setData({
  69. pages: page
  70. })
  71. this.getList()
  72. }
  73. },
  74. onShareAppMessage: function () {
  75. }
  76. })