index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // nova-werun/components/circle/index.js
  2. const Parse = getApp().Parse;
  3. const company = getApp().globalData.company;
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. },
  10. /**
  11. * 组件的初始数据
  12. */
  13. data: {
  14. //屏幕高度
  15. statusBarHeight: 0, // 状态栏高度
  16. screenHeight: 0, // 屏幕高度
  17. customHeight: 0, // 自定义导航栏高度(如小程序右上角胶囊按钮)
  18. bottomNavHeight: 0, // 底部导航栏高度
  19. contentHeight: 0, // 可用内容高度
  20. contentpadding: 0, //顶部padding高度
  21. navheight:0,//nav栏高度
  22. //朋友圈
  23. cardList: [],
  24. loadedItems: 0, // 已加载的商品数量
  25. pageSize: 6, // 每次加载的商品数量
  26. noMoreItems: false, // 是否还有更多商品
  27. },
  28. lifetimes: {
  29. detached: function () {
  30. // 在组件实例被从页面节点树移除时执行
  31. },
  32. attached: async function () {
  33. // 在组件实例进入页面节点树时执行
  34. // 计算
  35. const systemInfo = wx.getSystemInfoSync();
  36. const statusBarHeight = systemInfo.statusBarHeight || 0;
  37. const screenHeight = systemInfo.screenHeight || 0;
  38. const custom = wx.getMenuButtonBoundingClientRect();
  39. const customHeight = custom.height + 10 + 2 || 0;
  40. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  41. const contentHeight = (screenHeight - 50 - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  42. const navheight = (statusBarHeight+customHeight) * 750 / systemInfo.windowWidth;
  43. this.setData({
  44. statusBarHeight,
  45. screenHeight:(screenHeight-50-bottomNavHeight) * 750 / systemInfo.windowWidth,
  46. customHeight,
  47. bottomNavHeight,
  48. contentHeight,
  49. navheight
  50. });
  51. // console.log('123', contentHeight);
  52. // this.iddepe()
  53. this.getcircle()
  54. },
  55. },
  56. /**
  57. * 组件的方法列表
  58. */
  59. methods: {
  60. //查全部朋友圈
  61. async getcircle() {
  62. // const currentUser = Parse.User.current();
  63. // let Profilequery2 = new Parse.Query('Profile');
  64. // Profilequery2.equalTo('company', company);
  65. // Profilequery2.equalTo('user', currentUser.id);
  66. // Profilequery2.equalTo('isCheck', true);
  67. // Profilequery2.notEqualTo('isDeleted', true)
  68. // let P2 = await Profilequery2.find();
  69. // let profile1List2 = P2.map(item => item.toJSON());
  70. // // console.log(profile1List2);
  71. // const department = profile1List2[0].department.objectId
  72. // // console.log(department);
  73. // let queryWhere = {
  74. // where: {
  75. // profile: {
  76. // $inQuery: {
  77. // where: {
  78. // department: department
  79. // },
  80. // className: 'Profile',
  81. // },
  82. // }
  83. // }
  84. // }
  85. // let Profilequery = Parse.Query.fromJSON('AIMoment', queryWhere);
  86. let Profilequery = new Parse.Query('AIMoment');
  87. Profilequery.equalTo('company', company);
  88. Profilequery.equalTo('isVisible', true);
  89. Profilequery.notEqualTo('isDeleted', true)
  90. Profilequery.descending('createdAt');
  91. // 设置查询的限制和偏移
  92. Profilequery.limit(this.data.pageSize);
  93. Profilequery.skip(this.data.loadedItems);
  94. let P = await Profilequery.find();
  95. let profile1List = P.map(item => item.toJSON());
  96. // 检查是否还有更多商品
  97. if (profile1List.length < this.data.pageSize) {
  98. this.setData({
  99. noMoreItems: true
  100. });
  101. } else {
  102. this.setData({
  103. noMoreItems: false
  104. });
  105. }
  106. this.setData({
  107. cardList: this.data.cardList.concat(profile1List),
  108. loadedItems: this.data.loadedItems + profile1List.length,
  109. })
  110. console.log(this.data.cardList);
  111. },
  112. loadMoreData: async function () {
  113. // 触底时加载更多数据
  114. if (!this.data.noMoreItems) {
  115. await this.getcircle();
  116. }
  117. },
  118. getcircle2() {
  119. this.setData({
  120. cardList: [],
  121. loadedItems:0,
  122. noMoreItems:false
  123. })
  124. console.log('运行了');
  125. this.getcircle()
  126. },
  127. //跳转
  128. gourl(e) {
  129. const url = e.currentTarget.dataset.url
  130. wx.navigateTo({
  131. url: `${url}` // 目标页面的路径
  132. });
  133. },
  134. //判断是否有部门
  135. // async iddepe(){
  136. // const currentUser = Parse.User.current();
  137. // let Profilequery2 = new Parse.Query('Profile');
  138. // Profilequery2.equalTo('company', company);
  139. // Profilequery2.equalTo('user', currentUser.id);
  140. // Profilequery2.equalTo('isCheck', true);
  141. // Profilequery2.notEqualTo('isDeleted', true)
  142. // let P2 = await Profilequery2.first();
  143. // if(P2){
  144. // this.getcircle()
  145. // }else{
  146. // wx.navigateTo({
  147. // url: '../../pages/my/my-profile/index?type='+'资料认证'// 目标页面的路径
  148. // });
  149. // }
  150. // }
  151. }
  152. })