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 = "";
  30. let h = Math.floor(detail.duration / 3600000);
  31. if (h) detail.durationText += h + "时";
  32. let min = Math.floor(detail.duration % 3600000 / 60000);
  33. if (min) detail.durationText += min + "分";
  34. let s = Math.floor(detail.duration % 60000 / 1000);
  35. if (s) detail.durationText += s + "秒";
  36. this.setData({
  37. detail
  38. })
  39. },
  40. reset() {
  41. wx.reLaunch({
  42. url: '/pages/answer/index?reset=1'
  43. })
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面卸载
  62. */
  63. onUnload: function () {
  64. },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh: function () {
  69. },
  70. /**
  71. * 页面上拉触底事件的处理函数
  72. */
  73. onReachBottom: function () {
  74. },
  75. /**
  76. * 用户点击右上角分享
  77. */
  78. onShareAppMessage: function () {
  79. }
  80. })