index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. console.log(sys);
  20. const query = wx.createSelectorQuery();
  21. query.selectAll('.getHeight').boundingClientRect(rect => {
  22. let heightAll = 0;
  23. rect.map((currentValue, index, arr) => {
  24. heightAll += currentValue.height
  25. })
  26. this.setData({
  27. scrollheight: sys.windowHeight - heightAll
  28. })
  29. }).exec();
  30. detail.durationText = Math.floor(detail.duration / 3600000);
  31. if (detail.durationText) detail.durationText += "时";
  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. })