根据“图标代码对照表”修改天气视图,现在会返回正确的天气icon图片 12/1 12/head
authorluozheng <1732036298@qq.com>
Tue, 16 Apr 2024 02:19:21 +0000 (10:19 +0800)
committerluozheng <1732036298@qq.com>
Tue, 16 Apr 2024 02:19:21 +0000 (10:19 +0800)
code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h
code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp

index da73169..b3fa377 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-08 18:40:20
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-15 14:45:55
+ * @LastEditTime: 2024-04-16 09:57:34
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h
  */
 #ifndef WEATHER_MODEL_H
@@ -64,18 +64,20 @@ namespace OHOS
 #define weather_src "/user/res/weather/weather65x65/"
     static const char *weather65x65[] =
         {
-            weather_src "weather_sunny.bin",        // 晴天
-            weather_src "weather_clear-cloudy.bin", // 多云
-            weather_src "weather_rain.bin",         // 阵雨
-            weather_src "weather_thundershower.bin",
-            weather_src "weather_foggy.bin",
-            weather_src "weather_unknown.bin",
-            weather_src "weather_overcast.bin",
-            weather_src "weather_clear-sunny.bin",
-            weather_src "weather_duststorm.bin",
-            weather_src "weather_haze.bin",
-            weather_src "weather_snow.bin",
-            weather_src "weather_sunny-cloudy.bin",
+            weather_src "weather_placeholder.bin",   // 占位或默认
+            weather_src "weather_sunny.bin",         // 晴(白天)
+            weather_src "weather_clear-sunny.bin",   // 晴(晚上)
+            weather_src "weather_sunny-cloudy.bin",  // 多云(白天)
+            weather_src "weather_clear-cloudy.bin",  // 多云(晚上)
+            weather_src "weather_overcast.bin",      // 阴
+            weather_src "weather_rain.bin",          // 阵雨
+            weather_src "weather_thundershower.bin", // 雷雨
+            weather_src "weather_snow.bin",          // 雪
+            weather_src "weather_foggy.bin",         // 雾
+            weather_src "weather_haze.bin",          // 霾
+            weather_src "weather_duststorm.bin",     // 沙尘暴
+            weather_src "weather_unknown.bin",       // 未知
+
     };
     /* -------------------------------------------------------------------------- */
     class WeatherModel
index 987f0af..daa9e56 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-08 18:40:09
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-15 15:16:06
+ * @LastEditTime: 2024-04-16 09:48:10
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp
  */
 #include "weather/include/WeatherModel.h"
@@ -83,18 +83,18 @@ namespace OHOS
     }
 #endif /* __cplusplus */
 
-    // static constexpr const char json_data[] =
-    //     "{\"now\": {\"humidity\":89,\"windScale\":\"2\",\"textNight\":\"多云\",\"uvIndex\":3,\"temp\":24,\"iconNight\":4},"
-    //     "\"address\": {\"lat\":225737664,\"atm\":\"1010\",\"city\":\"深圳\",\"subLocality\":\"宝安\",\"lon\":1138535138},"
-    //     "\"daily\": [{\"tempMin\":22,\"iconDay\":6,\"fxDate\":1712505600,\"textDay\":\"阵雨\",\"tempMax\":29},"
-    //     "{\"tempMax\":27,\"textDay\":\"多云\",\"iconDay\":3,\"fxDate\":1712592000,\"tempMin\":22},"
-    //     "{\"tempMax\":29,\"fxDate\":1712678400,\"textDay\":\"多云\",\"iconDay\":3,\"tempMin\":22},"
-    //     "{\"tempMin\":23,\"textDay\":\"多云\",\"fxDate\":1712764800,\"tempMax\":30,\"iconDay\":3},"
-    //     "{\"fxDate\":1712851200,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":31,\"tempMin\":24},"
-    //     "{\"fxDate\":1712937600,\"iconDay\":3,\"tempMax\":31,\"tempMin\":24,\"textDay\":\"多云\"},"
-    //     "{\"fxDate\":1713024000,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":29,\"tempMin\":25}],"
-    //     "\"code\":1}";
-    static constexpr const char json_data[2048] = "{\"now\":{\"humidity\":89,\"windScale\":\"2\",\"textNight\":\"多云\",\"uvIndex\":3,\"temp\":24,\"iconNight\":4},\"address\":{\"lat\":225737664,\"atm\":\"1010\",\"city\":\"深圳\",\"subLocality\":\"宝安\",\"lon\":1138535138},\"daily\":[{\"tempMin\":22,\"iconDay\":6,\"fxDate\":1712505600,\"textDay\":\"阵雨\",\"tempMax\":29},{\"tempMax\":27,\"textDay\":\"多云\",\"iconDay\":3,\"fxDate\":1712592000,\"tempMin\":22},{\"tempMax\":29,\"fxDate\":1712678400,\"textDay\":\"多云\",\"iconDay\":3,\"tempMin\":22},{\"tempMin\":23,\"textDay\":\"多云\",\"fxDate\":1712764800,\"tempMax\":30,\"iconDay\":3},{\"fxDate\":1712851200,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":31,\"tempMin\":24},{\"fxDate\":1712937600,\"iconDay\":3,\"tempMax\":31,\"tempMin\":24,\"textDay\":\"多云\"},{\"fxDate\":1713024000,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":29,\"tempMin\":25}],\"code\":1}";
+    static constexpr const char json_data[] =
+        "{\"now\": {\"humidity\":89,\"windScale\":\"2\",\"textNight\":\"多云\",\"uvIndex\":3,\"temp\":24,\"iconNight\":4},"
+        "\"address\": {\"lat\":225737664,\"atm\":\"1010\",\"city\":\"深圳\",\"subLocality\":\"宝安\",\"lon\":1138535138},"
+        "\"daily\": [{\"tempMin\":22,\"iconDay\":6,\"fxDate\":1712505600,\"textDay\":\"阵雨\",\"tempMax\":29},"
+        "{\"tempMax\":27,\"textDay\":\"多云\",\"iconDay\":3,\"fxDate\":1712592000,\"tempMin\":22},"
+        "{\"tempMax\":29,\"fxDate\":1712678400,\"textDay\":\"多云\",\"iconDay\":3,\"tempMin\":22},"
+        "{\"tempMin\":23,\"textDay\":\"多云\",\"fxDate\":1712764800,\"tempMax\":30,\"iconDay\":3},"
+        "{\"fxDate\":1712851200,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":31,\"tempMin\":24},"
+        "{\"fxDate\":1712937600,\"iconDay\":3,\"tempMax\":31,\"tempMin\":24,\"textDay\":\"多云\"},"
+        "{\"fxDate\":1713024000,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":29,\"tempMin\":25}],"
+        "\"code\":1}";
+    //static constexpr const char json_data[] = "{\"now\":{\"humidity\":89,\"windScale\":\"2\",\"textNight\":\"多云\",\"uvIndex\":3,\"temp\":24,\"iconNight\":4},\"address\":{\"lat\":225737664,\"atm\":\"1010\",\"city\":\"深圳\",\"subLocality\":\"宝安\",\"lon\":1138535138},\"daily\":[{\"tempMin\":22,\"iconDay\":6,\"fxDate\":1712505600,\"textDay\":\"阵雨\",\"tempMax\":29},{\"tempMax\":27,\"textDay\":\"多云\",\"iconDay\":3,\"fxDate\":1712592000,\"tempMin\":22},{\"tempMax\":29,\"fxDate\":1712678400,\"textDay\":\"多云\",\"iconDay\":3,\"tempMin\":22},{\"tempMin\":23,\"textDay\":\"多云\",\"fxDate\":1712764800,\"tempMax\":30,\"iconDay\":3},{\"fxDate\":1712851200,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":31,\"tempMin\":24},{\"fxDate\":1712937600,\"iconDay\":3,\"tempMax\":31,\"tempMin\":24,\"textDay\":\"多云\"},{\"fxDate\":1713024000,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":29,\"tempMin\":25}],\"code\":1}";
     /* -------------------------------------------------------------------------- */
     uint8_t WeatherModel::WEATHER_DATA_VALID = 0;
     WeatherModel::WeatherModel()