You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

309 lines
10 KiB

  1. //Created by HBuilder.
  2. //User: Miracle~
  3. //Date: 2016/11/14
  4. //Time: 19:00
  5. //缓存数据
  6. $("#loading_html").show();
  7. var where_disney;
  8. var up_id;
  9. var up_name;
  10. var down_id;
  11. var down_name;
  12. var data_cur;
  13. var data_cur_str;
  14. var week_day;
  15. var data = {
  16. where_disney: where_disney, //迪士尼页面所在位置 1在下面0在上面down_input编号
  17. up_name: up_name, //上面inputname
  18. up_id: up_id, //上面inputid
  19. down_id: down_id,
  20. down_name: down_name,
  21. data_cur: data_cur, //时间2016-11-11
  22. data_cur_str: data_cur_str, //时间11月11日
  23. week_day: week_day, //星期几
  24. };
  25. //开始加载
  26. window.onload = function() {
  27. var data_cur = getPar('data_cur');
  28. var data_cur_str = getPar('data_cur_str');
  29. var week_day = getPar('week_day');
  30. if(data_cur == '' || data_cur_str == '' || week_day == '') {
  31. //不是日历界面返回
  32. if(getStorJson('disney_tranship') == null) {
  33. //没存过第一次加载
  34. data.where_disney = 1; //默认迪士尼在下面
  35. data.data_cur =after(getDateTime(0));//2016-11-11 明天
  36. temp_time = data.data_cur.replace(/-/g, "/");
  37. data.week_day = getWeekDay(temp_time);
  38. //data.week_day = '今天'; //今天显示今天
  39. // data.data_cur_str = getDateTime(11); //11月11日
  40. var month = getMonthAndDayByDate(data.data_cur,'month');
  41. var day = getMonthAndDayByDate(data.data_cur,'day');
  42. var new_newdate = month + '月' + day + '日';
  43. data.data_cur_str = new_newdate;
  44. //data.data_cur = getDateTime(13); //2016-11-11
  45. //data.week_day = '今天'; //今天显示今天
  46. //data.data_cur_str = getDateTime(11); //11月11日
  47. data.up_name = ''; //初始化缓存
  48. data.up_id = ''; //初始化缓存
  49. data.down_name = '上海迪士尼度假区'; //初始化缓存
  50. data.down_id = '3240'; //初始化缓存
  51. setStorJson('disney_tranship', data);
  52. //页面加载
  53. $("#time_string").html(data.data_cur_str);
  54. $("#today").html(data.week_day);
  55. $('#time_string').attr('to_sql_time', data.data_cur);
  56. //上
  57. $('#up_input').val(data.up_name);
  58. $('#up_input').attr("up_id", data.up_id);
  59. $('#up_input').attr("up_name", data.up_name);
  60. $('#up_input').attr("where_disney", 0);
  61. //下
  62. $('#down_input').val(data.down_name);
  63. $('#down_input').attr("down_id", data.down_id);
  64. $('#down_input').attr("down_name", data.down_name);
  65. $('#down_input').attr("where_disney", 1);
  66. } else {
  67. //不是第一次加载
  68. data = getStorJson('disney_tranship');
  69. //得到数据加载界面
  70. var temp = data.data_cur.replace(/-/g, '/');
  71. var week_day = getWeekDay(temp);
  72. data.week_day = week_day;
  73. if(data.where_disney == 1) {
  74. //迪士尼在下面
  75. $("#time_string").html(data.data_cur_str);
  76. $("#today").html(data.week_day);
  77. $('#time_string').attr('to_sql_time', data.data_cur);
  78. //上
  79. $('#up_input').val(data.up_name);
  80. $('#up_input').attr("up_id", data.up_id);
  81. $('#up_input').attr("up_name", data.up_name);
  82. $('#up_input').attr("where_disney", 0);
  83. //下
  84. $('#down_input').val(data.down_name);
  85. $('#down_input').attr("down_id", data.down_id);
  86. $('#down_input').attr("down_name", data.down_name);
  87. $('#down_input').attr("where_disney", 1);
  88. } else {
  89. //迪士尼在上面
  90. $("#time_string").html(data.data_cur_str);
  91. $("#today").html(data.week_day);
  92. $('#time_string').attr('to_sql_time', data.data_cur);
  93. //上
  94. $('#up_input').val(data.up_name);
  95. $('#up_input').attr("up_id", data.up_id);
  96. $('#up_input').attr("up_name", data.up_name);
  97. $('#up_input').attr("where_disney", 1);
  98. //下
  99. $('#down_input').val(data.down_name);
  100. $('#down_input').attr("down_id", data.down_id);
  101. $('#down_input').attr("down_name", data.down_name);
  102. $('#down_input').attr("where_disney", 0);
  103. }
  104. }
  105. } else {
  106. //日历界面返回
  107. data = getStorJson('disney_tranship'); //得到缓存
  108. var temp = data.data_cur.replace(/-/g, '/');
  109. var week_day = getWeekDay(temp);
  110. data.week_day = week_day;
  111. data.data_cur = getPar('data_cur');
  112. data.data_cur_str = getPar('data_cur_str');
  113. data.week_day = getPar('week_day');
  114. var temp = data.data_cur.replace(/-/g, '/');
  115. var week_day = getWeekDay(temp);
  116. data.week_day = week_day;
  117. if(getDateTime(11) == data.data_cur_str) {
  118. //显示今天
  119. data.week_day = '今天';
  120. }
  121. setStorJson('disney_tranship', data);
  122. //加载界面
  123. //得到数据加载界面
  124. if(data.where_disney == 1) {
  125. //迪士尼在下面
  126. $("#time_string").html(data.data_cur_str);
  127. $("#today").html(data.week_day);
  128. $('#time_string').attr('to_sql_time', data.data_cur);
  129. //上
  130. $('#up_input').val(data.up_name);
  131. $('#up_input').attr("up_id", data.up_id);
  132. $('#up_input').attr("up_name", data.up_name);
  133. $('#up_input').attr("where_disney", 0);
  134. //下
  135. $('#down_input').val(data.down_name);
  136. $('#down_input').attr("down_id", data.down_id);
  137. $('#down_input').attr("down_name", data.down_name);
  138. $('#down_input').attr("where_disney", 1);
  139. } else {
  140. //迪士尼在上面
  141. $("#time_string").html(data.data_cur_str);
  142. $("#today").html(data.week_day);
  143. $('#time_string').attr('to_sql_time', data.data_cur);
  144. //上
  145. $('#up_input').val(data.up_name);
  146. $('#up_input').attr("up_id", data.up_id);
  147. $('#up_input').attr("up_name", data.up_name);
  148. $('#up_input').attr("where_disney", 1);
  149. //下
  150. $('#down_input').val(data.down_name);
  151. $('#down_input').attr("down_id", data.down_id);
  152. $('#down_input').attr("down_name", data.down_name);
  153. $('#down_input').attr("where_disney", 0);
  154. }
  155. }
  156. }
  157. //选择日期
  158. function select_date() {
  159. data = getStorJson('disney_tranship');
  160. data.where_disney = $("#down_input").attr("where_disney"); //得到where_disney属性
  161. data.down_id = $("#down_input").attr("down_id");
  162. data.down_name = $("#down_input").attr("down_name");
  163. data.up_id = $("#up_input").attr("up_id");
  164. data.up_name = $("#up_input").attr("up_name");
  165. data.data_cur = $('#time_string').attr('to_sql_time');
  166. data.data_cur_str = $('#time_string').html();
  167. data.week_day = $('#today').html();
  168. setStorJson('disney_tranship', data); //存入缓存
  169. window.location.href = "calendar.html?from=disney_tranship"; //跳转日历
  170. }
  171. //切换起终点
  172. function change_where() {
  173. data = getStorJson('disney_tranship');
  174. data.data_cur = $('#time_string').attr('to_sql_time');
  175. data.data_cur_str = $("#time_string").html();
  176. data.up_id = $("#up_input").attr("up_id");
  177. data.up_name = $("#up_input").attr("up_name");
  178. data.down_id = $("#down_input").attr("down_id");
  179. data.down_name = $("#down_input").attr("down_name");
  180. data.week_day = $("#today").html();
  181. data.where_disney = $("#down_input").attr("where_disney");
  182. var temp_data;
  183. if(data.where_disney == 1) {
  184. //迪士尼在下面,变成上面
  185. $("#down_input").attr("where_disney", 0);
  186. $("#up_input").attr("where_disney", 1);
  187. data.where_disney = 0;
  188. temp_data = data.up_id
  189. data.up_id = data.down_id;
  190. data.down_id = temp_data;
  191. temp_data = data.up_name;
  192. data.up_name = data.down_name;
  193. data.down_name = temp_data;
  194. } else {
  195. //迪士尼在上面,变成下面
  196. $("#down_input").attr("where_disney", 1);
  197. $("#up_input").attr("where_disney", 0);
  198. data.where_disney = 1;
  199. temp_data = data.up_id
  200. data.up_id = data.down_id;
  201. data.down_id = temp_data;
  202. temp_data = data.up_name;
  203. data.up_name = data.down_name;
  204. data.down_name = temp_data;
  205. }
  206. setStorJson('disney_tranship', data);
  207. //载入界面
  208. if(data.where_disney == 1) {
  209. //迪士尼在下面
  210. $("#time_string").html(data.data_cur_str);
  211. $("#today").html(data.week_day);
  212. $('#time_string').attr('to_sql_time', data.data_cur);
  213. //上
  214. $('#up_input').val(data.up_name);
  215. $('#up_input').attr("up_id", data.up_id);
  216. $('#up_input').attr("up_name", data.up_name);
  217. $('#up_input').attr("where_disney", 0);
  218. //下
  219. $('#down_input').val(data.down_name);
  220. $('#down_input').attr("down_id", data.down_id);
  221. $('#down_input').attr("down_name", data.down_name);
  222. $('#down_input').attr("where_disney", 1);
  223. } else {
  224. //迪士尼在上面
  225. $("#time_string").html(data.data_cur_str);
  226. $("#today").html(data.week_day);
  227. $('#time_string').attr('to_sql_time', data.data_cur);
  228. //上
  229. $('#up_input').val(data.up_name);
  230. $('#up_input').attr("up_id", data.up_id);
  231. $('#up_input').attr("up_name", data.up_name);
  232. $('#up_input').attr("where_disney", 1);
  233. //下
  234. $('#down_input').val(data.down_name);
  235. $('#down_input').attr("down_id", data.down_id);
  236. $('#down_input').attr("down_name", data.down_name);
  237. $('#down_input').attr("where_disney", 0);
  238. }
  239. }
  240. function select_place(which_obj) {
  241. var if_can = $(which_obj).attr("where_disney");
  242. if(if_can == 0) {
  243. //非迪士尼才能选
  244. //拿到所有数据,存入缓存,跳转界面
  245. data = getStorJson('disney_tranship');
  246. data.data_cur = $('#time_string').attr('to_sql_time');
  247. data.data_cur_str = $("#time_string").html();
  248. data.up_id = $("#up_input").attr("up_id");
  249. data.up_name = $("#up_input").attr("up_name");
  250. data.down_id = $("#down_input").attr("down_id");
  251. data.down_name = $("#down_input").attr("down_name");
  252. data.week_day = $("#today").html();
  253. data.where_disney = $("#down_input").attr("where_disney");
  254. setStorJson('disney_tranship', data);
  255. var url = "hot_city.html?op_type=";
  256. var tt = getDateTime(4);
  257. if(data.where_disney == 1) {
  258. //迪士尼为终点,查起点
  259. url = url + "in";
  260. } else {
  261. //迪士尼为起点,查终点
  262. url = url + "out";
  263. }
  264. url = url + "&from=disney_tranship&station_id=3240&line_type=379&tt=" + tt;
  265. window.location.href = url; //地点选择
  266. }
  267. }
  268. function search_answer() {
  269. var start_area_id = '';
  270. var end_area_id = '';
  271. var temp_where = $("#down_input").attr("where_disney");
  272. if(temp_where == 1) {
  273. //迪士尼在下面
  274. end_area_id = $("#down_input").attr("down_id");
  275. start_area_id = $("#up_input").attr("up_id");
  276. } else {
  277. //迪士尼在上面
  278. end_area_id = $("#down_input").attr("down_id");
  279. start_area_id = $("#up_input").attr("up_id");
  280. }
  281. var temp_time = $('#time_string').attr('to_sql_time'); //时间
  282. if(start_area_id != '' && end_area_id != '' && temp_time != '') {
  283. window.location.href = "search_results.html?start_area_id=" + start_area_id +
  284. "&end_area_id=" + end_area_id +
  285. "&run_date=" + temp_time;
  286. } else {
  287. if(temp_where == 1) {
  288. alert('请选择出发地!');
  289. } else {
  290. alert('请选择目的地!');
  291. }
  292. }
  293. }