weatherInfo.jsp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <%@ page contentType="text/html;charset=GBK"%>
  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  3. <script type="text/javascript" src="http://pv.sohu.com/cityjson" charset="gb2312"></script>
  4. <link type="text/css" rel="stylesheet" href="http://i.tq121.com.cn/c/weather2014/common.css" />
  5. <link type="text/css" rel="stylesheet" href="http://i.tq121.com.cn/c/core.css" />
  6. <link type="text/css" rel="stylesheet" href="http://i.tq121.com.cn/c/weather2014/city7d.css" />
  7. <script type="text/javascript">
  8. var ip;
  9. var city;
  10. window.onload=function(){
  11. loadweather();
  12. };
  13. function loadweather() {
  14. try {
  15. ip = returnCitySN["cip"];
  16. //alert(returnCitySN["cip"]+ ',' + returnCitySN["cname"])
  17. $.ajax({
  18. type : "POST",
  19. url : "weatherForecastAction.do?task=weatherData",
  20. data : {
  21. "ip" : ip
  22. },
  23. timeout : 1000000,
  24. cache : false,
  25. dataType : "json",
  26. success : function(data) {
  27. var showapi_res_body = data.showapi_res_body;
  28. var cityInfo = showapi_res_body.cityInfo;
  29. city = cityInfo.c3;
  30. var f1 = showapi_res_body.f1;
  31. var f2 = showapi_res_body.f2;
  32. var f3 = showapi_res_body.f3;
  33. var f4 = showapi_res_body.f4;
  34. var f5 = showapi_res_body.f5;
  35. var f6 = showapi_res_body.f6;
  36. var f7 = showapi_res_body.f7;
  37. weatherData(f1, 1);
  38. weatherData(f2, 2);
  39. weatherData(f3, 3);
  40. weatherData(f4, 4);
  41. weatherData(f5, 5);
  42. weatherData(f6, 6);
  43. weatherData(f7, 7);
  44. },
  45. error : function(data) {
  46. //alert(data);
  47. }
  48. });
  49. } catch (e) {
  50. }
  51. }
  52. function viewAllWeather() {
  53. var title = city + "七天天气预报"
  54. $.ligerDialog.open({
  55. target : $("#target_weather"),
  56. title : title,
  57. width : 720,
  58. height : 350
  59. });
  60. };
  61. function colse() {
  62. $.ligerDialog.hide();
  63. $.ligerDialog.colse();
  64. }
  65. function weatherData(f, n) {
  66. var day = f.day;
  67. var day_air_temperature = f.day_air_temperature;
  68. var day_weather = f.day_weather;
  69. var day_weather_pic = f.day_weather_pic;
  70. var night_air_temperature = f.night_air_temperature;
  71. var night_weather = f.night_weather;
  72. var night_weather_pic = f.night_weather_pic;
  73. var weekday = f.weekday;
  74. var show_weather = "";
  75. if (day_weather == night_weather) {
  76. show_weather = day_weather
  77. } else {
  78. show_weather = day_weather + "转" + night_weather
  79. }
  80. if (n == 1) {
  81. var weather = city + " " + show_weather + " " + day_air_temperature
  82. + "°C~" + night_air_temperature + "°C";
  83. $("#showWeather").html(weather);
  84. }
  85. day = day.substring(6, 8);
  86. $("#day_7d" + n).html(day + "日");
  87. $("#d_img_7d" + n).attr("src", day_weather_pic);
  88. $("#n_img_7d" + n).attr("src", night_weather_pic);
  89. $("#weather_7d" + n).html(show_weather);
  90. $("#d_temp_7d" + n).html(day_air_temperature);
  91. $("#n_temp_7d" + n).html(night_air_temperature);
  92. if (n > 3) {
  93. if (weekday == 1) {
  94. weekday = "周一";
  95. } else if (weekday == 2) {
  96. weekday = "周二";
  97. } else if (weekday == 3) {
  98. weekday = "周三";
  99. } else if (weekday == 4) {
  100. weekday = "周四";
  101. } else if (weekday == 5) {
  102. weekday = "周五";
  103. } else if (weekday == 6) {
  104. weekday = "周六";
  105. } else if (weekday == 7) {
  106. weekday = "周日";
  107. }
  108. $("#h1_7d" + n).html(weekday);
  109. }
  110. }
  111. </script>
  112. <div style="padding-top: 10px;">
  113. <a> <span id="showWeather"
  114. style="text-align: right; padding-right: 20px; padding-top: 10px; color: white;"
  115. onclick="viewAllWeather();"> </span>
  116. </a>
  117. </div>
  118. <div id="target_weather"
  119. style="width: 200px; height: 200px; margin: 3px; display: none;">
  120. <div>
  121. <div class="con d7 clearfix">
  122. <div class="left fl">
  123. <!--今明后7d大包 begin-->
  124. <div id="tabDays">
  125. <div class="m m1" id="today">
  126. <ul class="t clearfix">
  127. <!-- 实况 begin-->
  128. <!-- 实况 end-->
  129. <!-- 今天明天预报 begin-->
  130. <!-- 今天明天预报 end-->
  131. </ul>
  132. <i class="line1"></i> <i class="line2"></i> <i class="line3"></i>
  133. </div>
  134. <div class="m m2" id="2_3d">
  135. <!-- 明天后天预报 begin-->
  136. <i class="line1"></i> <i class="line2"></i>
  137. <!-- 明天后天预报 end-->
  138. </div>
  139. <div class="m m3" id="7d">
  140. <ul class="t clearfix">
  141. <li class='dn' data-dn='7d1'>
  142. <h1>今天</h1>
  143. <h2 id="day_7d1">19日</h2> <img id="d_img_7d1" width="50px;"
  144. src="" /> <img id="n_img_7d1" width="50px;" src="" />
  145. <p id="weather_7d1" class="wea">阵雨转多云</p>
  146. <p class="tem tem1">
  147. <span id="d_temp_7d1">32</span><i>°C</i>
  148. </p>
  149. <p class="tem tem2">
  150. <span id="n_temp_7d1">25</span><i>°C</i>
  151. </p>
  152. </li>
  153. <i class="line1"></i>
  154. <li class='dn' data-dn='7d2'>
  155. <h1>明天</h1>
  156. <h2 id="day_7d2">20日</h2> <img id="d_img_7d2" width="50px;"
  157. src="" /> <img id="n_img_7d2" width="50px;" src="" />
  158. <p id="weather_7d2" class="wea">阴转多云</p>
  159. <p class="tem tem1">
  160. <span id="d_temp_7d2">34</span><i>°C</i>
  161. </p>
  162. <p class="tem tem2">
  163. <span id="n_temp_7d2">25</span><i>°C</i>
  164. </p>
  165. </li>
  166. <li class='dn' data-dn='7d3'>
  167. <h1>后天</h1>
  168. <h2 id="day_7d3">21日</h2> <img id="d_img_7d3" width="50px;"
  169. src="" /> <img id="n_img_7d3" width="50px;" src="" />
  170. <p id="weather_7d3" class="wea">多云</p>
  171. <p class="tem tem1">
  172. <span id="d_temp_7d3">35</span><i>°C</i>
  173. </p>
  174. <p class="tem tem2">
  175. <span id="n_temp_7d3">26</span><i>°C</i>
  176. </p>
  177. </li>
  178. <li class='dn' data-dn='7d4'>
  179. <h1 id="h1_7d4">周六</h1>
  180. <h2 id="day_7d4">22日</h2> <img id="d_img_7d4" width="50px;"
  181. src="" /> <img id="n_img_7d4" width="50px;" src="" />
  182. <p id="weather_7d4" class="wea">阵雨</p>
  183. <p class="tem tem1">
  184. <span id="d_temp_7d4">31</span><i>°C</i>
  185. </p>
  186. <p class="tem tem2">
  187. <span id="n_temp_7d4">25</span><i>°C</i>
  188. </p>
  189. </li>
  190. <li class='dn' data-dn='7d5'>
  191. <h1 id="h1_7d5">周日</h1>
  192. <h2 id="day_7d5">23日</h2> <img id="d_img_7d5" width="50px;"
  193. src="" /> <img id="n_img_7d5" width="50px;" src="" />
  194. <p id="weather_7d5" class="wea">阵雨转阴</p>
  195. <p class="tem tem1">
  196. <span id="d_temp_7d5">32</span><i>°C</i>
  197. </p>
  198. <p class="tem tem2">
  199. <span id="n_temp_7d5">24</span><i>°C</i>
  200. </p>
  201. </li>
  202. <li class='dn' data-dn='7d6'>
  203. <h1 id="h1_7d6">周一</h1>
  204. <h2 id="day_7d6">24日</h2> <img id="d_img_7d6" width="50px;"
  205. src="" /> <img id="n_img_7d6" width="50px;" src="" />
  206. <p id="weather_7d6" class="wea">多云</p>
  207. <p class="tem tem6">
  208. <span id="d_temp_7d6">31</span><i>°C</i>
  209. </p>
  210. <p class="tem tem2">
  211. <span id="n_temp_7d6">24</span><i>°C</i>
  212. </p>
  213. </li>
  214. <li class='dn' data-dn='7d7'>
  215. <h1 id="h1_7d7">周二</h1>
  216. <h2 id="day_7d7">25日</h2> <img id="d_img_7d7" width="50px;"
  217. src="" /> <img id="n_img_7d7" width="50px;" src="" />
  218. <p id="weather_7d7" class="wea">多云</p>
  219. <p class="tem tem1">
  220. <span id="d_temp_7d7">32</span><i>°C</i>
  221. </p>
  222. <p class="tem tem2">
  223. <span id="n_temp_7d7">24</span><i>°C</i>
  224. </p>
  225. </li>
  226. </ul>
  227. <i class="line1"></i>
  228. </div>
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. </div>