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.
 
 
 
 
 
 

236 lines
7.5 KiB

  1. $("#loading_html").show();
  2. //当前时间
  3. var tmonth = new Date();
  4. var year = tmonth.getFullYear();
  5. var month = tmonth.getMonth();
  6. var dom = $('.month');
  7. //中间变量 记录
  8. var tttmonth = '';
  9. var tyear = '';
  10. window.onload = function() {
  11. !dom.hasClass("amonth") && dom.addClass("amonth");
  12. //当前日期
  13. var date1 = new Date(year, month);
  14. //当前月份
  15. var tomonth = new Date().getMonth();
  16. //
  17. var today = new Date().getDate();
  18. var dayhtml = [];
  19. var week = ["日", "一", "二", "三", "四", "五", "六"];
  20. for(var t = 1; t <= 3; t++) {
  21. dayhtml.push('<div style="clear:both">');
  22. var date = date1;
  23. month = date.getMonth() + t - 1;
  24. if(month >= 11) {
  25. tyear = year + 1;
  26. tttmonth = month - 12;
  27. // month = 0;
  28. } else {
  29. tyear = year;
  30. tttmonth = month;
  31. }
  32. if(tttmonth == -1) {
  33. tttmonth = 11;
  34. tyear = year;
  35. }
  36. dayhtml.push('<div class="month_title"><span class="current_month">' + (tttmonth + 1) + '月' + '</span><span class="current_year">' + tyear + '</span></div>')
  37. // dayhtml.push();
  38. // $.each(week,function(i,v){
  39. // dayhtml.push('<div class="aweek" style="float:left">'+week[i]+'</div>')
  40. // });
  41. var str = '';
  42. $.each(week, function(i, v) {
  43. str += '<div style="padding-top: 0.08rem;" class="aweek ub-f1 text_middle ui_p_b15">' + week[i] + '</div>';
  44. });
  45. dayhtml.push('<div class="ub" style="margin-left:0.2rem;margin-right:0.2rem;">' + str + '</div>')
  46. var nextdate = new Date(year, month)
  47. var firstweek = nextdate.getDay();
  48. // var firstweek = month.getDay();
  49. // var first = month.getDay();
  50. var allday = new Date(parseInt(year), (parseInt(month) + 1), 0).getDate();
  51. var daystr = '<div style="margin-left:0.2rem;margin-right:0.2rem;">';
  52. for(var i = 0; i < firstweek; i++) {
  53. daystr += '<div class="aday"></div>'
  54. };
  55. var data_cur_str = ''; //日期str
  56. var data_cur = ''; //日期-
  57. // 得到去程日期
  58. var go_run_date = getPar('go_date');
  59. // var date1 = new Date(go_run_date.replace(/\-/g, '/'));
  60. // // 判断日期是否合理
  61. // var date1 = new Date(start_date.replace(/\-/g, '/'));
  62. // var date2 = new Date(end_date.replace(/\-/g, '/'));
  63. // if (date1>date2 || end_date=="") {
  64. // $('#id-date-picker-2').val(start_date);
  65. // }
  66. if(month == tomonth) {
  67. for(i = 1; i <= allday; i++) {
  68. var t_m = (tttmonth + 1);
  69. var t_m_str = t_m;
  70. var t_d_str = i;
  71. if(t_m <= 9) {
  72. t_m_str = "0" + t_m;
  73. }
  74. if(i <= 9) {
  75. t_d_str = "0" + i;
  76. }
  77. data_cur_str = t_m_str + "月" + t_d_str + '日';
  78. data_cur = tyear + "-" + (Array(2).join(0) + (tttmonth + 1)).slice(-2) + "-" + (Array(2).join(0) + i).slice(-2);
  79. var run_day = go_run_date.substring(8);
  80. if(i < parseInt(run_day)) {
  81. daystr += '<div class="aday disday">' + i + '</div>';
  82. } else {
  83. if(i == today) {
  84. // if(getPar('from')=="fill_order"){
  85. // daystr+='<div class="aday disday">'+i+'</div>';
  86. // }else{
  87. daystr += '<div data-cur-str="' + data_cur_str + '" data-cur="' + data_cur + '" class="aday canday today">今天</div>';
  88. // }
  89. } else if(i < today) {
  90. daystr += '<div class="aday disday">' + i + '</div>';
  91. } else {
  92. daystr += '<div data-cur-str="' + data_cur_str + '" data-cur="' + data_cur + '"class="aday canday">' + i + '</div>';
  93. }
  94. }
  95. }
  96. } else if(month < tomonth) {
  97. for(i = 1; i <= allday; i++) {
  98. daystr += '<div class="aday disday">' + i + '</div>'
  99. }
  100. } else {
  101. for(i = 1; i <= allday; i++) {
  102. var t_m = (tttmonth + 1);
  103. var t_m_str = t_m;
  104. var t_d_str = i;
  105. if(t_m <= 9) {
  106. t_m_str = "0" + t_m;
  107. }
  108. if(i <= 9) {
  109. t_d_str = "0" + i;
  110. }
  111. data_cur_str = t_m_str + "月" + t_d_str + '日';
  112. data_cur = tyear + "-" + (Array(2).join(0) + (tttmonth + 1)).slice(-2) + "-" + (Array(2).join(0) + i).slice(-2);
  113. daystr += '<div data-cur-str="' + data_cur_str + '" data-cur="' + data_cur + '"class="aday canday">' + i + '</div>'
  114. }
  115. }
  116. daystr += "</div>";
  117. dayhtml.push(daystr);
  118. dayhtml.push('</div>');
  119. }
  120. dom.html(dayhtml.join(""))
  121. //选中去程的日期
  122. $(".canday").each(function(index, domE) {
  123. if($(this).attr('data-cur') == getPar('go_run_date')) {
  124. $(this).removeClass('select_day');
  125. $(this).removeClass('select_go_day');
  126. $(this).addClass('select_go_day');
  127. };
  128. })
  129. $(".canday").on("click", function() {
  130. $(".canday").removeClass('select_day');
  131. $(this).addClass('select_day');
  132. //判断从哪个页面跳转过来
  133. var from = getPar('from');
  134. //出行预订
  135. if(from == "travel_book") {
  136. var data_cur = $(this).attr('data-cur');
  137. var data_cur_str = $(this).attr('data-cur-str');
  138. var tt = getDateTime(4);
  139. var listURL = 'travel_book.html?run_date=' + data_cur + "&run_date_str=" + data_cur_str + "&tt=" + tt ;
  140. listURL = encodeURI(listURL);
  141. window.location.href = listURL;
  142. }
  143. //订单详情
  144. if(from == "fill_order") {
  145. // go_ticket_id='+go_ticket_id+'&go_date='+go_date+'&back=back'+'&from=fill_order';
  146. var start_area_id = getPar("start_area_id");
  147. var end_area_id = getPar("end_area_id");
  148. var data_cur_str = $(this).attr('data-cur-str');
  149. var data_cur = $(this).attr('data-cur');
  150. var tt = getDateTime(4);
  151. var listURL = "search_results.html?start_area_id=" + start_area_id + "&end_area_id=" + end_area_id + "&run_date=" + data_cur + "&if_go=back" +"&go_run_date=" + getPar('go_run_date');
  152. listURL = encodeURI(listURL);
  153. window.location.href = listURL;
  154. // 测试返程列表接口。。。
  155. // var url=base_api+"./zz_wxsct/control.php";
  156. // var parm={
  157. // type:"bus_reservation_list_back",
  158. // date:go_date,
  159. // ticket_id:go_ticket_id
  160. // }
  161. // ZZLog(url+JSON.stringify(parm));
  162. // $.post(url,parm,function(res_data){
  163. // ZZLog(res_data);
  164. // res_data=JSON.parse(res_data);
  165. // ZZLog(res_data);
  166. // });
  167. }
  168. if(from == "search_results"){
  169. var data_cur_str = $(this).attr('data-cur-str');
  170. var data_cur = $(this).attr('data-cur');
  171. var start_area_id = getPar('start_area_id');
  172. var end_area_id = getPar('end_area_id');
  173. var ticket_id = getPar('go_ticket_id');
  174. var listURL = '';
  175. if(ticket_id != '') {
  176. listURL = "./search_results.html?run_date=" + data_cur + "&data_cur_str=" + data_cur_str + "&start_area_id=" + start_area_id + "&end_area_id=" + end_area_id + "&from=search_results" + "&go_run_date=" + getPar('go_run_date');
  177. } else {
  178. listURL = "./search_results.html?run_date=" + data_cur + "&data_cur_str=" + data_cur_str + "&start_area_id=" + start_area_id + "&end_area_id=" + end_area_id + "&from=search_results" + "&go_run_date=" + getPar('go_run_date');
  179. }
  180. listURL = encodeURI(listURL);
  181. window.location.href = listURL;
  182. }
  183. if(from == "pick_drop") {
  184. var data_cur_str = $(this).attr('data-cur-str');
  185. var data_cur = $(this).attr('data-cur');
  186. var temp=data_cur.replace('-','/');
  187. var week_day = getWeekDay(temp);
  188. window.location.href = "pick_drop_person.html?data_cur=" + data_cur + "&data_cur_str=" + data_cur_str+"&week_day=" + week_day + "&go_run_date=" + getPar('go_run_date') ;
  189. }
  190. if(from == "disney_tranship") {
  191. var data_cur_str = $(this).attr('data-cur-str');
  192. var data_cur = $(this).attr('data-cur');
  193. var temp=data_cur.replace(/-/g,"/");
  194. var week_day = getWeekDay(temp);
  195. window.location.href = "disney_tranship.html?data_cur=" + data_cur + "&data_cur_str=" + data_cur_str+"&week_day=" + week_day ;
  196. }
  197. // $(".canday").removeClass('thisday');
  198. // $(this).next().addClass("placesel");
  199. // $(this).addClass("thisday");
  200. })
  201. }