forked from ziye12/Scripts-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather.js
30 lines (26 loc) · 1.06 KB
/
weather.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var appid="47273245";
var appsecret="BCK1QTW5";
var wurl = {
url: "https://www.tianqiapi.com/api/?version=v6&appid=" + appid + "&appsecret=" + appsecret,
};
$task.fetch(wurl).then(response => {
var obj = JSON.parse(response.body);
var city = obj.city;
var noweather = obj.wea;
var wind_dir = obj.win;
var wind_sc = obj.win_speed;
var hum = obj.humidity;
var lowtmp = obj.tem2;
var hightmp = obj.tem1;
var air = obj.air_pm25;
var airlevel =obj.air_level;
var airtips = obj.air_tips;
var updatetime = obj.date + " " + obj.update_time;
var title = city + "天气: "+ noweather +", " + "气温: " + lowtmp +" °C " + "~" + hightmp +" °C "
var mation = "风向: " + wind_dir + "·" + wind_sc + " | " + "湿度: " + hum + " | " + "PM2.5: " + air + " " + airlevel
var tips = "建议: " + airtips
var update = "更新于: " + updatetime
$notify(title, mation, tips, update);
}, reason => {
$notify("错误", "", reason.error);
});