| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- // subpages/textStep/textStep.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- comScoreIndex: 0,
- comScore: 0,
- comScoreDesc: "如果你在这一级别内,那么你的睡眠质量可就亮起红灯了。你必须警惕,因为你的睡眠质量确实比较糟糕,健康状况明显受损。饮食起居会受到一定影响,甚至部分工作你都开始感觉吃力。",
- ratingResultsList: [{
- title: "非常好",
- icon: "/subpages/icons/ic_triangle_down_1.svg",
- color: "#70B3FE"
- }, {
- title: "良好",
- icon: "/subpages/icons/ic_triangle_down_2.svg",
- color: "#68D89E"
- }, {
- title: "一般",
- icon: "/subpages/icons/ic_triangle_down_3.svg",
- color: "#FFA95A"
- }, {
- title: "差",
- icon: "/subpages/icons/ic_triangle_down_4.svg",
- color: "#FC726E"
- }],
- },
- leftBack() {
- wx.navigateBack()
- },
- toTest() {
- // 去测试
- wx.setStorageSync("testType", 'sleep');
- wx.redirectTo({
- url: '/subpages/textStep/textStep?type=sleep'
- })
- },
- toHome() {
- // 回家啦
- wx.removeStorageSync('testType')
- wx.reLaunch({
- url: '/pages/index/index'
- })
- },
- // 分数范围
- judgmentScoreRange(scoreValue, startScore, endScore) {
- return scoreValue >= startScore && scoreValue <= endScore;
- },
- // 描述判断
- judgmentComScoreDesc() {
- var _comScoreDesc = "";
- if (this.judgmentScoreRange(this.data.comScore, 0, 5)) {
- _comScoreDesc = "你目前的睡眠质量非常高,而且健康状况良好,这一切应该继续保持下去。"
- } else if (this.judgmentScoreRange(this.data.comScore, 6, 10)) {
- _comScoreDesc = "你的睡眠质量平平,健康状况也受到影响, 如果再不引起你对睡眠质量的足够重视, 那么你的睡眠质量很可能会迅速下降,向下一级别发展。"
- } else if (this.judgmentScoreRange(this.data.comScore, 11, 15)) {
- _comScoreDesc = "如果你在这一级别内,那么你的睡眠质量可 就亮起红灯了。你必须警惕,因为你的睡眠质量确实比较糟糕,健康状况明显受损。饮食起居会受到一定影响,甚至部分工作你都开始感觉吃力。"
- } else {
- _comScoreDesc = "天啊!你的睡眠质量已经到了令人发指的地 步—长期睡眠不足导致了你的健康状况严重恶化,这就是你工作力不从心,情绪起伏不定的原因。"
- }
- this.setData({
- comScoreDesc: _comScoreDesc
- })
- },
- // 评分判断
- judgmentComScoreIndex() {
- let comScoreIndex = 0;
- let _comScoreStatus = "";
- if (this.data.comScore >= 0 && this.data.comScore <= 5) {
- _comScoreStatus = "非常好";
- } else if (this.data.comScore >= 6 && this.data.comScore <= 10) {
- _comScoreStatus = "良好";
- comScoreIndex = 1;
- } else if (this.data.comScore >= 11 && this.data.comScore <= 15) {
- _comScoreStatus = "一般";
- comScoreIndex = 2;
- } else {
- _comScoreStatus = "差";
- comScoreIndex = 3;
- }
- this.setData({
- comScoreIndex: comScoreIndex
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- // 接收一个分数
- if (options.comScore) {
- this.setData({
- comScore: options.comScore
- })
- }
- this.judgmentComScoreIndex();
- this.judgmentComScoreDesc();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- var that = this;
- return {
- title: '体质诊断检测',
- path: '/subpages/evaluationIntroduction/evaluationIntroduction?type=sleep',
- }
- }
- })
|