|
- var tempdate = '';
- var run_date = "";
- var prod_id = getPar('prod_id');
- $(document).ready(function(){
- run_date = getPar('time');
- tempdate = run_date;
- var month = getMonthAndDayByDate(run_date,'month');
- var day = getMonthAndDayByDate(run_date,'day');
- $('#show_date').html(month+'月'+day+'日');
-
- var otherday = run_date;
- var nowdate = getDateTime(0);
- if (tempdate==nowdate) {
- $('#show_date').html(month+'月'+day+'日 今天');
- $('#left').removeClass('fontgreen_color');
- $('#left').addClass('commongray_color');
- $('#left').removeAttr('onclick');
- $('#left_img').attr('src','public/images/ic_return_d.png');
- } else{
- $('#show_date').html(month+'月'+day+'日');
- $('#left').removeClass('commongray_color');
- $('#left').addClass('fontgreen_color');
- $('#left').attr('onclick','leftDidClicked();');
- $('#left_img').attr('src','public/images/ic_return_n_l.png');
- }
- go_list();
- })
-
- $("#show_date").click(function(){
- window.location.href="calendar.html?from=query_result&prod_id="+prod_id;
- })
-
- function go_list(){
- $.ajax({
- url:base_api+"application/api/get_run_list.php", //请求地址
- data:{prod_id:prod_id,startDate:tempdate,page:"1",page_size:"1000"},
- type: "post",
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == 0){
- if(data.ticket.length==0){
- reloadData(data.ticket);
- $("#no_result").show();
-
- }else{
- $("#no_result").hide();
- reloadData(data.ticket);
- }
-
- }else{
- alert(data.info);
- }
-
- }
- });
- }
- //获取前一天日期
- function before(d){
- d = new Date(d);
- d = +d - 1000*60*60*24;
- d = new Date(d);
- //return d;
- //格式化
- var year = ";" + d.getFullYear() + ";";
- var month = ";" + (d.getMonth()+0+1) + ";";
- var day = ";" + d.getDate() + ";";
- if(year.length < 4) {
- year = "0" + year;
- }
- if(month.length < 4) {
- month = "0" + month;
- }
- if(day.length < 4) {
- day = "0" + day;
- }
- var datestr = year + "-" + month + "-" + day;
- datestr = datestr.replace(/;/g, "");
- return datestr;
- // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
-
- }
- //获取后一天日期
- function after(d){
- d = new Date(d);
- d = +d + 1000*60*60*24;
- d = new Date(d);
- //return d;
- //格式化
- var year = ";" + d.getFullYear() + ";";
- var month = ";" + (d.getMonth()+0+1) + ";";
- var day = ";" + d.getDate() + ";";
- if(year.length < 4) {
- year = "0" + year;
- }
- if(month.length < 4) {
- month = "0" + month;
- }
- if(day.length < 4) {
- day = "0" + day;
- }
- var datestr = year + "-" + month + "-" + day;
- datestr = datestr.replace(/;/g, "");
- return datestr;
- // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
-
- }
-
- //点击了 前一天
- function leftDidClicked(){
- var nowdate = tempdate;
- var run_date = before(nowdate);
- tempdate = run_date;
- var nowdate = getDateTime(0);
- var month = getMonthAndDayByDate(run_date,'month');
- var day = getMonthAndDayByDate(run_date,'day');
- console.log('tempdate'+tempdate);
- console.log('nowdate'+nowdate);
- if (tempdate==nowdate) {
- $('#show_date').html(month+'月'+day+'日 今天');
- $('#left').removeClass('fontgreen_color');
- $('#left').addClass('commongray_color');
- $('#left').removeAttr('onclick');
- $('#left_img').attr('src','public/images/ic_return_d.png');
- } else{
- $('#show_date').html(month+'月'+day+'日');
- $('#left').removeClass('commongray_color');
- $('#left').addClass('fontgreen_color');
- $('#left').attr('onclick','leftDidClicked();');
- $('#left_img').attr('src','public/images/ic_return_n_l.png');
- }
- go_list();
- }
- //点击了后一天
- function rightDidClicked(){
- var nowdate = tempdate;
- var run_date = after(nowdate);
- tempdate = run_date;
- var nowdate = getDateTime(0);
- var month = getMonthAndDayByDate(run_date,'month');
- var day = getMonthAndDayByDate(run_date,'day');
- if (tempdate==nowdate) {
- $('#show_date').html(month+'月'+day+'日 今天');
- $('#left').removeClass('fontgreen_color');
- $('#left').addClass('commongray_color');
- $('#left').removeAttr('onclick');
- $('#left_img').attr('src','public/images/ic_return_d.png');
- } else{
- $('#show_date').html(month+'月'+day+'日');
- $('#left').removeClass('commongray_color');
- $('#left').addClass('fontgreen_color');
- $('#left').attr('onclick','leftDidClicked();');
- $('#left_img').attr('src','public/images/ic_return_n_l.png');
- }
- go_list();
-
-
- }
- function reloadData(data){
- var temp = "";
- for (var i=0;i<data.length;i++) {
- if(parseInt(data[i].stock)==0){
- temp += "<li num='"+i+"' class='ub ub-ver white_bg_color ui_radiu_all ui_m_b10'>"
- + '<div class="ub ub-f1 ui_m_l20 ui_m_r20 ui_p_t15 ui_p_b10 border_bom ub-ae">'
- + '<div class="ub-f1 ulev2 light_color">'+data[i].start_time+'</div>'
- + '<div class="ub-f1 text_right light_color">约3时10分</div>'
- + '</div>'
- + '<div class="ub ub-f1 ui_p_l20 ui_p_r20 ui_p_t10 ui_p_b15 border_bom ub-ae">'
- + '<div class="ub-f1">'
- + '<span class="ulev3 light_color">'+data[i].start_area+'</span>'
- + '<img style="width: 0.6rem;position: relative;top: -0.02rem;left:0.1rem" src="public/images/img_line_ga.png"/>'
- + '<span class="ulev3 light_color ui_m_l20">'+data[i].end_area+'</span>'
- + '</div>'
- + '<div class="ub-f1 text_right light_color ">¥<span class="ulev6 light_color">'+Math.ceil(data[i].price)+'</span></div>'
- + '</div>'
- + '<div style="background-color: #e5e5e5;" class="ub ub-f1 ui_p_l20 ui_p_r20 ui_p_t10 ui_p_b10">'
- + '<div class="ub-f1 light_color">6座奔驰商务车</div>'
- + '<div class="ub-f1 text_right light_color">已售罄</div>'
- + '</div>'
- + '</li>'
- }else{
- var spare_ticket = "";
- if(parseInt(data[i].stock)>=3){
- spare_ticket = '<div class="ub-f1 text_right grey_font">余票充足</div>'
- }else if(parseInt(data[i].stock)<3){
- console.log(data[i].stock)
- spare_ticket = '<div class="ub-f1 text_right red_font">余票紧张</div>'
- }
- temp += "<li num='"+i+"' class='ub ub-ver white_bg_color ui_radiu_all ui_m_b10 submit_order'>"
- + '<div class="ub ub-f1 ui_m_l20 ui_m_r20 ui_p_t15 ui_p_b10 border_bom ub-ae">'
- + '<div class="ub-f1 ulev2 lightblack_color">'+data[i].start_time+'</div>'
- + '<div class="ub-f1 text_right commongray_color">约3时10分</div>'
- + '</div>'
- + '<div class="ub ub-f1 ui_p_l20 ui_p_r20 ui_p_t10 ui_p_b15 border_bom ub-ae">'
- + '<div class="ub-f1">'
- + '<span class="ulev3 fontmiddle_color">'+data[i].start_area+'</span>'
- + '<img style="width: 0.6rem;position: relative;top: -0.02rem;left:0.1rem" src="public/images/img_line_gr.png"/>'
- + '<span class="ulev3 fontmiddle_color ui_m_l20">'+data[i].end_area+'</span>'
- + '</div>'
- + '<div class="ub-f1 text_right main_font_color ">¥<span class="ulev6 main_font_color">'+Math.ceil(data[i].price)+'</span></div>'
- + '</div>'
- + '<div class="ub ub-f1 ui_p_l20 ui_p_r20 ui_p_t10 ui_p_b10">'
- + '<div class="ub-f1 main_font_color">6座奔驰商务车</div>'
- + spare_ticket
- + '</div>'
- + '</li>'
- }
-
- }
- $("#list").html(temp);
- $(".submit_order").click(function(){
- var num = $(this).attr("num")
- setStorJson("list_order",data[$(this).attr("num")]);
- window.location.href="submit_order.html";
- });
- }
|