//發送最低價ajax請求
function getlowerPrice(date){
console.log(date);
//在這裏處理日期下面的最低價
$.ajax({
url:basepath+"/tpticket/getlowesttprice",
type:"POST",
data:"departcity="+$("#departcity").val()+"&arrivecity="+$("#arrivecity").val()+"&date="+date+ "&passengertype=" + $("#passengertype").val(),
dataType:"JSON",
success: function(data){
console.log(data);
var dataLength = eval(data.lowerprice).length;
for(var i=0;i<dataLength;i++){
var strsspan = "<span>" + data.lowerprice[i].price+"</span>";
//$(".searchDate li[date='" +data.lowerprice[i].date+ "']").appendTo(strsspan);
$(".searchDate li[date='" +data.lowerprice[i].date+ "']").append(strsspan);
//console.log($(".searchDate>li").attr("data"));
}
}
});
}
// 獲得前N天或後N天的日期
function showdate(n) {
var d = new Date($("#date").val());
var uom = new Date(d- 0 + n * 86400000);
uom = uom.getFullYear() + "-" + (uom.getMonth() + 1)
+ "-" + uom.getDate();
return uom;
}
function makeWeekDate(){
for(var i=-3;i<4;i++){
getlowerPrice(showdate(i));
}
}
makeWeekDate();