complaint.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // pages/user/advisory/advisory.js
  2. const app = getApp(),
  3. {
  4. globalData: {
  5. util: {
  6. regeneratorRuntime,
  7. api: {
  8. advisoryList,
  9. },
  10. navigate,
  11. navigate_auth_native,
  12. request: {
  13. get_auth,
  14. get
  15. }
  16. }
  17. }
  18. } = app;
  19. Page({
  20. /**
  21. * 页面的初始数据
  22. */
  23. data: {
  24. page: '1',
  25. rows: '10',
  26. completion: false,
  27. noData: false,
  28. list: [],
  29. },
  30. advisoryDetail: function (e) {
  31. let id = e.currentTarget.dataset.id;
  32. navigate('/pages/user/complaintDetail/complaintDetail?id=' + id);
  33. },
  34. lower: function (e) {
  35. let that = this;
  36. let page = that.data.page,
  37. total = that.data.total;
  38. page++;
  39. let num = Math.ceil(total / 10);
  40. if (page <= num) {
  41. that.setData({
  42. page,
  43. completion: true,
  44. })
  45. that.listData();
  46. return;
  47. } else {
  48. return;
  49. }
  50. },
  51. async listData() {
  52. let that = this, noData, completion, list = [];
  53. let {
  54. items,
  55. total,
  56. _err
  57. } = await get_auth(advisoryList, {
  58. page: that.data.page,
  59. rows: that.data.rows,
  60. type: 1
  61. });
  62. if (!_err) {
  63. items.forEach(function (item) {
  64. that.data.list.push(item);
  65. })
  66. list = that.data.list;
  67. if(list.length==total){
  68. that.setData({
  69. noNextData: true
  70. })
  71. }
  72. completion = false
  73. total == 0 ? noData = true : noData = false;
  74. } else {
  75. completion = true;
  76. }
  77. that.setData({
  78. list,
  79. total,
  80. completion,
  81. noData
  82. })
  83. },
  84. /**
  85. * 生命周期函数--监听页面加载
  86. */
  87. async onLoad(options) {
  88. let that = this;
  89. this.listData();
  90. },
  91. /**
  92. * 生命周期函数--监听页面初次渲染完成
  93. */
  94. onReady: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面显示
  98. */
  99. onShow: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面隐藏
  103. */
  104. onHide: function () {
  105. },
  106. /**
  107. * 生命周期函数--监听页面卸载
  108. */
  109. onUnload: function () {
  110. },
  111. /**
  112. * 页面相关事件处理函数--监听用户下拉动作
  113. */
  114. onPullDownRefresh: function () {
  115. },
  116. /**
  117. * 页面上拉触底事件的处理函数
  118. */
  119. onReachBottom: function () {
  120. },
  121. /**
  122. * 用户点击右上角分享
  123. */
  124. onShareAppMessage: function () {
  125. },
  126. navigate_auth_native
  127. })