var url = 'https://tianqiapi.com/api?version=v6&appid=4323&appsecret=YqmyZ';
$.getJSON(url, function (res) {
//console.log(res);
$("#location").html(res.city);
$("#weather-desc").html(res.wea);
$("#weather-temp").html(res.tem + "°C");
//天气图标;
$("#icon").html(getIcon(0, 'day', res.wea));
})
//按天气情况返回对应图图标;
/* local图标位置,0->60px;1->30px;
* times,day->白天;night->晚上;
* desc天气描述;
*/
function getIcon(local, dnStatus, desc) {
var iconWidth, url;
//图标尺寸判断;
if (local == 0) {
iconWidth = "30px";
} else {
iconWidth =
漏刻有时数据可视化自动获取天气API接口函数lockweather.js
关注
打赏