问星数据小程序

hotDr.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // pages/hotDr/hotDr.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. hotDrList:[],
  9. page:1,
  10. pages:0,
  11. scrollTop:0
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. this.getHotDr()
  18. },
  19. goHrDetail(e){
  20. wx.navigateTo({
  21. url: '/pages/hrDetail/hrDetail?user_id=' + e.currentTarget.dataset.userid ,
  22. })
  23. },
  24. getHotDr(){//热门达人
  25. wx.hideLoading()
  26. wx.showLoading({
  27. title: '加载中',
  28. })
  29. app.func.req('/api/kwaiUser/redUserList', 'get', {
  30. 'page': this.data.page,
  31. 'starttime':app.func.getDay(-30,false),
  32. 'endtime':app.func.getDay(-1,false)
  33. }, (res) => {
  34. wx.hideLoading()
  35. if(res && res.errno == 0){
  36. //成功
  37. var list = res.rst.data;
  38. list.forEach((item)=>{
  39. if(item.categorys){
  40. item.categorys_arr = item.categorys.splice(',')
  41. }
  42. })
  43. var list2 = this.data.hotDrList.concat(list)
  44. this.setData({
  45. hotDrList: list2,
  46. pages: res.rst.pages
  47. })
  48. }else{
  49. wx.showToast({
  50. title: res.err,
  51. icon: 'none',
  52. duration: 2000
  53. })
  54. }
  55. },()=>{
  56. wx.hideLoading()
  57. })
  58. },
  59. onPageScroll: function(res) {//获取滑动的距离
  60. this.setData({
  61. scrollTop:res.scrollTop
  62. })
  63. },
  64. goScrolltop:function(e){//返回顶部
  65. if (wx.pageScrollTo) {
  66. wx.pageScrollTo({
  67. scrollTop: 0
  68. })
  69. } else {
  70. wx.showModal({
  71. title: '提示',
  72. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  73. })
  74. }
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面隐藏
  88. */
  89. onHide: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面卸载
  93. */
  94. onUnload: function () {
  95. },
  96. /**
  97. * 页面相关事件处理函数--监听用户下拉动作
  98. */
  99. onPullDownRefresh: function () {
  100. },
  101. /**
  102. * 页面上拉触底事件的处理函数
  103. */
  104. onReachBottom: function () {
  105. if(this.data.pages <= this.data.page){
  106. return
  107. }
  108. this.data.page ++;
  109. this.getHotDr()
  110. },
  111. /**
  112. * 用户点击右上角分享
  113. */
  114. onShareAppMessage: function () {
  115. }
  116. })