list.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. const util = require('../../../utils/util.js');
  2. const api = require('../../../utils/api.js');
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. tab: 1,
  10. list: '',
  11. userInfo: ''
  12. },
  13. checkTab: function(e) {
  14. const that = this;
  15. let type = e.currentTarget.dataset.type;
  16. that.setData({
  17. tab: type
  18. })
  19. if (type == 1) {
  20. that.getList(0);
  21. } else if (type == 3) {
  22. that.getList(1);
  23. } else {
  24. that.getList('');
  25. }
  26. },
  27. getList: function(state) {
  28. const that = this;
  29. util.httpRequest(api.getSuggestionList, {
  30. loginId: that.data.userInfo.loginId,
  31. reply: state,
  32. page: 1,
  33. rows: 20
  34. }, 'post').then(res => {
  35. that.setData({
  36. list: res.data.data.data
  37. })
  38. })
  39. },
  40. toDetail: function(e) {
  41. const that = this;
  42. let id = e.currentTarget.dataset.id;
  43. wx.navigateTo({
  44. url: 'detail?id=' + id,
  45. })
  46. },
  47. /**
  48. * 生命周期函数--监听页面加载
  49. */
  50. onLoad: function(options) {
  51. const that = this;
  52. let userInfo = wx.getStorageSync('user');
  53. that.setData({
  54. userInfo: userInfo
  55. })
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady: function() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面显示
  64. */
  65. onShow: function() {
  66. const that = this;
  67. let type = that.data.tab;
  68. if (type == 1) {
  69. that.getList(0);
  70. } else if (type == 3) {
  71. that.getList(1);
  72. } else {
  73. that.getList('');
  74. }
  75. },
  76. /**
  77. * 生命周期函数--监听页面隐藏
  78. */
  79. onHide: function() {
  80. },
  81. /**
  82. * 生命周期函数--监听页面卸载
  83. */
  84. onUnload: function() {
  85. },
  86. /**
  87. * 页面相关事件处理函数--监听用户下拉动作
  88. */
  89. onPullDownRefresh: function() {
  90. },
  91. /**
  92. * 页面上拉触底事件的处理函数
  93. */
  94. onReachBottom: function() {
  95. }
  96. })