feat(天气): 新增天气图标并支持温度单位配置
- 为不同天气条件添加专用图标,提升视觉辨识度
- 从配置接口获取温度单位并动态显示
- 修复首次进入活动接口的URL路径错误
| | |
| | | const [orderData, setOrderData] = useState<any>({}); // 订单数据 |
| | | const [isLogin, setIsLogin] = useState(false); // 是否登录 |
| | | const [overlayAnchorBottom, setOverlayAnchorBottom] = useState<number | null>(null); // 浮层初始化锚点(距底部) |
| | | const [temperatureUnit, setTemperatureUnit] = useState('℃'); // 温度单位 |
| | | const { |
| | | boxHeight, |
| | | originOpacity, |
| | |
| | | getOrderDistance().then((res: any) => { |
| | | if (res && res.adsorptionDistance) { |
| | | setAdsorptionDistance(res.adsorptionDistance); |
| | | } |
| | | if (res && res.temperatureUnit) { |
| | | setTemperatureUnit(res.temperatureUnit); |
| | | } |
| | | }).catch(err => { |
| | | console.error('获取吸附距离失败', err); |
| | |
| | | {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> |
| | |
| | | // 第一次进入应用 |
| | | 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); |
| | | } |
| | |
| | | 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'; |
| | | |
| | | /** |
| | | * 根据高德天气返回的天气描述,匹配系统定义的天气图标。 |
| | |
| | | |
| | | // 雷阵雨/冰雹 |
| | | 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; |
| | | } |
| | | |
| | | // 其他/未知:['热', '冷', '未知'] |