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(); ///////////////////////////////////////////// $(function () { day10(); Foshorttime(); }); function day10(){ $.getJSON("weather/data/10day.js?t=" + Math.random(), function (json) { if (json) { var strbtit = new Array(); var datetime_1 = new Date(json[0]["datetime"].replace(/-/g, "/")); //转换成Data(); datetime_1.setDate(datetime_1.getDate() + 1); for (var i = 1; i <= 10; i++) { var _tmax = json[0]["tmax" + i + ""]; var _tmin = json[0]["tmin" + i + ""]; //strbtit.push("\""
" + _tmax + "°C
"); strbtit.push("\"""); time_7.push(datetime_1.Format('MM/dd')); tmax_7.push(_tmax); tmin_7.push(_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 = ''; $.getJSON("weather/data/foId_wea.js?t=" + Math.random(), function (jsonf) { if (jsonf) { $.each(jsonf, function (key, value) { if (json[0]["wb1"] == value.id) wb2 = value.w; if (json[0]["wb2"] == value.id) wb3 = value.w; if (json[0]["wb3"] == value.id) wb4 = value.w; if (json[0]["wb4"] == value.id) wb5 = value.w; }) var sbweilai = new Array(); datetime.setDate(datetime.getDate() + 1); sbweilai.push("
  • " + (datetime.getMonth() + 1) + "月" + datetime.getDate() + " \""" + wb2 + "" + json[0]["tmin1"] + "°C~" + json[0]["tmax1"] + "°C" + "
  • "); datetime.setDate(datetime.getDate() + 1); sbweilai.push("
  • " + (datetime.getMonth() + 1) + "月" + datetime.getDate() + " \""" + wb3 + "" + json[0]["tmin2"] + "°C~" + json[0]["tmax2"] + "°C" + "
  • "); datetime.setDate(datetime.getDate() + 1); sbweilai.push("
  • " + (datetime.getMonth() + 1) + "月" + datetime.getDate() + " \""" + wb4 + "" + json[0]["tmin3"] + "°C~" + json[0]["tmax3"] + "°C" + "
  • "); datetime.setDate(datetime.getDate() + 1); sbweilai.push("
  • " + (datetime.getMonth() + 1) + "月" + datetime.getDate() + " \""" + wb5 + "" + json[0]["tmin4"] + "°C~" + json[0]["tmax4"] + "°C" + "
  • "); datetime.setDate(datetime.getDate() + 1); $("#litweilai01").append(sbweilai.join("")); } }); } line_10day(); } }); } function Foshorttime() { $.getJSON("weather/data/wc_last.js?t=" + Math.random(), function (json_wcLast) { if (json_wcLast) { var datetime = new Date(); var PeriodPath = "day"; if (datetime.getHours() >= 19 || datetime.getHours() < 7) PeriodPath = "night"; var strcontent = "
    佛山
    "; $("#foshorttime01").append(strcontent); var strcx = "
    "; $("#foshorttime02").append(strcx); } $.getJSON("weather/data/foshorttime.js?t=" + Math.random(), function (json) { if (json) { var shidu = json[0]["hmin"] + "% ~ " + json[0]["hmax"] + "% "; var strcontent = "
    "; strcontent += "
    " + json[0]["tmax"] + "°C " + json[0]["ws"] + "
    "; strcontent += "
    "; strcontent += "" + Math.floor(json[0]["tmin"]) + "°C ~ " + Math.ceil(json[0]["tmax"]) + "°C " + " " + json[0]["wind"] + "
    湿度" + shidu + "
    " + datetime_cn + "
    "; //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("
    " + json[0]["ws"] + "
    " + json[0]["wind"] + "
    相对湿度:" + shidu + "
    "); strcx.push("
    "); $("#foshorttime02").append(strcx.join("")); } } }) }) } function line_10day() { // 折线图-我的气象台 require.config({ paths: { echarts: '/Echarts/asset/js/echarts', 'echarts/chart/line': '/Echarts/asset/js/echarts-map' } }); option = { animation:false, title: { text: '', subtext: '' }, tooltip: { trigger: 'axis', axisPointer: { type: 'none' } }, legend: { selectedMode: false, data: ['', ''] }, toolbox: { show: false }, calculable: false, color: ['#D62859', '#055483'], grid: { x: 30, y: 25, x2: 28, y2: 25, 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, formatter: '{value} °C' }, scale: true, axisLine: false, splitArea: { show: false }, splitLine: { show: false } } ], series: [ { name: '最高气温', type: 'line', itemStyle: { normal: { lineStyle: { shadowColor: 'rgba(0,0,0,0.0)' } } }, symbol: "circle", symbolSize: "2", itemStyle: { normal: { label: { show: true, textStyle: { fontSize: '12', fontFamily: '微软雅黑', color: '#fff' } } } }, data: tmax_7, tooltip: { // Series config. trigger: 'item', formatter: "最高气温:{c} ℃" } }, { name: '最低气温', type: 'line', itemStyle: { normal: { lineStyle: { shadowColor: 'rgba(0,0,0,0.0)' } } }, symbol: "circle", symbolSize: "2", itemStyle: { normal: { label: { show: true, textStyle: { fontSize: '12', fontFamily: '微软雅黑', color: '#fff' } } } }, data: tmin_7, tooltip: { // Series config. trigger: 'item', formatter: "最低气温:{c} ℃" } } ] }; require( [ 'echarts', 'echarts/chart/line' ], function (ec) { var myChart = ec.init(document.getElementById('wLine1')); myChart.setOption(option); } ) }