index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. },
  54. },
  55. /**
  56. * 组件的方法列表
  57. */
  58. methods: {
  59. //查全部朋友圈
  60. async getcircle() {
  61. const currentUser = Parse.User.current();
  62. let Profilequery2 = new Parse.Query('Profile');
  63. Profilequery2.equalTo('company', company);
  64. Profilequery2.equalTo('user', currentUser.id);
  65. Profilequery2.equalTo('isCheck', true);
  66. Profilequery2.notEqualTo('isDeleted', true)
  67. let P2 = await Profilequery2.find();
  68. let profile1List2 = P2.map(item => item.toJSON());
  69. // console.log(profile1List2);
  70. const department = profile1List2[0].department.objectId
  71. // console.log(department);
  72. let queryWhere = {
  73. where: {
  74. profile: {
  75. $inQuery: {
  76. where: {
  77. department: department
  78. },
  79. className: 'Profile',
  80. },
  81. }
  82. }
  83. }
  84. let Profilequery = Parse.Query.fromJSON('AIMoment', queryWhere);
  85. Profilequery.equalTo('company', company);
  86. Profilequery.equalTo('isVisible', true);
  87. Profilequery.notEqualTo('isDeleted', true)
  88. Profilequery.descending('createdAt');
  89. // 设置查询的限制和偏移
  90. Profilequery.limit(this.data.pageSize);
  91. Profilequery.skip(this.data.loadedItems);
  92. let P = await Profilequery.find();
  93. let profile1List = P.map(item => item.toJSON());
  94. // 检查是否还有更多商品
  95. if (profile1List.length < this.data.pageSize) {
  96. this.setData({
  97. noMoreItems: true
  98. });
  99. } else {
  100. this.setData({
  101. noMoreItems: false
  102. });
  103. }
  104. this.setData({
  105. cardList: this.data.cardList.concat(profile1List),
  106. loadedItems: this.data.loadedItems + profile1List.length,
  107. })
  108. console.log(this.data.cardList);
  109. },
  110. loadMoreData: async function () {
  111. // 触底时加载更多数据
  112. if (!this.data.noMoreItems) {
  113. await this.getcircle();
  114. }
  115. },
  116. getcircle2() {
  117. this.setData({
  118. cardList: [],
  119. loadedItems:0,
  120. noMoreItems:false
  121. })
  122. console.log('运行了');
  123. this.getcircle()
  124. },
  125. //跳转
  126. gourl(e) {
  127. const url = e.currentTarget.dataset.url
  128. wx.navigateTo({
  129. url: `${url}` // 目标页面的路径
  130. });
  131. },
  132. //判断是否有部门
  133. async iddepe(){
  134. const currentUser = Parse.User.current();
  135. let Profilequery2 = new Parse.Query('Profile');
  136. Profilequery2.equalTo('company', company);
  137. Profilequery2.equalTo('user', currentUser.id);
  138. Profilequery2.equalTo('isCheck', true);
  139. Profilequery2.notEqualTo('isDeleted', true)
  140. let P2 = await Profilequery2.first();
  141. if(P2){
  142. this.getcircle()
  143. }else{
  144. wx.navigateTo({
  145. url: '../../pages/my/my-profile/index'// 目标页面的路径
  146. });
  147. }
  148. }
  149. }
  150. })