Production and sharing of high-end web reports with weather forecast
I've developed a lot of reports with FineReport, but this is the first time I've integrated weather forecasting to improve interaction and humanization, so I'd like to share it with you.
This report is a comprehensive store sales management analysis panel, you can query performance analysis, clerk sales analysis, store ranking analysis (you can see that it is a chain store), VIP birthday reminder. How to make a specific template, people in the industry can see at a glance, there is no need to say more, just focus on how to integrate the weather.
First, the picture above:
The method is to add a piece of JS code, as follows:
[javascript] view plaincopy
Var weather=function () {
Var tmp=0
Var SWther= {w: [{}], add: {}}
Var SWther= {}
This.getWeather=function (city,type) {
/ / city=utf8ToGBK (city)
/ *
$.getScript ("http://php.weather.sina.com.cn/iframe/index/w_cl.php?code=js&day=2&city="+city+"&dfc=3",function(){if(type=='js'){echo(city);}});"
* * /
$.ajax ({
DataType:'script'
ScriptCharset:'gb2312',/
Url: "http://php.weather.sina.com.cn/iframe/index/w_cl.php?code=js&day=2&city="+city+"&dfc=3",
Success:function () {
If (type=='js') {echo (city);}
}
})
}
Function dis_img (weather) {
Var style_img= "p_w_picpath/s_13.png"
If (weather.indexOf ("cloudy")! = =-1 | | weather.indexOf ("clear")! =-1) {style_img= "p_w_picpath/s_1.png";}
Else if (weather.indexOf (cloudy)! =-1&&weather.indexOf (overcast)! =-1) {style_img= "p_w_picpath/s_2.png";}
Else if (weather.indexOf ("overcast")! =-1&&weather.indexOf ("rain")! =-1) {style_img= "p_w_picpath/s_3.png";}
Else if (weather.indexOf)! =-1&&weather.indexOf (Rain)! =-1) {style_img= "p_w_picpath/s_12.png";}
Else if (weather.indexOf)! =-1&&weather.indexOf (fog)! =-1) {style_img= "p_w_picpath/s_12.png";}
Else if (weather.indexOf ("clear")! =-1) {style_img= "p_w_picpath/s_13.png";}
Else if (weather.indexOf ("cloudy")! =-1) {style_img= "p_w_picpath/s_2.png";}
Else if (weather.indexOf ("shower")! =-1) {style_img= "p_w_picpath/s_3.png";}
Else if (weather.indexOf (light rain)! =-1) {style_img= "p_w_picpath/s_3.png";}
Else if (weather.indexOf)! =-1) {style_img= "p_w_picpath/s_4.png";}
Else if (weather.indexOf)! =-1) {style_img= "p_w_picpath/s_5.png";}
Else if (weather.indexOf)! =-1) {style_img= "p_w_picpath/s_5.png";}
Else if (weather.indexOf (hail)! =-1) {style_img= "p_w_picpath/s_6.png";}
Else if (weather.indexOf (thunderstorm)! =-1) {style_img= "p_w_picpath/s_7.png";}
Else if (weather.indexOf (Lesser Snow)! =-1) {style_img= "p_w_picpath/s_8.png";}
Else if (weather.indexOf)! =-1) {style_img= "p_w_picpath/s_9.png";}
Else if (weather.indexOf)! =-1) {style_img= "p_w_picpath/s_10.png";}
Else if (weather.indexOf (Blizzard)! =-1) {style_img= "p_w_picpath/s_10.png";}
Else if (weather.indexOf)! =-1) {style_img= "p_w_picpath/s_11.png";}
Else if (weather.indexOf)! =-1) {style_img= "p_w_picpath/s_11.png";}
Else if (weather.indexOf ("fog")! =-1) {style_img= "p_w_picpath/s_12.png";}
Else {style_img= "p_w_picpath/s_2.png";}
Return style_img;}
Function echo (city) {
$('# city') .html (city)
$('# weather') .html (window.SWther.w [city] [0] .s1)
$('# temperature') .html (window.SWther.w [city] [0] .t1 +'°')
$('# wind') .html (window.SWther.w [city] [0] .p1)
$('# direction') .html (window.SWther.w [city] [0] .d1)
Var T_weather_img=dis_img (window.SWther.w [city] [0] .s1)
$('# thanks weatherproof img'). Html ("
")
/ / $('# city feature') .html (window.SWther.w [city] [0] .t1 +'~'+ window.SWther.w [window] [0] .t2 +'°')
$('# Thumblature') .html (window.SWther.w [city] [0] .t1)
$('# Tweeweather') .html (window.SWther.w [city] [0] .s1)
$('# Tubwind') .html (window.SWther.w [city] [0] .p1)
$('# Tunable direction') .html (window.SWther.w [city] [0] .d1)
$('# Mitchweather') .html (window.SWther.w [city] [1] .s1)
Var M_weather_img=dis_img (window.SWther.w [city] [1] .s1)
$('# html weatherproof IMG').
")
) .html (window.SWther.w [city] [1] .T1 +'~'+ window.SWther.w [city] [1] .T2 +'°')
$('# Mainwind') .html (window.SWther.w [city] [1] .p1)
$('# Manners direction') .html (window.SWther.w [city] [1] .d1)
$('# Lawweather') .html (window.SWther.w [city] [2] .s1)
Var L_weather_img=dis_img (window.SWther.w [city] [2] .s1)
$('# lazy weatherproof img'). Html ("
")
) .html (window.SWther.w [city] [2] .T1 +'~'+ window.SWther.w [city] [2] .T2 +'°')
$('# Lawwind') .html (window.SWther.w [city] [2] .p1); $('# Laterdirection`) .html (window.SWther.w [city] [2] .d1)
}
}
/ / weather is over
Function jintian () {
Weather_.getWeather (city,'js')
}
In this way, the job is done.