Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

217 řádky
7.5 KiB

  1. var tempdate = '';
  2. var run_date = "";
  3. var prod_id = getPar('prod_id');
  4. $(document).ready(function(){
  5. run_date = getPar('time');
  6. tempdate = run_date;
  7. var month = getMonthAndDayByDate(run_date,'month');
  8. var day = getMonthAndDayByDate(run_date,'day');
  9. $('#show_date').html(month+'月'+day+'日');
  10. var otherday = run_date;
  11. var nowdate = getDateTime(0);
  12. if (tempdate==nowdate) {
  13. $('#show_date').html(month+'月'+day+'日  今天');
  14. $('#left').removeClass('fontgreen_color');
  15. $('#left').addClass('commongray_color');
  16. $('#left').removeAttr('onclick');
  17. $('#left_img').attr('src','public/images/ic_return_d.png');
  18. } else{
  19. $('#show_date').html(month+'月'+day+'日');
  20. $('#left').removeClass('commongray_color');
  21. $('#left').addClass('fontgreen_color');
  22. $('#left').attr('onclick','leftDidClicked();');
  23. $('#left_img').attr('src','public/images/ic_return_n_l.png');
  24. }
  25. go_list();
  26. })
  27. $("#show_date").click(function(){
  28. window.location.href="calendar.html?from=query_result&prod_id="+prod_id;
  29. })
  30. function go_list(){
  31. $.ajax({
  32. url:base_api+"application/api/get_run_list.php", //请求地址
  33. data:{prod_id:prod_id,startDate:tempdate,page:"1",page_size:"1000"},
  34. type: "post",
  35. dataType: "json",
  36. success: function (data) {
  37. console.log(data);
  38. if(data.code == 0){
  39. if(data.ticket.length==0){
  40. reloadData(data.ticket);
  41. $("#no_result").show();
  42. }else{
  43. $("#no_result").hide();
  44. reloadData(data.ticket);
  45. }
  46. }else{
  47. alert(data.info);
  48. }
  49. }
  50. });
  51. }
  52. //获取前一天日期
  53. function before(d){
  54. d = new Date(d);
  55. d = +d - 1000*60*60*24;
  56. d = new Date(d);
  57. //return d;
  58. //格式化
  59. var year = ";" + d.getFullYear() + ";";
  60. var month = ";" + (d.getMonth()+0+1) + ";";
  61. var day = ";" + d.getDate() + ";";
  62. if(year.length < 4) {
  63. year = "0" + year;
  64. }
  65. if(month.length < 4) {
  66. month = "0" + month;
  67. }
  68. if(day.length < 4) {
  69. day = "0" + day;
  70. }
  71. var datestr = year + "-" + month + "-" + day;
  72. datestr = datestr.replace(/;/g, "");
  73. return datestr;
  74. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  75. }
  76. //获取后一天日期
  77. function after(d){
  78. d = new Date(d);
  79. d = +d + 1000*60*60*24;
  80. d = new Date(d);
  81. //return d;
  82. //格式化
  83. var year = ";" + d.getFullYear() + ";";
  84. var month = ";" + (d.getMonth()+0+1) + ";";
  85. var day = ";" + d.getDate() + ";";
  86. if(year.length < 4) {
  87. year = "0" + year;
  88. }
  89. if(month.length < 4) {
  90. month = "0" + month;
  91. }
  92. if(day.length < 4) {
  93. day = "0" + day;
  94. }
  95. var datestr = year + "-" + month + "-" + day;
  96. datestr = datestr.replace(/;/g, "");
  97. return datestr;
  98. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  99. }
  100. //点击了 前一天
  101. function leftDidClicked(){
  102. var nowdate = tempdate;
  103. var run_date = before(nowdate);
  104. tempdate = run_date;
  105. var nowdate = getDateTime(0);
  106. var month = getMonthAndDayByDate(run_date,'month');
  107. var day = getMonthAndDayByDate(run_date,'day');
  108. console.log('tempdate'+tempdate);
  109. console.log('nowdate'+nowdate);
  110. if (tempdate==nowdate) {
  111. $('#show_date').html(month+'月'+day+'日&nbsp;&nbsp;今天');
  112. $('#left').removeClass('fontgreen_color');
  113. $('#left').addClass('commongray_color');
  114. $('#left').removeAttr('onclick');
  115. $('#left_img').attr('src','public/images/ic_return_d.png');
  116. } else{
  117. $('#show_date').html(month+'月'+day+'日');
  118. $('#left').removeClass('commongray_color');
  119. $('#left').addClass('fontgreen_color');
  120. $('#left').attr('onclick','leftDidClicked();');
  121. $('#left_img').attr('src','public/images/ic_return_n_l.png');
  122. }
  123. go_list();
  124. }
  125. //点击了后一天
  126. function rightDidClicked(){
  127. var nowdate = tempdate;
  128. var run_date = after(nowdate);
  129. tempdate = run_date;
  130. var nowdate = getDateTime(0);
  131. var month = getMonthAndDayByDate(run_date,'month');
  132. var day = getMonthAndDayByDate(run_date,'day');
  133. if (tempdate==nowdate) {
  134. $('#show_date').html(month+'月'+day+'日&nbsp;&nbsp;今天');
  135. $('#left').removeClass('fontgreen_color');
  136. $('#left').addClass('commongray_color');
  137. $('#left').removeAttr('onclick');
  138. $('#left_img').attr('src','public/images/ic_return_d.png');
  139. } else{
  140. $('#show_date').html(month+'月'+day+'日');
  141. $('#left').removeClass('commongray_color');
  142. $('#left').addClass('fontgreen_color');
  143. $('#left').attr('onclick','leftDidClicked();');
  144. $('#left_img').attr('src','public/images/ic_return_n_l.png');
  145. }
  146. go_list();
  147. }
  148. function reloadData(data){
  149. var temp = "";
  150. for (var i=0;i<data.length;i++) {
  151. if(parseInt(data[i].stock)==0){
  152. temp += "<li num='"+i+"' class='ub ub-ver white_bg_color ui_radiu_all ui_m_b10'>"
  153. + '<div class="ub ub-f1 ui_m_l20 ui_m_r20 ui_p_t15 ui_p_b10 border_bom ub-ae">'
  154. + '<div class="ub-f1 ulev2 light_color">'+data[i].start_time+'</div>'
  155. + '<div class="ub-f1 text_right light_color">约3时10分</div>'
  156. + '</div>'
  157. + '<div class="ub ub-f1 ui_p_l20 ui_p_r20 ui_p_t10 ui_p_b15 border_bom ub-ae">'
  158. + '<div class="ub-f1">'
  159. + '<span class="ulev3 light_color">'+data[i].start_area+'</span>'
  160. + '<img style="width: 0.6rem;position: relative;top: -0.02rem;left:0.1rem" src="public/images/img_line_ga.png"/>'
  161. + '<span class="ulev3 light_color ui_m_l20">'+data[i].end_area+'</span>'
  162. + '</div>'
  163. + '<div class="ub-f1 text_right light_color ">¥<span class="ulev6 light_color">'+Math.ceil(data[i].price)+'</span></div>'
  164. + '</div>'
  165. + '<div style="background-color: #e5e5e5;" class="ub ub-f1 ui_p_l20 ui_p_r20 ui_p_t10 ui_p_b10">'
  166. + '<div class="ub-f1 light_color">6座奔驰商务车</div>'
  167. + '<div class="ub-f1 text_right light_color">已售罄</div>'
  168. + '</div>'
  169. + '</li>'
  170. }else{
  171. var spare_ticket = "";
  172. if(parseInt(data[i].stock)>=3){
  173. spare_ticket = '<div class="ub-f1 text_right grey_font">余票充足</div>'
  174. }else if(parseInt(data[i].stock)<3){
  175. console.log(data[i].stock)
  176. spare_ticket = '<div class="ub-f1 text_right red_font">余票紧张</div>'
  177. }
  178. temp += "<li num='"+i+"' class='ub ub-ver white_bg_color ui_radiu_all ui_m_b10 submit_order'>"
  179. + '<div class="ub ub-f1 ui_m_l20 ui_m_r20 ui_p_t15 ui_p_b10 border_bom ub-ae">'
  180. + '<div class="ub-f1 ulev2 lightblack_color">'+data[i].start_time+'</div>'
  181. + '<div class="ub-f1 text_right commongray_color">约3时10分</div>'
  182. + '</div>'
  183. + '<div class="ub ub-f1 ui_p_l20 ui_p_r20 ui_p_t10 ui_p_b15 border_bom ub-ae">'
  184. + '<div class="ub-f1">'
  185. + '<span class="ulev3 fontmiddle_color">'+data[i].start_area+'</span>'
  186. + '<img style="width: 0.6rem;position: relative;top: -0.02rem;left:0.1rem" src="public/images/img_line_gr.png"/>'
  187. + '<span class="ulev3 fontmiddle_color ui_m_l20">'+data[i].end_area+'</span>'
  188. + '</div>'
  189. + '<div class="ub-f1 text_right main_font_color ">¥<span class="ulev6 main_font_color">'+Math.ceil(data[i].price)+'</span></div>'
  190. + '</div>'
  191. + '<div class="ub ub-f1 ui_p_l20 ui_p_r20 ui_p_t10 ui_p_b10">'
  192. + '<div class="ub-f1 main_font_color">6座奔驰商务车</div>'
  193. + spare_ticket
  194. + '</div>'
  195. + '</li>'
  196. }
  197. }
  198. $("#list").html(temp);
  199. $(".submit_order").click(function(){
  200. var num = $(this).attr("num")
  201. setStorJson("list_order",data[$(this).attr("num")]);
  202. window.location.href="submit_order.html";
  203. });
  204. }