zjk
2026-04-25 1e2c59f41fc39e1e3e1c6b0eaad7fa5f4a0f067d
feat(天气): 新增天气图标并支持温度单位配置

- 为不同天气条件添加专用图标,提升视觉辨识度
- 从配置接口获取温度单位并动态显示
- 修复首次进入活动接口的URL路径错误
8个文件已添加
3个文件已修改
36 ■■■■■ 已修改文件
src/pages/robotaxi/home/index.tsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/api/home.ts 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/assets/cloudy.png 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/assets/fog.png 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/assets/rain.png 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/assets/sandDust.png 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/assets/snow.png 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/assets/sunny.png 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/assets/thundershower.png 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/assets/wind.png 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/weather.ts 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/robotaxi/home/index.tsx
@@ -151,6 +151,7 @@
  const [orderData, setOrderData] = useState<any>({}); // 订单数据
  const [isLogin, setIsLogin] = useState(false); // 是否登录
  const [overlayAnchorBottom, setOverlayAnchorBottom] = useState<number | null>(null); // 浮层初始化锚点(距底部)
  const [temperatureUnit, setTemperatureUnit] = useState('℃'); // 温度单位
  const {
    boxHeight,
    originOpacity,
@@ -221,6 +222,9 @@
    getOrderDistance().then((res: any) => {
      if (res && res.adsorptionDistance) {
        setAdsorptionDistance(res.adsorptionDistance);
      }
      if (res && res.temperatureUnit) {
        setTemperatureUnit(res.temperatureUnit);
      }
    }).catch(err => {
      console.error('获取吸附距离失败', err);
@@ -579,7 +583,7 @@
          {weatherData && (
            <View className="weather-info" onClick={() => setShowMarketing(true)}>
              <Image className="weather-icon" src={getWeatherIconByDesc(weatherData.weather)} />
              <Text>{weatherData.temperature}°C</Text>
              <Text>{weatherData.temperature}{temperatureUnit ? `(${temperatureUnit})` : '℃'}</Text>
            </View>
          )}
        </View>
src/robotaxi/api/home.ts
@@ -114,7 +114,7 @@
// 第一次进入应用
export const firstEnter = async () => {
    return request({
        url: _ROBOTAXI_HOST + '/operation/v1/api/mini-program/acticity/firstEnter',
        url: _ROBOTAXI_HOST + '/operation/api/v1/mini-program/acticity/firstEnter',
        method: 'GET'
    }, true);
}
src/robotaxi/assets/cloudy.png
src/robotaxi/assets/fog.png
src/robotaxi/assets/rain.png
src/robotaxi/assets/sandDust.png
src/robotaxi/assets/snow.png
src/robotaxi/assets/sunny.png
src/robotaxi/assets/thundershower.png
src/robotaxi/assets/wind.png
src/utils/weather.ts
@@ -1,4 +1,12 @@
import weatherIcon from '../robotaxi/assets/weather.png';
import windIcon from '../robotaxi/assets/wind.png';
import sunnyIcon from '../robotaxi/assets/sunny.png';
import cloudIcon from '../robotaxi/assets/sandDust.png';
import rainIcon from '../robotaxi/assets/rain.png';
import snowIcon from '../robotaxi/assets/snow.png';
import thunderstormIcon from '../robotaxi/assets/thundershower.png';
import fogIcon from '../robotaxi/assets/fog.png';
import cloudyIcon from '../robotaxi/assets/cloudy.png';
/**
 * 根据高德天气返回的天气描述,匹配系统定义的天气图标。
@@ -12,43 +20,43 @@
  // 雷阵雨/冰雹
  if (['雷阵雨', '强雷阵雨', '雷阵雨并伴有冰雹'].includes(weatherDesc)) {
    return weatherIcon;
    return thunderstormIcon;
  }
  // 大雨/暴雨
  if (['大雨', '暴雨', '大暴雨', '特大暴雨', '强阵雨', '极端降雨', '中雨-大雨', '大雨-暴雨', '暴雨-大暴雨', '大暴雨-特大暴雨'].includes(weatherDesc)) {
    return weatherIcon;
    return rainIcon;
  }
  // 小雨/中雨
  if (['阵雨', '小雨', '中雨', '毛毛雨/细雨', '雨', '小雨-中雨', '阵雨天气'].includes(weatherDesc)) {
    return weatherIcon;
    return rainIcon;
  }
  // 雪
  if (['雪', '阵雪', '小雪', '中雪', '大雪', '暴雪', '小雪-中雪', '中雪-大雪', '大雪-暴雪'].includes(weatherDesc)) {
    return weatherIcon;
    return snowIcon;
  }
  // 雨夹雪
  if (['雨夹雪', '阵雨夹雪', '雨雪天气', '冻雨'].includes(weatherDesc)) {
    return weatherIcon;
    return snowIcon;
  }
  // 沙尘/浮尘
  if (['浮尘', '扬沙', '沙尘暴', '强沙尘暴'].includes(weatherDesc)) {
    return weatherIcon;
    return cloudIcon;
  }
  // 雾/霾
  if (['雾', '浓雾', '强浓雾', '轻雾', '大雾', '特强浓雾', '霾', '中度霾', '重度霾', '严重霾'].includes(weatherDesc)) {
    return weatherIcon;
    return fogIcon;
  }
  // 大风/台风
  if (['有风', '和风', '微风', '清风', '强风/劲风', '疾风', '大风', '烈风', '风暴', '狂暴风', '飓风', '热带风暴', '龙卷风'].includes(weatherDesc)) {
    return weatherIcon;
    return windIcon;
  }
  // 多云/阴
  if (['晴间多云', '多云', '阴'].includes(weatherDesc)) {
    return weatherIcon;
    return cloudyIcon;
  }
  // 晴
  if (['晴', '少云', '平静'].includes(weatherDesc)) {
    return weatherIcon;
    return sunnyIcon;
  }
  // 其他/未知:['热', '冷', '未知']