index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. //朋友圈
  22. cardList: [],
  23. },
  24. lifetimes: {
  25. detached: function () {
  26. // 在组件实例被从页面节点树移除时执行
  27. },
  28. attached: async function () {
  29. // 在组件实例进入页面节点树时执行
  30. // 计算
  31. const systemInfo = wx.getSystemInfoSync();
  32. const statusBarHeight = systemInfo.statusBarHeight || 0;
  33. const screenHeight = systemInfo.screenHeight || 0;
  34. const custom = wx.getMenuButtonBoundingClientRect();
  35. const customHeight = custom.height + 10 + 2 || 0;
  36. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  37. const contentHeight = (screenHeight - 50 - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  38. this.setData({
  39. statusBarHeight,
  40. screenHeight,
  41. customHeight,
  42. bottomNavHeight,
  43. contentHeight
  44. });
  45. console.log('123', contentHeight);
  46. this.getcircle()
  47. },
  48. },
  49. /**
  50. * 组件的方法列表
  51. */
  52. methods: {
  53. //查全部朋友圈
  54. async getcircle() {
  55. const currentUser = Parse.User.current();
  56. let Profilequery2 = new Parse.Query('Profile');
  57. Profilequery2.equalTo('company', company);
  58. Profilequery2.equalTo('user', currentUser.id);
  59. Profilequery2.equalTo('isCheck', true);
  60. Profilequery2.notEqualTo('isDeleted', true)
  61. let P2 = await Profilequery2.find();
  62. let profile1List2 = P2.map(item => item.toJSON());
  63. console.log(profile1List2);
  64. const department = profile1List2[0].department.objectId
  65. console.log(department);
  66. let queryWhere = {
  67. where: {
  68. profile: {
  69. $inQuery: {
  70. where: {
  71. department: department
  72. },
  73. className: 'Profile',
  74. },
  75. }
  76. }
  77. }
  78. let Profilequery = Parse.Query.fromJSON('AIMoment', queryWhere);
  79. Profilequery.equalTo('company', company);
  80. Profilequery.equalTo('isVisible', true);
  81. Profilequery.notEqualTo('isDeleted', true)
  82. let P = await Profilequery.find();
  83. let profile1List = P.map(item => item.toJSON());
  84. profile1List.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
  85. console.log(profile1List);
  86. this.setData({
  87. cardList: profile1List
  88. })
  89. },
  90. getcircle2(){
  91. this.setData({
  92. cardList:[]
  93. })
  94. this.getcircle()
  95. },
  96. //跳转
  97. gourl(e) {
  98. const url = e.currentTarget.dataset.url
  99. wx.navigateTo({
  100. url: `${url}`// 目标页面的路径
  101. });
  102. },
  103. }
  104. })