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