day.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // pages/follow/follow.js
  2. const $api = require('../../utils/api.js').API;
  3. const $push = require('../../utils/api.js').PUSH;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. list: [],
  10. page: 1,
  11. total: 0,
  12. show: 0
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. this.setData({
  19. id: options.id,
  20. user_id: options.user_id
  21. })
  22. this.getData();
  23. },
  24. next: function () {
  25. if (this.data.list.length < this.data.total) {
  26. const page = this.data.page + 1
  27. this.setData({
  28. page: page
  29. })
  30. this.getData()
  31. }
  32. },
  33. getData() {
  34. wx.showLoading({
  35. title: '正在加载',
  36. })
  37. var list = this.data.list
  38. //每日持股
  39. var parm = {
  40. id: this.data.id, user_id: this.data.user_id,
  41. page: this.data.page, page_size: 20
  42. }
  43. $api.getRecordList(parm).then(res => {
  44. wx.hideLoading()
  45. res.data.data.list.forEach(item => {
  46. list.push(item)
  47. })
  48. this.setData({
  49. list: list,
  50. total: res.data.data.total,
  51. show: 1
  52. })
  53. })
  54. },
  55. //预览
  56. preview(e) {
  57. wx.previewImage({
  58. urls: e.target.dataset.urls,
  59. current: e.target.dataset.src
  60. })
  61. },
  62. pushToday(e){
  63. $push.pushToday(e.currentTarget.dataset)
  64. },
  65. /**
  66. * 生命周期函数--监听页面初次渲染完成
  67. */
  68. onReady: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面显示
  72. */
  73. onShow: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面隐藏
  77. */
  78. onHide: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面卸载
  82. */
  83. onUnload: function () {
  84. },
  85. /**
  86. * 页面相关事件处理函数--监听用户下拉动作
  87. */
  88. onPullDownRefresh: function () {
  89. },
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom: function () {
  94. },
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage: function () {
  99. }
  100. })