📝 应用描述
可爱的天气预报小程序,显示当前天气信息
📋 详细信息
| 应用ID |
weather_card |
| 名称 |
天气卡片 |
| 版本 |
v1 |
| 文件大小 |
2.2 KB |
| 上传时间 |
2026-07-29 20:51:09 |
| 状态 |
✅ 已启用 |
| 权限 |
storage |
💡 界面预览 (main.lua)
📄 Lua 源码
-- 天气预报小程序 - 可爱版
-- 作者:Operit AI助手
-- 天气数据(模拟数据,实际使用时可从服务器获取)
local weather_data = {
city = "北京",
province = "北京市",
weather = "晴",
temperature = 25,
humidity = 40,
wind_direction = "西南风",
wind_power = "微风",
feels_like = 26,
aqi = 56,
aqi_category = "良",
temp_max = 28,
temp_min = 18,
sunrise = "05:30",
sunset = "19:20"
}
-- 生活指数数据
local life_indices = {
clothing = { level = "较舒适", advice = "建议穿薄外套、卫衣或长袖衬衫" },
uv = { level = "高", advice = "紫外线较强,减少10-14点户外活动,涂抹SPF30+防晒霜" },
car_wash = { level = "非常适宜", advice = "天气晴好,非常适合洗车" },
exercise = { level = "适宜", advice = "天气适合运动" },
umbrella = { level = "不需要", advice = "天气晴好,无需带伞" }
}
-- 天气图标映射
local weather_icons = {
["晴"] = "☀️",
["多云"] = "⛅",
["阴"] = "☁️",
["小雨"] = "🌦️",
["中雨"] = "🌧️",
["大雨"] = "🌧️",
["雷阵雨"] = "⛈️",
["小雪"] = "❄️",
["中雪"] = "❄️",
["大雪"] = "❄️",
["雨夹雪"] = "🌨️",
["雾"] = "🌫️",
["霾"] = "🌫️"
}
-- 创建天气卡片
local function create_weather_card()
local weather_icon = weather_icons[weather_data.weather] or "🌤️"
return ui.list({
id = "weather_card",
children = {
-- 顶部标题区域
ui.text({
text = "🌸 天气预报 🌸",
size = 24,
color = "#FF69B4",
center = true,
margin = 12
}),
-- 城市信息
ui.text({
text = "📍 " .. weather_data.province .. " · " .. weather_data.city,
size = 16,
color = "#666",
center = true,
margin = 6
}),
-- 天气主信息
ui.list({
id = "weather_main",
children = {
-- 天气图标和描述
ui.text({
text = weather_icon .. " " .. weather_data.weather,
size = 28,
color = "#333",
center = true,
margin = 8
}),
-- 温度
ui.text({
text = "🌡️ " .. weather_data.temperature .. "°C",
size = 32,
color = "#FF4500",
center = true,
margin = 6
}),
-- 温度范围
ui.text({
text = "最高 " .. weather_data.temp_max .. "°C / 最低 " .. weather_data.temp_min .. "°C",
size = 14,
color = "#888",
center = true,
margin = 4
})
}
}),
-- 分隔线
ui.text({
text = "━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
size = 12,
color = "#EEE",
center = true,
margin = 8
}),
-- 详细信息
ui.list({
id = "weather_details",
children = {
ui.text({
text = "💧 湿度: " .. weather_data.humidity .. "%",
size = 14,
color = "#555",
margin = 4
}),
ui.text({
text = "🌬️ 风向: " .. weather_data.wind_direction .. " " .. weather_data.wind_power,
size = 14,
color = "#555",
margin = 4
}),
ui.text({
text = "🌡️ 体感温度: " .. weather_data.feels_like .. "°C",
size = 14,
color = "#555",
margin = 4
}),
ui.text({
text = "🫧 空气质量: " .. weather_data.aqi_category .. " (AQI: " .. weather_data.aqi .. ")",
size = 14,
color = "#555",
margin = 4
})
}
}),
-- 日出日落
ui.list({
id = "sun_info",
children = {
ui.text({
text = "🌅 日出: " .. weather_data.sunrise .. " 🌇 日落: " .. weather_data.sunset,
size = 14,
color = "#7B68EE",
center = true,
margin = 8
})
}
}),
-- 生活指数
ui.text({
text = "🌈 生活指数",
size = 18,
color = "#FF69B4",
center = true,
margin = 12
}),
-- 穿衣建议
ui.text({
text = "👕 穿衣: " .. life_indices.clothing.level .. " - " .. life_indices.clothing.advice,
size = 13,
color = "#666",
margin = 4
}),
-- 紫外线
ui.text({
text = "☀️ 紫外线: " .. life_indices.uv.level .. " - " .. life_indices.uv.advice,
size = 13,
color = "#666",
margin = 4
}),
-- 运动建议
ui.text({
text = "🏃 运动: " .. life_indices.exercise.level .. " - " .. life_indices.exercise.advice,
size = 13,
color = "#666",
margin = 4
}),
-- 带伞建议
ui.text({
text = "☔ 带伞: " .. life_indices.umbrella.level .. " - " .. life_indices.umbrella.advice,
size = 13,
color = "#666",
margin = 4
}),
-- 刷新按钮
ui.spacer({ height = 16 }),
ui.button({
text = "🔄 刷新天气",
on_click = function()
-- 这里可以添加刷新逻辑
app.toast("天气数据已刷新!")
end
}),
-- 底部信息
ui.spacer({ height = 8 }),
ui.text({
text = "数据更新时间: 2026-07-27 18:40",
size = 12,
color = "#999",
center = true,
margin = 4
}),
ui.text({
text = "💖 由 Operit AI 助手制作",
size = 12,
color = "#FF69B4",
center = true,
margin = 4
})
}
})
end
-- 创建页面
return ui.page({
title = "天气预报",
children = {
create_weather_card()
}
})