information.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. const app=getApp(),utils=require("../../../utils/http");
  2. let page=1;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. webUrl:"",
  9. // clientype: app.globalData.clientype,
  10. inforList:[],
  11. datashow:false,
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. this.setData({
  18. clientype: app.globalData.clientype,
  19. webUrl:app.globalData.webUrl+'applet.html#/information?token='+app.globalData.token + '&client_type=' + app.globalData.clientype,
  20. })
  21. wx.showLoading({
  22. title: '加载中...',
  23. })
  24. this.inforfun();
  25. },
  26. /**
  27. * 生命周期函数--监听页面初次渲染完成
  28. */
  29. onReady: function () {
  30. },
  31. inforfun(){
  32. const that=this;
  33. page=1;
  34. utils.$post({
  35. url: app.globalData.webUrl + 'api/user_msg/list',
  36. header: {
  37. 'Authorization': 'bearer ' + app.globalData.token
  38. },
  39. data: {
  40. page: 1,
  41. limit:15
  42. },
  43. success: function (res) {
  44. wx.hideLoading();
  45. if (res.data.code == '0') {
  46. that.setData({
  47. inforList: res.data.data,
  48. datashow:true
  49. })
  50. }
  51. }
  52. })
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {
  58. app.globalData.unreadNum=0;
  59. },
  60. /**
  61. * 生命周期函数--监听页面隐藏
  62. */
  63. onHide: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面卸载
  67. */
  68. onUnload: function () {
  69. },
  70. /**
  71. * 页面相关事件处理函数--监听用户下拉动作
  72. */
  73. onPullDownRefresh: function () {
  74. wx.showLoading({
  75. title: '加载中...',
  76. })
  77. this.inforfun();
  78. wx.stopPullDownRefresh()
  79. },
  80. /**
  81. * 页面上拉触底事件的处理函数
  82. */
  83. onReachBottom: function () {
  84. const that=this;
  85. page=page*1+1;
  86. wx.showLoading({
  87. title: '加载中...',
  88. })
  89. utils.$post({
  90. url: app.globalData.webUrl + 'api/user_msg/list',
  91. header: {
  92. 'Authorization': 'bearer ' + app.globalData.token
  93. },
  94. data: {
  95. page:page,
  96. limit:15
  97. },
  98. success: function (res) {
  99. wx.hideLoading();
  100. let inforList=that.data.inforList;
  101. if (res.data.code == '0') {
  102. inforList=inforList.concat(res.data.data);
  103. that.setData({
  104. inforList:inforList
  105. })
  106. }
  107. }
  108. })
  109. },
  110. /**
  111. * 用户点击右上角分享
  112. */
  113. // onShareAppMessage: function () {
  114. // }
  115. })