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.
 
 
 
 
 

226 lines
6.4 KiB

  1. //当前时间
  2. var tmonth = new Date();
  3. var year = tmonth.getFullYear();
  4. var month = tmonth.getMonth();
  5. var dom = $('.month');
  6. //中间变量 记录
  7. var tttmonth = '';
  8. var tyear = '';
  9. window.onload = function(){
  10. !dom.hasClass("amonth")&&dom.addClass("amonth");
  11. //当前日期
  12. var date1 = new Date(year,month);
  13. //当前月份
  14. var tomonth = new Date().getMonth();
  15. //
  16. var today = new Date().getDate();
  17. var dayhtml = [];
  18. var week = ["日","一","二","三","四","五","六"];
  19. for (var t=1;t<=3;t++){
  20. dayhtml.push('<div style="clear:both">');
  21. var date = date1;
  22. month = date.getMonth()+t-1;
  23. if (month>=11) {
  24. tyear = year+1;
  25. tttmonth = month-12 ;
  26. // month = 0;
  27. }else{
  28. tyear =year;
  29. tttmonth = month;
  30. }
  31. if(tttmonth==-1){
  32. tttmonth=11;
  33. tyear = year;
  34. }
  35. dayhtml.push('<div class="month_title"><span class="current_month">'+(tttmonth+1)+'月'+'</span><span class="current_year">'+tyear+'</span></div>')
  36. // dayhtml.push();
  37. // $.each(week,function(i,v){
  38. // dayhtml.push('<div class="aweek" style="float:left">'+week[i]+'</div>')
  39. // });
  40. var str = '';
  41. $.each(week,function(i,v){
  42. str += '<div class="aweek ub-f1 text_middle ui_p_t15 ui_p_b15">'+week[i]+'</div>';
  43. });
  44. dayhtml.push('<div class="ub" style="margin-left:0.2rem;margin-right:0.2rem;">'+str+'</div>')
  45. var nextdate = new Date(year,month)
  46. var firstweek = nextdate.getDay();
  47. // var firstweek = month.getDay();
  48. // var first = month.getDay();
  49. var allday = new Date(parseInt(year),(parseInt(month)+1),0).getDate();
  50. var daystr = '<div style="margin-left:0.2rem;margin-right:0.2rem;">';
  51. for(var i = 0;i<firstweek;i++){
  52. daystr+='<div class="aday"></div>'
  53. };
  54. var data_cur_str=''; //日期str
  55. var data_cur=''; //日期-
  56. // 得到去程日期
  57. var go_run_date=getPar('go_date');
  58. // var date1 = new Date(go_run_date.replace(/\-/g, '/'));
  59. // // 判断日期是否合理
  60. // var date1 = new Date(start_date.replace(/\-/g, '/'));
  61. // var date2 = new Date(end_date.replace(/\-/g, '/'));
  62. // if (date1>date2 || end_date=="") {
  63. // $('#id-date-picker-2').val(start_date);
  64. // }
  65. if (month==tomonth){
  66. for(i=1;i<=allday;i++){
  67. var t_m=(tttmonth+1);
  68. var t_m_str=t_m;
  69. var t_d_str=i;
  70. if(t_m<=9){
  71. t_m_str="0"+t_m;
  72. }
  73. if(i<=9){
  74. t_d_str="0"+i;
  75. }
  76. data_cur_str=t_m_str+"月"+t_d_str+'日';
  77. data_cur=tyear+"-"+(Array(2).join(0)+(tttmonth+1)).slice(-2)+"-"+(Array(2).join(0)+i).slice(-2);
  78. var run_day=go_run_date.substring(8);
  79. if(i<parseInt(run_day)){
  80. daystr+='<div class="aday disday">'+i+'</div>';
  81. }else{
  82. if(i==today){
  83. // if(getPar('from')=="fill_order"){
  84. // daystr+='<div class="aday disday">'+i+'</div>';
  85. // }else{
  86. daystr+='<div data-cur-str="'+data_cur_str+'" data-cur="'+data_cur+'" class="aday canday today">今天</div>';
  87. // }
  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_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 go_ticket_id=getPar('go_ticket_id');
  147. var go_date=getPar('go_date');
  148. var data_cur=$(this).attr('data-cur');
  149. var data_cur_str=$(this).attr('data-cur-str');
  150. var tt=getDateTime(4);
  151. var listURL="search_results.html?go_date="+data_cur+"&go_ticket_id="+go_ticket_id+"&tt="+tt;
  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_type = getPar('start_area_type');
  172. var start_area_id = getPar('start_area_id');
  173. var end_area_id = getPar('end_area_id');
  174. var end_area_type = getPar('end_area_type');
  175. var ticket_id = getPar('go_ticket_id');
  176. var listURL = '';
  177. if (ticket_id != '') {
  178. listURL="./search_results.html?run_date="+data_cur+"&data_cur_str="+data_cur_str+"&start_area_type="+start_area_type+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&end_area_type="+end_area_type+"&go_ticket_id="+ticket_id+"&from=search_results";
  179. }else{
  180. listURL="./search_results.html?run_date="+data_cur+"&data_cur_str="+data_cur_str+"&start_area_type="+start_area_type+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&end_area_type="+end_area_type+"&go_ticket_id="+"&from=search_results";
  181. }
  182. listURL=encodeURI(listURL);
  183. window.location.href=listURL;
  184. }
  185. // $(".canday").removeClass('thisday');
  186. // $(this).next().addClass("placesel");
  187. // $(this).addClass("thisday");
  188. })
  189. }