index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // nova-werun/pages/my-circle/index.js
  2. const Parse = getApp().Parse;
  3. const company = getApp().globalData.company;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. //屏幕高度
  10. statusBarHeight: 0, // 状态栏高度
  11. screenHeight: 0, // 屏幕高度
  12. customHeight: 0, // 自定义导航栏高度(如小程序右上角胶囊按钮)
  13. bottomNavHeight: 0, // 底部导航栏高度
  14. contentHeight: 0, // 可用内容高度
  15. contentpadding: 0, //顶部padding高度
  16. //朋友圈
  17. cardList: [],
  18. loadedItems: 0, // 已加载的商品数量
  19. pageSize: 6, // 每次加载的商品数量
  20. noMoreItems: false, // 是否还有更多商品
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. // 计算
  27. const systemInfo = wx.getSystemInfoSync();
  28. const statusBarHeight = systemInfo.statusBarHeight || 0;
  29. const screenHeight = systemInfo.screenHeight || 0;
  30. const custom = wx.getMenuButtonBoundingClientRect();
  31. const customHeight = custom.height + 10 + 2 || 0;
  32. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  33. const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  34. this.setData({
  35. statusBarHeight,
  36. screenHeight,
  37. customHeight,
  38. bottomNavHeight,
  39. contentHeight
  40. });
  41. console.log('123', contentHeight);
  42. this.getcircle()
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload: function () {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh: function () {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom: function () {
  73. },
  74. /**
  75. * 用户点击右上角分享
  76. */
  77. onShareAppMessage: function () {
  78. },
  79. //查全部朋友圈
  80. async getcircle() {
  81. const currentUser = Parse.User.current();
  82. // let Profilequery2 = new Parse.Query('Profile');
  83. // Profilequery2.equalTo('company', company);
  84. // Profilequery2.equalTo('user', currentUser.id);
  85. // Profilequery2.equalTo('isCheck', true);
  86. // Profilequery2.notEqualTo('isDeleted', true)
  87. // let P2 = await Profilequery2.find();
  88. // let profile1List2 = P2.map(item => item.toJSON());
  89. let Profilequery = new Parse.Query('AIMoment');
  90. Profilequery.equalTo('company', company);
  91. // Profilequery.equalTo('isVisible', true);
  92. Profilequery.notEqualTo('isDeleted', true)
  93. // Profilequery.equalTo('profile', profile1List2[0].objectId);
  94. Profilequery.equalTo('user', currentUser.id);
  95. Profilequery.include('user');
  96. Profilequery.descending('createdAt');
  97. // 设置查询的限制和偏移
  98. Profilequery.limit(this.data.pageSize);
  99. Profilequery.skip(this.data.loadedItems);
  100. let P = await Profilequery.find();
  101. let profile1List = P.map(item => item.toJSON());
  102. // 检查是否还有更多商品
  103. if (profile1List.length < this.data.pageSize) {
  104. this.setData({
  105. noMoreItems: true
  106. });
  107. } else {
  108. this.setData({
  109. noMoreItems: false
  110. });
  111. }
  112. this.setData({
  113. cardList: this.data.cardList.concat(profile1List),
  114. loadedItems: this.data.loadedItems + profile1List.length
  115. })
  116. console.log(this.data.cardList);
  117. },
  118. loadMoreData: async function () {
  119. // 触底时加载更多数据
  120. if (!this.data.noMoreItems) {
  121. await this.getcircle();
  122. }
  123. },
  124. })