index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // nova-werun/pages/activity/index.js
  2. const Parse = getApp().Parse;
  3. const company = getApp().globalData.company;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. statusBarHeight: 0, // 状态栏高度
  10. screenHeight: 0, // 屏幕高度
  11. customHeight: 0, // 自定义导航栏高度(如小程序右上角胶囊按钮)
  12. bottomNavHeight: 0, // 底部导航栏高度
  13. contentHeight: 0, // 可用内容高度
  14. contentHeight2: 0,
  15. contentpadding: 0, //顶部padding高度
  16. ActivityList:[],
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. // 计算
  23. const systemInfo = wx.getSystemInfoSync();
  24. const statusBarHeight = systemInfo.statusBarHeight || 0;
  25. const screenHeight = systemInfo.screenHeight || 0;
  26. const custom = wx.getMenuButtonBoundingClientRect();
  27. const customHeight = custom.height + 10 + 2 || 0;
  28. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  29. const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
  30. const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  31. this.setData({
  32. statusBarHeight,
  33. screenHeight,
  34. customHeight,
  35. bottomNavHeight,
  36. contentpadding,
  37. contentHeight
  38. });
  39. this.getact()
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload: function () {
  60. },
  61. /**
  62. * 页面相关事件处理函数--监听用户下拉动作
  63. */
  64. onPullDownRefresh: function () {
  65. },
  66. /**
  67. * 页面上拉触底事件的处理函数
  68. */
  69. onReachBottom: function () {
  70. },
  71. /**
  72. * 用户点击右上角分享
  73. */
  74. onShareAppMessage: function () {
  75. },
  76. //活动列表
  77. async getact() {
  78. let Activityquery = new Parse.Query('Activity');
  79. Activityquery.equalTo('company', company);
  80. Activityquery.notEqualTo('isDeleted', true);
  81. Activityquery.equalTo('isEnabled', true);
  82. Activityquery.ascending('index'); // 按index升序排序
  83. let P = await Activityquery.find();
  84. let ActivityList = P.map(item => item.toJSON());
  85. this.setData({
  86. ActivityList,
  87. });
  88. console.log(ActivityList);
  89. },
  90. gourl(e) {
  91. const url = e.currentTarget.dataset.url
  92. const id = e.currentTarget.dataset.id
  93. wx.navigateTo({
  94. url: `${url}?id=` + id // 目标页面的路径
  95. });
  96. },
  97. })