advisory.js 2.4 KB

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