var cid = "";
if (document.getElementById('js_weather')!=null){
var arr = document.getElementById('js_weather').getAttribute('data').split(/[=&]/);
cid = arr[1];
}
var tmax_7 = new Array();
var tmin_7 = new Array();
var time_7 = new Array();
var tmax_7_markPoint = new Array();
var tmin_7_markPoint = new Array();
/////////////////////////////////////////////
$(function () {
day10();
Foshorttime();
});
function day10(){
$.getJSON("/weather//data/10day.js", function (json) {
if (json) {
var strbtit = new Array();
var datetime_1 = new Date(json[0]["datetime"].replace(/-/g, "/")); //转换成Data();
for (var i = 1; i < 8; i++) {
var _tmax = json[0]["tmax" + i + ""];
var _tmin = json[0]["tmin" + i + ""];
strbtit.push("
" + _tmax + "°C");
time_7.push(datetime_1.Format('MM/dd'));
tmax_7.push(_tmax);
tmin_7.push(_tmin);
tmax_7_markPoint.push({ name: '摄氏度', value: _tmax, xAxis: datetime_1.Format('MM/dd'), yAxis: _tmax });
tmin_7_markPoint.push({ name: '摄氏度', value: _tmin, xAxis: datetime_1.Format('MM/dd'), yAxis: _tmin });
datetime_1.setDate(datetime_1.getDate() + 1);
}
$("#littit").append(strbtit.join(""));
if (cid != 1) {
var datetime = new Date(json[0]["datetime"].replace(/-/g, "/")); //转换成Data();
var wb2 = '';
var wb3 = '';
var wb4 = '';
var wb5 = '';
var wb6 = '';
$.getJSON("/weather//data/foId_wea.js", function (jsonf) {
if (jsonf) {
$.each(jsonf, function (key, value) {
if (json[0]["wb2"] == value.id) wb2 = value.w;
if (json[0]["wb3"] == value.id) wb3 = value.w;
if (json[0]["wb4"] == value.id) wb4 = value.w;
if (json[0]["wb5"] == value.id) wb5 = value.w;
})
var sbweilai = new Array();
sbweilai.push("
明天 " + wb2 + "" + json[0]["tmin2"] + "°C~" + json[0]["tmax2"] + "°C" + "");
datetime.setDate(datetime.getDate() + 2);
sbweilai.push("" + (datetime.getMonth() + 1) + "月" + datetime.getDate() + " " + wb3 + "" + json[0]["tmin3"] + "°C~" + json[0]["tmax3"] + "°C" + "");
datetime.setDate(datetime.getDate() + 1);
sbweilai.push("" + (datetime.getMonth() + 1) + "月" + datetime.getDate() + " " + wb4 + "" + json[0]["tmin4"] + "°C~" + json[0]["tmax4"] + "°C" + "");
datetime.setDate(datetime.getDate() + 1);
sbweilai.push("" + (datetime.getMonth() + 1) + "月" + datetime.getDate() + " " + wb5 + "" + json[0]["tmin5"] + "°C~" + json[0]["tmax5"] + "°C" + "");
datetime.setDate(datetime.getDate() + 1);
$("#litweilai01").append(sbweilai.join(""));
}
});
}
line_10day();
}
});
}
function Foshorttime() {
$.getJSON("/weather//data/foshorttime.js", function (json) {
if (json) {
var shidu = json[0]["hmin"] + "% ~ " + json[0]["hmax"] + "% ";
var strcontent = "佛山";
strcontent += "";
strcontent += "" + json[0]["tmax"] + "°C " + json[0]["ws"] + "
";
strcontent += "";
strcontent += "" + json[0]["tmin"] + "°C ~ " + json[0]["tmax"] + "°C " + " " + json[0]["wind"] + "
湿度" + shidu + " " + datetime + "
";
//strcontent += "" + json[0]["tmin"] + "°C ~ " + json[0]["tmax"] + "°C " + " " + json[0]["wind"] + "
湿度" + shidu + "";
strcontent += "";
strcontent += "";
$("#foshorttime01").append(strcontent);
if (cid != 1) {
var strcx = new Array();
strcx.push("");
strcx.push("
");
strcx.push("" + json[0]["ws"] + "
" + json[0]["wind"] + "
相对湿度:" + shidu + "
");
strcx.push("");
$("#foshorttime02").append(strcx.join(""));
}
}
})
}
function line_10day() {
// 折线图-我的气象台
var myChart = echarts.init(document.getElementById('wLine1'));
myChart.setOption({
title: {
text: '',
subtext: ''
},
tooltip: {
trigger: 'axis',
axisPointer: { type: 'none' }
},
legend: {
selectedMode: false,
data: ['最高气温', '最低气温']
},
toolbox: {
show: false
},
calculable: false,
color: ['#D62859', '#055483'],
grid: {
x: 40,
y: 5,
x2: 40,
y2: 20,
borderWidth: 0
},
xAxis: [
{
type: 'category',
boundaryGap: false,
axisTick: { show: false },
axisLine: false,
splitArea: { show: false },
splitLine: { show: false },
axisLabel: {
textStyle: { color: '#fff' }
},
data: time_7
}
],
yAxis: [
{
type: 'value',
axisLabel: {
show: false
},
max: 45,
scale: true,
axisLine: false,
splitArea: { show: false },
splitLine: { show: false }
}
],
series: [
{
name: '最高气温',
type: 'line',
itemStyle: {
normal: {
lineStyle: {
shadowColor: 'rgba(0,0,0,0.0)'
}
}
},
data: tmax_7,
markPoint: {
data: tmax_7_markPoint
}
},
{
name: '最低气温',
type: 'line',
itemStyle: {
normal: {
lineStyle: {
shadowColor: 'rgba(0,0,0,0.0)'
}
}
},
data: tmin_7,
markPoint: {
data: tmin_7_markPoint
}
}
]
});
}
//日期
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
/////////////////////////////////////////////