Update weather.js

This commit is contained in:
Shawn
2019-06-25 19:26:26 +08:00
committed by GitHub
parent 579ac6c209
commit c40851e1c4

View File

@@ -1,21 +1,16 @@
const weaapi = "https://www.tianqiapi.com/api/?version=v6" const weaapi = "https://www.tianqiapi.com/api/?version=v6"
$request.url(weaapi);
$httpClient.get(weaapi, function(error, response, data){ var body = $response.body;
if (error){ var obj = JSON.parse(body);
console.log(error);
$done(); var city = "所在城市: " + obj.city;
} else { var wea = "天气状况: " + obj.wea + " 当前" + obj.tem + "℃ " + obj.tem2 + "℃~" + obj.tem1 + "℃";
var obj = JSON.parse(data); var air = "当前风力: " + obj.win + obj.win_speed + " 风速" + obj.win_meter + "\n空气指数 " + obj.air + " " + obj.air_level + "\n友情提示 " + obj.air_tips + "\n更新时间 " + obj.date + " "+ obj.update_time;
console.log(obj); let wmation = [city,wea,air];
var city = "所在城市: " + obj.city; $notify("Weather Situation:", wmation[0]+ wmation[1]+ wmation[2]);
var wea = "天气状况: " + obj.wea + " 当前" + obj.tem + "℃ " + obj.tem2 + "℃~" + obj.tem1 + "℃";
var air = "当前风力: " + obj.win + obj.win_speed + " 风速" + obj.win_meter + "\n空气指数 " + obj.air + " " + obj.air_level + "\n友情提示 " + obj.air_tips + "\n更新时间 " + obj.date + " "+ obj.update_time; $done(body);
let wmation = [city,wea,air];
$notify("Weather Situation:", wmation[0]+ wmation[1]+ wmation[2]);
$done();
}
}
);
/***************************************************************** /*****************************************************************