news.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. const pages = require('../../mixin/pages')
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. ...pages.data(),
  8. listUrl: '/api/user/track/list',
  9. searchForm: {
  10. 'key_words': ''
  11. // 'follow_type': 1
  12. },
  13. nav: [
  14. {
  15. name: '推荐',
  16. value: '1'
  17. },
  18. {
  19. name: '关注',
  20. value: '2'
  21. }
  22. ],
  23. active: '1'
  24. },
  25. ...pages.methods,
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad(options) {
  30. this.fetchOrderList()
  31. },
  32. /**
  33. * 生命周期函数--监听页面初次渲染完成
  34. */
  35. onReady() {
  36. },
  37. /**
  38. * 生命周期函数--监听页面显示
  39. */
  40. onShow() {
  41. this.getTabBar().init()
  42. },
  43. /**
  44. * 生命周期函数--监听页面隐藏
  45. */
  46. onHide() {
  47. },
  48. /**
  49. * 生命周期函数--监听页面卸载
  50. */
  51. onUnload() {
  52. },
  53. /**
  54. * 页面相关事件处理函数--监听用户下拉动作
  55. */
  56. onPullDownRefresh() {
  57. if (this.data.freshing) {
  58. return
  59. }
  60. this.setData({
  61. freshing: true
  62. })
  63. this.bindCallBack()
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom() {
  69. this.fetchOrderList()
  70. },
  71. bindCallBack() {
  72. this.refreshOrderList()
  73. },
  74. handleNav(e) {
  75. const { value } = e.detail
  76. const searchForm = JSON.parse(JSON.stringify(this.data.searchForm))
  77. if (value === '1' && searchForm.hasOwnProperty('follow_type')) {
  78. delete searchForm.follow_type
  79. } else if (value === '2') {
  80. searchForm.follow_type = 1
  81. }
  82. this.setData({
  83. active: value,
  84. searchForm: searchForm
  85. }, () => {
  86. this.refreshOrderList()
  87. })
  88. },
  89. followUser(e) {
  90. const { item } = e.target.dataset
  91. console.log(item)
  92. },
  93. jumpAddNews() {
  94. wx.navigateTo({
  95. url: '/pages/addNews/addNews'
  96. })
  97. }
  98. })