|
- //Created by HBuilder.
- //User: Miracle~
- //Date: 2016/11/14
- //Time: 19:00
- //缓存数据
-
- $("#loading_html").show();
- var where_disney;
- var up_id;
- var up_name;
- var down_id;
- var down_name;
- var data_cur;
- var data_cur_str;
- var week_day;
- var data = {
- where_disney: where_disney, //迪士尼页面所在位置 1在下面0在上面down_input编号
- up_name: up_name, //上面inputname
- up_id: up_id, //上面inputid
- down_id: down_id,
- down_name: down_name,
- data_cur: data_cur, //时间2016-11-11
- data_cur_str: data_cur_str, //时间11月11日
- week_day: week_day, //星期几
-
- };
- //开始加载
- window.onload = function() {
- var data_cur = getPar('data_cur');
- var data_cur_str = getPar('data_cur_str');
- var week_day = getPar('week_day');
- if(data_cur == '' || data_cur_str == '' || week_day == '') {
- //不是日历界面返回
- if(getStorJson('disney_tranship') == null) {
- //没存过第一次加载
- data.where_disney = 1; //默认迪士尼在下面
-
- data.data_cur =after(getDateTime(0));//2016-11-11 明天
- temp_time = data.data_cur.replace(/-/g, "/");
- data.week_day = getWeekDay(temp_time);
- //data.week_day = '今天'; //今天显示今天
- // data.data_cur_str = getDateTime(11); //11月11日
- var month = getMonthAndDayByDate(data.data_cur,'month');
- var day = getMonthAndDayByDate(data.data_cur,'day');
- var new_newdate = month + '月' + day + '日';
- data.data_cur_str = new_newdate;
-
- //data.data_cur = getDateTime(13); //2016-11-11
- //data.week_day = '今天'; //今天显示今天
- //data.data_cur_str = getDateTime(11); //11月11日
- data.up_name = ''; //初始化缓存
- data.up_id = ''; //初始化缓存
- data.down_name = '上海迪士尼度假区'; //初始化缓存
- data.down_id = '3240'; //初始化缓存
- setStorJson('disney_tranship', data);
- //页面加载
- $("#time_string").html(data.data_cur_str);
- $("#today").html(data.week_day);
- $('#time_string').attr('to_sql_time', data.data_cur);
- //上
- $('#up_input').val(data.up_name);
- $('#up_input').attr("up_id", data.up_id);
- $('#up_input').attr("up_name", data.up_name);
- $('#up_input').attr("where_disney", 0);
- //下
- $('#down_input').val(data.down_name);
- $('#down_input').attr("down_id", data.down_id);
- $('#down_input').attr("down_name", data.down_name);
- $('#down_input').attr("where_disney", 1);
-
- } else {
- //不是第一次加载
- data = getStorJson('disney_tranship');
- //得到数据加载界面
- var temp = data.data_cur.replace(/-/g, '/');
- var week_day = getWeekDay(temp);
- data.week_day = week_day;
- if(data.where_disney == 1) {
- //迪士尼在下面
- $("#time_string").html(data.data_cur_str);
- $("#today").html(data.week_day);
- $('#time_string').attr('to_sql_time', data.data_cur);
- //上
- $('#up_input').val(data.up_name);
- $('#up_input').attr("up_id", data.up_id);
- $('#up_input').attr("up_name", data.up_name);
- $('#up_input').attr("where_disney", 0);
- //下
- $('#down_input').val(data.down_name);
- $('#down_input').attr("down_id", data.down_id);
- $('#down_input').attr("down_name", data.down_name);
- $('#down_input').attr("where_disney", 1);
-
- } else {
- //迪士尼在上面
- $("#time_string").html(data.data_cur_str);
- $("#today").html(data.week_day);
- $('#time_string').attr('to_sql_time', data.data_cur);
- //上
- $('#up_input').val(data.up_name);
- $('#up_input').attr("up_id", data.up_id);
- $('#up_input').attr("up_name", data.up_name);
- $('#up_input').attr("where_disney", 1);
- //下
- $('#down_input').val(data.down_name);
- $('#down_input').attr("down_id", data.down_id);
- $('#down_input').attr("down_name", data.down_name);
- $('#down_input').attr("where_disney", 0);
- }
-
- }
-
- } else {
- //日历界面返回
- data = getStorJson('disney_tranship'); //得到缓存
- var temp = data.data_cur.replace(/-/g, '/');
- var week_day = getWeekDay(temp);
- data.week_day = week_day;
- data.data_cur = getPar('data_cur');
- data.data_cur_str = getPar('data_cur_str');
- data.week_day = getPar('week_day');
- var temp = data.data_cur.replace(/-/g, '/');
- var week_day = getWeekDay(temp);
- data.week_day = week_day;
- if(getDateTime(11) == data.data_cur_str) {
- //显示今天
- data.week_day = '今天';
- }
- setStorJson('disney_tranship', data);
- //加载界面
- //得到数据加载界面
- if(data.where_disney == 1) {
- //迪士尼在下面
- $("#time_string").html(data.data_cur_str);
- $("#today").html(data.week_day);
- $('#time_string').attr('to_sql_time', data.data_cur);
- //上
- $('#up_input').val(data.up_name);
- $('#up_input').attr("up_id", data.up_id);
- $('#up_input').attr("up_name", data.up_name);
- $('#up_input').attr("where_disney", 0);
- //下
- $('#down_input').val(data.down_name);
- $('#down_input').attr("down_id", data.down_id);
- $('#down_input').attr("down_name", data.down_name);
- $('#down_input').attr("where_disney", 1);
-
- } else {
- //迪士尼在上面
- $("#time_string").html(data.data_cur_str);
- $("#today").html(data.week_day);
- $('#time_string').attr('to_sql_time', data.data_cur);
- //上
- $('#up_input').val(data.up_name);
- $('#up_input').attr("up_id", data.up_id);
- $('#up_input').attr("up_name", data.up_name);
- $('#up_input').attr("where_disney", 1);
- //下
- $('#down_input').val(data.down_name);
- $('#down_input').attr("down_id", data.down_id);
- $('#down_input').attr("down_name", data.down_name);
- $('#down_input').attr("where_disney", 0);
- }
-
- }
-
- }
- //选择日期
- function select_date() {
- data = getStorJson('disney_tranship');
- data.where_disney = $("#down_input").attr("where_disney"); //得到where_disney属性
- data.down_id = $("#down_input").attr("down_id");
- data.down_name = $("#down_input").attr("down_name");
- data.up_id = $("#up_input").attr("up_id");
- data.up_name = $("#up_input").attr("up_name");
- data.data_cur = $('#time_string').attr('to_sql_time');
- data.data_cur_str = $('#time_string').html();
- data.week_day = $('#today').html();
- setStorJson('disney_tranship', data); //存入缓存
- window.location.href = "calendar.html?from=disney_tranship"; //跳转日历
- }
- //切换起终点
- function change_where() {
- data = getStorJson('disney_tranship');
- data.data_cur = $('#time_string').attr('to_sql_time');
- data.data_cur_str = $("#time_string").html();
- data.up_id = $("#up_input").attr("up_id");
- data.up_name = $("#up_input").attr("up_name");
- data.down_id = $("#down_input").attr("down_id");
- data.down_name = $("#down_input").attr("down_name");
- data.week_day = $("#today").html();
- data.where_disney = $("#down_input").attr("where_disney");
- var temp_data;
- if(data.where_disney == 1) {
- //迪士尼在下面,变成上面
- $("#down_input").attr("where_disney", 0);
- $("#up_input").attr("where_disney", 1);
- data.where_disney = 0;
- temp_data = data.up_id
- data.up_id = data.down_id;
- data.down_id = temp_data;
- temp_data = data.up_name;
- data.up_name = data.down_name;
- data.down_name = temp_data;
- } else {
- //迪士尼在上面,变成下面
- $("#down_input").attr("where_disney", 1);
- $("#up_input").attr("where_disney", 0);
- data.where_disney = 1;
- temp_data = data.up_id
- data.up_id = data.down_id;
- data.down_id = temp_data;
- temp_data = data.up_name;
- data.up_name = data.down_name;
- data.down_name = temp_data;
- }
- setStorJson('disney_tranship', data);
- //载入界面
- if(data.where_disney == 1) {
- //迪士尼在下面
- $("#time_string").html(data.data_cur_str);
- $("#today").html(data.week_day);
- $('#time_string').attr('to_sql_time', data.data_cur);
- //上
- $('#up_input').val(data.up_name);
- $('#up_input').attr("up_id", data.up_id);
- $('#up_input').attr("up_name", data.up_name);
- $('#up_input').attr("where_disney", 0);
- //下
- $('#down_input').val(data.down_name);
- $('#down_input').attr("down_id", data.down_id);
- $('#down_input').attr("down_name", data.down_name);
- $('#down_input').attr("where_disney", 1);
-
- } else {
- //迪士尼在上面
- $("#time_string").html(data.data_cur_str);
- $("#today").html(data.week_day);
- $('#time_string').attr('to_sql_time', data.data_cur);
- //上
- $('#up_input').val(data.up_name);
- $('#up_input').attr("up_id", data.up_id);
- $('#up_input').attr("up_name", data.up_name);
- $('#up_input').attr("where_disney", 1);
- //下
- $('#down_input').val(data.down_name);
- $('#down_input').attr("down_id", data.down_id);
- $('#down_input').attr("down_name", data.down_name);
- $('#down_input').attr("where_disney", 0);
- }
- }
-
- function select_place(which_obj) {
- var if_can = $(which_obj).attr("where_disney");
- if(if_can == 0) {
- //非迪士尼才能选
- //拿到所有数据,存入缓存,跳转界面
- data = getStorJson('disney_tranship');
- data.data_cur = $('#time_string').attr('to_sql_time');
- data.data_cur_str = $("#time_string").html();
- data.up_id = $("#up_input").attr("up_id");
- data.up_name = $("#up_input").attr("up_name");
- data.down_id = $("#down_input").attr("down_id");
- data.down_name = $("#down_input").attr("down_name");
- data.week_day = $("#today").html();
- data.where_disney = $("#down_input").attr("where_disney");
- setStorJson('disney_tranship', data);
- var url = "hot_city.html?op_type=";
- var tt = getDateTime(4);
- if(data.where_disney == 1) {
- //迪士尼为终点,查起点
- url = url + "in";
- } else {
- //迪士尼为起点,查终点
- url = url + "out";
- }
- url = url + "&from=disney_tranship&station_id=3240&line_type=379&tt=" + tt;
- window.location.href = url; //地点选择
- }
-
- }
-
- function search_answer() {
- var start_area_id = '';
- var end_area_id = '';
- var temp_where = $("#down_input").attr("where_disney");
- if(temp_where == 1) {
- //迪士尼在下面
- end_area_id = $("#down_input").attr("down_id");
- start_area_id = $("#up_input").attr("up_id");
- } else {
- //迪士尼在上面
- end_area_id = $("#down_input").attr("down_id");
- start_area_id = $("#up_input").attr("up_id");
- }
- var temp_time = $('#time_string').attr('to_sql_time'); //时间
- if(start_area_id != '' && end_area_id != '' && temp_time != '') {
- window.location.href = "search_results.html?start_area_id=" + start_area_id +
- "&end_area_id=" + end_area_id +
- "&run_date=" + temp_time;
- } else {
- if(temp_where == 1) {
- alert('请选择出发地!');
- } else {
- alert('请选择目的地!');
- }
- }
-
- }
|