list.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. that.getList(0);
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady: function() {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function() {
  67. },
  68. /**
  69. * 生命周期函数--监听页面隐藏
  70. */
  71. onHide: function() {
  72. },
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload: function() {
  77. },
  78. /**
  79. * 页面相关事件处理函数--监听用户下拉动作
  80. */
  81. onPullDownRefresh: function() {
  82. },
  83. /**
  84. * 页面上拉触底事件的处理函数
  85. */
  86. onReachBottom: function() {
  87. }
  88. })