testResultA.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. // subpages/textStep/textStep.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. comScoreIndex: 0,
  8. comScore: 0,
  9. comScoreDesc: "如果你在这一级别内,那么你的睡眠质量可就亮起红灯了。你必须警惕,因为你的睡眠质量确实比较糟糕,健康状况明显受损。饮食起居会受到一定影响,甚至部分工作你都开始感觉吃力。",
  10. ratingResultsList: [{
  11. title: "非常好",
  12. icon: "/subpages/icons/ic_triangle_down_1.svg",
  13. color: "#70B3FE"
  14. }, {
  15. title: "良好",
  16. icon: "/subpages/icons/ic_triangle_down_2.svg",
  17. color: "#68D89E"
  18. }, {
  19. title: "一般",
  20. icon: "/subpages/icons/ic_triangle_down_3.svg",
  21. color: "#FFA95A"
  22. }, {
  23. title: "差",
  24. icon: "/subpages/icons/ic_triangle_down_4.svg",
  25. color: "#FC726E"
  26. }],
  27. },
  28. leftBack() {
  29. wx.navigateBack()
  30. },
  31. toTest() {
  32. // 去测试
  33. wx.setStorageSync("testType", 'sleep');
  34. wx.redirectTo({
  35. url: '/subpages/textStep/textStep?type=sleep'
  36. })
  37. },
  38. toHome() {
  39. // 回家啦
  40. wx.removeStorageSync('testType')
  41. wx.reLaunch({
  42. url: '/pages/index/index'
  43. })
  44. },
  45. // 分数范围
  46. judgmentScoreRange(scoreValue, startScore, endScore) {
  47. return scoreValue >= startScore && scoreValue <= endScore;
  48. },
  49. // 描述判断
  50. judgmentComScoreDesc() {
  51. var _comScoreDesc = "";
  52. if (this.judgmentScoreRange(this.data.comScore, 0, 5)) {
  53. _comScoreDesc = "你目前的睡眠质量非常高,而且健康状况良好,这一切应该继续保持下去。"
  54. } else if (this.judgmentScoreRange(this.data.comScore, 6, 10)) {
  55. _comScoreDesc = "你的睡眠质量平平,健康状况也受到影响, 如果再不引起你对睡眠质量的足够重视, 那么你的睡眠质量很可能会迅速下降,向下一级别发展。"
  56. } else if (this.judgmentScoreRange(this.data.comScore, 11, 15)) {
  57. _comScoreDesc = "如果你在这一级别内,那么你的睡眠质量可 就亮起红灯了。你必须警惕,因为你的睡眠质量确实比较糟糕,健康状况明显受损。饮食起居会受到一定影响,甚至部分工作你都开始感觉吃力。"
  58. } else {
  59. _comScoreDesc = "天啊!你的睡眠质量已经到了令人发指的地 步—长期睡眠不足导致了你的健康状况严重恶化,这就是你工作力不从心,情绪起伏不定的原因。"
  60. }
  61. this.setData({
  62. comScoreDesc: _comScoreDesc
  63. })
  64. },
  65. // 评分判断
  66. judgmentComScoreIndex() {
  67. let comScoreIndex = 0;
  68. let _comScoreStatus = "";
  69. if (this.data.comScore >= 0 && this.data.comScore <= 5) {
  70. _comScoreStatus = "非常好";
  71. } else if (this.data.comScore >= 6 && this.data.comScore <= 10) {
  72. _comScoreStatus = "良好";
  73. comScoreIndex = 1;
  74. } else if (this.data.comScore >= 11 && this.data.comScore <= 15) {
  75. _comScoreStatus = "一般";
  76. comScoreIndex = 2;
  77. } else {
  78. _comScoreStatus = "差";
  79. comScoreIndex = 3;
  80. }
  81. this.setData({
  82. comScoreIndex: comScoreIndex
  83. })
  84. },
  85. /**
  86. * 生命周期函数--监听页面加载
  87. */
  88. onLoad(options) {
  89. // 接收一个分数
  90. if (options.comScore) {
  91. this.setData({
  92. comScore: options.comScore
  93. })
  94. }
  95. this.judgmentComScoreIndex();
  96. this.judgmentComScoreDesc();
  97. },
  98. /**
  99. * 生命周期函数--监听页面初次渲染完成
  100. */
  101. onReady() {
  102. },
  103. /**
  104. * 生命周期函数--监听页面显示
  105. */
  106. onShow() {
  107. },
  108. /**
  109. * 生命周期函数--监听页面隐藏
  110. */
  111. onHide() {
  112. },
  113. /**
  114. * 生命周期函数--监听页面卸载
  115. */
  116. onUnload() {
  117. },
  118. /**
  119. * 页面相关事件处理函数--监听用户下拉动作
  120. */
  121. onPullDownRefresh() {
  122. },
  123. /**
  124. * 页面上拉触底事件的处理函数
  125. */
  126. onReachBottom() {
  127. },
  128. /**
  129. * 用户点击右上角分享
  130. */
  131. onShareAppMessage() {
  132. var that = this;
  133. return {
  134. title: '体质诊断检测',
  135. path: '/subpages/evaluationIntroduction/evaluationIntroduction?type=sleep',
  136. }
  137. }
  138. })