柒零 1 anno fa
parent
commit
606968cff2

+ 44 - 0
subpages/sleepReport/sleepReport.js

@@ -165,6 +165,48 @@ Page({
       minutes: minutes || 0
     }
   },
+  checkRScoreValueColor(value) {
+    var checkList = [{
+      title: "极好",
+      titleColor: "#0BC3AA",
+      startColor: "#0AB1C3",
+      centerColor: "#0BC3AA",
+      endColor: "#36E1CA",
+    }, {
+      title: "良好",
+      titleColor: "#9C43FF",
+      startColor: "#8D25FF",
+      centerColor: "#A631FF",
+      endColor: "#FF8FF0",
+    }, {
+      title: "较差",
+      titleColor: "#FF8F4E",
+      startColor: "#EE8B52",
+      centerColor: "#FAA472",
+      endColor: "#FAA472",
+    }, {
+      title: "很差",
+      titleColor: "#FB717B",
+      startColor: "#FB717B",
+      centerColor: "#FB717B",
+      endColor: "#FF98A0",
+      }];
+
+    var color = checkList[0].titleColor;
+    var rscore_value = value - 0;
+    if (rscore_value >= 90 && rscore_value <= 100) {
+      color = checkList[0].titleColor;
+    } else if (rscore_value >= 75 && rscore_value < 90) {
+      color = checkList[1].titleColor;
+    } else if (rscore_value >= 60 && rscore_value < 75) {
+      color = checkList[2].titleColor;
+    } else {
+      color = checkList[3].titleColor;
+    }
+
+    return color;
+    
+  },
   getList(startdateStr, enddateStr) {
     const that = this;
     wx.request({
@@ -194,8 +236,10 @@ Page({
                   for (let i = 0; i < subElement.length; i++) {
                     var item = subElement[i];
                     var dateItem = that.checkTime(item.rinbed_duration);
+                    var color = that.checkRScoreValueColor(item.rscore_value);
                     item.hours = dateItem.hours;
                     item.minutes = dateItem.minutes;
+                    item.color = color;
                   }
                   subItems = subItems.concat(subElement);
                 }

+ 1 - 1
subpages/sleepReport/sleepReport.wxml

@@ -16,7 +16,7 @@
                     <text class="desc">睡眠时间</text>
                 </view>
                 <view class="v-item">
-                    <text class="t3">{{subItem.rscore_value}}</text>
+                    <text class="t3" style="color:{{subItem.color}};">{{subItem.rscore_value}}</text>
                     <text class="desc">香睡指数</text>
                 </view>
                 <view class="v-item">

+ 1 - 0
subpages/sleepReport/sleepReport.wxss

@@ -71,6 +71,7 @@
 }
 
 .v-item {
+    flex: 1;
     display: flex;
     height: 190rpx;
     justify-content: center;