index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // pages/result/index.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. detail: {},
  8. scrollheight: 0
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. if (!options.data) return wx.redirectTo({
  15. url: '/pages/problemPage/index',
  16. })
  17. const detail = JSON.parse(options.data);
  18. const sys = wx.getSystemInfoSync();
  19. const query = wx.createSelectorQuery();
  20. query.selectAll('.getHeight').boundingClientRect(rect => {
  21. let heightAll = 0;
  22. rect.map((currentValue, index, arr) => {
  23. heightAll += currentValue.height
  24. })
  25. this.setData({
  26. scrollheight: sys.windowHeight - heightAll
  27. })
  28. }).exec();
  29. detail.durationText = Math.floor(detail.duration / 3600000);
  30. if (detail.durationText) detail.durationText += "时";
  31. let min = Math.floor(detail.duration % 3600000 / 60000);
  32. if (min) detail.durationText += min + "分";
  33. let s = Math.floor(detail.duration % 60000 / 1000);
  34. if (s) detail.durationText += s + "秒";
  35. this.setData({
  36. detail
  37. })
  38. },
  39. reset() {
  40. wx.reLaunch({
  41. url: '/pages/answer/index?reset=1'
  42. })
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload: function () {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh: function () {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom: function () {
  73. },
  74. /**
  75. * 用户点击右上角分享
  76. */
  77. onShareAppMessage: function () {
  78. }
  79. })