xieruidong 2 years ago
parent
commit
d943dcbac2
1 changed files with 7 additions and 2 deletions
  1. 7 2
      app/data/service/WeatherSvc.php

+ 7 - 2
app/data/service/WeatherSvc.php

@@ -128,8 +128,13 @@ class WeatherSvc extends Service
             $now['category']=$airQuality['category']??'优';
             $now['aqi']=$airQuality['aqi']??'22';
             $now['obsTime']=Carbon::parse($now['obsTime'])->format('m-d H:i');
-            $now['tempMin']=$now['temp'];
-            $now['tempMax']=$now['temp']+mt_rand(1,5);
+            if(isset($daily[0])){
+                $now['tempMin'] = $daily[0]['tempMin'];
+                $now['tempMax'] = $daily[0]['tempMax'];
+            }else {
+                $now['tempMin'] = $now['temp'];
+                $now['tempMax'] = $now['temp'] + mt_rand(1, 5);
+            }
         }
         return compact('hourly','daily','index','now');
     }