index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // nova-werun/pages/home/step/index.js
  2. const Parse = getApp().Parse;
  3. const company = getApp().globalData.company;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. //屏幕高度
  10. statusBarHeight: 0, // 状态栏高度
  11. screenHeight: 0, // 屏幕高度
  12. customHeight: 0, // 自定义导航栏高度(如小程序右上角胶囊按钮)
  13. bottomNavHeight: 0, // 底部导航栏高度
  14. contentHeight: 0, // 可用内容高度
  15. navheight: 0,
  16. radio: '5000',
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. const systemInfo = wx.getSystemInfoSync();
  23. const statusBarHeight = systemInfo.statusBarHeight || 0;
  24. const screenHeight = systemInfo.screenHeight || 0;
  25. const custom = wx.getMenuButtonBoundingClientRect();
  26. const customHeight = custom.height + 10 + 2 || 0;
  27. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  28. const navheight = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
  29. const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  30. this.setData({
  31. statusBarHeight,
  32. screenHeight,
  33. customHeight,
  34. bottomNavHeight,
  35. contentHeight,
  36. navheight
  37. });
  38. },
  39. /**
  40. * 生命周期函数--监听页面初次渲染完成
  41. */
  42. onReady: function () {
  43. },
  44. /**
  45. * 生命周期函数--监听页面显示
  46. */
  47. onShow: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面隐藏
  51. */
  52. onHide: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面卸载
  56. */
  57. onUnload: function () {
  58. },
  59. /**
  60. * 页面相关事件处理函数--监听用户下拉动作
  61. */
  62. onPullDownRefresh: function () {
  63. },
  64. /**
  65. * 页面上拉触底事件的处理函数
  66. */
  67. onReachBottom: function () {
  68. },
  69. /**
  70. * 用户点击右上角分享
  71. */
  72. onShareAppMessage: function () {
  73. },
  74. //点击返回
  75. goback() {
  76. // if(!this.data.saveimage){
  77. // let pages = getCurrentPages(); //页面对象
  78. // console.log(pages);
  79. // let prevpage = pages[pages.length - 2]; //上一个页面对象
  80. // console.log(prevpage);
  81. // await prevpage.updateCom()
  82. // }
  83. wx.navigateBack({
  84. delta: 1
  85. });
  86. },
  87. onChange(event) {
  88. this.setData({
  89. radio: event.detail,
  90. });
  91. console.log(this.data.radio);
  92. },
  93. async submit() {
  94. const currentUser2 = Parse.User.current();
  95. let userquery2 = new Parse.Query('_User');
  96. userquery2.equalTo('company', company);
  97. userquery2.equalTo('objectId', currentUser2.id);
  98. userquery2.notEqualTo('isDeleted', true)
  99. let user2 = await userquery2.first();
  100. user2.set('num', Number(this.data.radio))
  101. try {
  102. let saveDate2 = await user2.save();
  103. console.log(saveDate2);
  104. let pages = getCurrentPages(); //页面对象
  105. console.log(pages);
  106. let prevpage = pages[pages.length - 2]; //上一个页面对象
  107. console.log(prevpage);
  108. await prevpage.updateCom2()
  109. wx.navigateBack({
  110. delta: 1
  111. });
  112. console.log("目标步数更改成功");
  113. } catch (error) {
  114. console.error("保存数据时出现错误:", error);
  115. }
  116. }
  117. })