index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. const department = profile1List2[0].department.objectId
  64. console.log(department);
  65. let queryWhere = {
  66. where: {
  67. profile: {
  68. $inQuery: {
  69. where: {
  70. department: department
  71. },
  72. className: 'Profile',
  73. },
  74. }
  75. }
  76. }
  77. let Profilequery = Parse.Query.fromJSON('AIMoment', queryWhere);
  78. Profilequery.equalTo('company', company);
  79. Profilequery.equalTo('isVisible', true);
  80. Profilequery.notEqualTo('isDeleted', true)
  81. let P = await Profilequery.find();
  82. let profile1List = P.map(item => item.toJSON());
  83. profile1List.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
  84. console.log(profile1List);
  85. this.setData({
  86. cardList: profile1List
  87. })
  88. },
  89. getcircle2(){
  90. this.setData({
  91. cardList:[]
  92. })
  93. this.getcircle()
  94. },
  95. //跳转
  96. gourl(e) {
  97. const url = e.currentTarget.dataset.url
  98. wx.navigateTo({
  99. url: `${url}`// 目标页面的路径
  100. });
  101. },
  102. }
  103. })