index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // nova-werun/pages/activity/detail-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. objectId: "",
  17. activity:{},
  18. active:0,
  19. showpopup:false,
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. // 计算
  26. const systemInfo = wx.getSystemInfoSync();
  27. const statusBarHeight = systemInfo.statusBarHeight || 0;
  28. const screenHeight = systemInfo.screenHeight || 0;
  29. const custom = wx.getMenuButtonBoundingClientRect();
  30. const customHeight = custom.height + 10 + 2 || 0;
  31. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  32. const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
  33. const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  34. this.setData({
  35. statusBarHeight,
  36. screenHeight,
  37. customHeight,
  38. bottomNavHeight,
  39. contentpadding,
  40. contentHeight
  41. });
  42. this.setData({
  43. objectId: options.id
  44. })
  45. console.log(this.data.objectId);
  46. this.getactivity()
  47. },
  48. /**
  49. * 生命周期函数--监听页面初次渲染完成
  50. */
  51. onReady: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面显示
  55. */
  56. onShow: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面隐藏
  60. */
  61. onHide: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面卸载
  65. */
  66. onUnload: function () {
  67. },
  68. /**
  69. * 页面相关事件处理函数--监听用户下拉动作
  70. */
  71. onPullDownRefresh: function () {
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom: function () {
  77. },
  78. /**
  79. * 用户点击右上角分享
  80. */
  81. onShareAppMessage: function () {
  82. },
  83. //获取活动详细信息
  84. async getactivity() {
  85. let Activityquery = new Parse.Query('Activity');
  86. Activityquery.equalTo('company', company);
  87. Activityquery.equalTo('objectId', this.data.objectId);
  88. Activityquery.notEqualTo('isDeleted', true);
  89. Activityquery.equalTo('isEnabled', true);
  90. let P = await Activityquery.find();
  91. let activity = P.map(item => item.toJSON());
  92. this.setData({
  93. activity:activity[0]
  94. })
  95. console.log(this.data.activity);
  96. },
  97. //切换
  98. async changeTab(e) {
  99. if (e.detail.name == 1) {
  100. this.getactivity()
  101. }
  102. this.setData({
  103. active: e.detail.name
  104. })
  105. console.log(this.data.active);
  106. },
  107. open(){
  108. this.setData({
  109. showpopup:true,
  110. })
  111. },
  112. onClose(){
  113. this.setData({
  114. showpopup:false,
  115. })
  116. }
  117. })