You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
412 lines
13 KiB
JavaScript
412 lines
13 KiB
JavaScript
// JavaScript Document
|
|
var Site_url = location.host;
|
|
//var Site_url = "202.103.68.193";
|
|
var Cart_DOM;
|
|
|
|
var temp_Shift;
|
|
var parentsDiv;
|
|
var Id; // .Cart_Id_jq
|
|
var Price; // .Cart_Price_jq
|
|
var Name; // .Cart_Name_jq
|
|
var City; // .Cart_City_jq
|
|
var Duration; // .Cart_Duration_jq
|
|
var NOP; // 总人数
|
|
var Adults; // .Cart_Adults_jq
|
|
var Children; // .Cart_Children_jq
|
|
var Infant; // .Cart_Infant_jq
|
|
var TourDate; // .Cart_TourDate_jq
|
|
var TourURL; // .Cart_TourURL_jq
|
|
var TourAttr; // .Cart_TourAttr_jq
|
|
|
|
$(document).ready(function(){
|
|
$('a[rel*=Cart_box]').facebox({opacity:0.5});
|
|
|
|
$(".daytripList.tourfilterList2 input[name=TripsDays]").datepicker({
|
|
showAnim: "fadeIn",
|
|
duration: 0,
|
|
minDate: 0,
|
|
maxDate: "2y",
|
|
numberOfMonths: 1,
|
|
showButtonPanel: true
|
|
});
|
|
get_cart_total();
|
|
get_cart_totalitems();
|
|
show_cartt_list();
|
|
get_cart_name();
|
|
});
|
|
|
|
function getnewcalendar(obj){
|
|
//alert($("#facebox .C_gp_s_box").attr("id")+"aaa11");
|
|
$(obj).datepicker({
|
|
showAnim: "fadeIn",
|
|
duration: 0,
|
|
minDate: 0,
|
|
maxDate: "2y",
|
|
numberOfMonths: 1,
|
|
showButtonPanel: true
|
|
});
|
|
}
|
|
|
|
function synchronization_cart(){
|
|
get_cart_total();
|
|
get_cart_totalitems();
|
|
show_cartt_list();
|
|
get_cart_name();
|
|
}
|
|
|
|
/**
|
|
* 给购物车所要的参数赋值
|
|
*
|
|
* return void
|
|
*/
|
|
function set_value(Obj, Parents){
|
|
//parentsDiv = $(Obj).parents(".daytripList.tourfilterList2");
|
|
parentsDiv = $(Obj).parents(Parents);
|
|
Id = $(".cid", parentsDiv).val();
|
|
Price = $(".g_p", parentsDiv).html();
|
|
if (Price == null) Price = "$0";
|
|
|
|
Name = $(".cname", parentsDiv).html();
|
|
|
|
City = cityurl
|
|
Duration = $(".tourdetailedInfo span", parentsDiv).html();
|
|
Adults = $("#Adults_Num", parentsDiv).val();
|
|
Children = $("#Child_Num", parentsDiv).val();
|
|
Infant = $("#Infants_Num", parentsDiv).val();
|
|
TourDate = $("#TripsDays", parentsDiv).val();
|
|
//TourURL = "http://www.hao123.com";
|
|
TourAttr = $(".tourdetailedInfo .TourAttr", parentsDiv).html();
|
|
|
|
//计算总价
|
|
Price = parseInt(Price.replace("$", "")) * ( parseInt(Adults) + parseInt(Children) + parseInt(Infant) );
|
|
|
|
if ($("#Adults_Num", parentsDiv).val() == "-"){
|
|
alert("Please select the adult number!");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function insert_cart(Obj, Parents){
|
|
if (set_value(Obj, Parents) == false )
|
|
return false;
|
|
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/single-city-tour/CartManager.asp?c=insert" +
|
|
"&Id=" + Id +
|
|
"&Qty=1" +
|
|
"&Price=" + Price +
|
|
"&CName=" + Name +
|
|
|
|
"&City=" + City +
|
|
"&Duration=" + Duration +
|
|
"&Adults_Num=" + Adults +
|
|
"&Child_Num=" + Children +
|
|
"&Infants_Num=" + Infant +
|
|
"&TripsDays=" + TourDate +
|
|
"&TourURL=" + TourURL +
|
|
"&TourAttr=" + TourAttr
|
|
,
|
|
dataType: "xml",
|
|
cache: false,
|
|
success: function(msg){
|
|
if ($(msg).find("Sign").text() == "True"){
|
|
alert("The product has been put into shopping cart.");
|
|
$(".list_jq").html("");
|
|
$(".totalPrice").show();
|
|
synchronization_cart();
|
|
}else{
|
|
alert("Hello. The product has been put into shopping cart.");
|
|
if(confirm("Make any changes? Click Yes to update it on shopping cart."))
|
|
{
|
|
update_cart(Obj);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function update_cart(Obj, Parents){
|
|
if (set_value(Obj, Parents) == false )
|
|
return false;
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/single-city-tour/CartManager.asp?c=update" +
|
|
"&Id=" + Id +
|
|
"&Qty=1" +
|
|
"&Price=" + Price +
|
|
"&CName=" + Name +
|
|
|
|
"&City=" + City +
|
|
"&Duration=" + Duration +
|
|
"&Adults_Num=" + Adults +
|
|
"&Child_Num=" + Children +
|
|
"&Infants_Num=" + Infant +
|
|
"&TripsDays=" + TourDate +
|
|
"&TourURL=" + TourURL +
|
|
"&TourAttr=" + TourAttr
|
|
,
|
|
dataType: "xml",
|
|
cache: false,
|
|
success: function(msg){
|
|
if ($(msg).find("Sign").text() == "True"){
|
|
alert("Your change has been updated!");
|
|
$(".list_jq").html("");
|
|
synchronization_cart();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function delect_cart(Obj){
|
|
if(confirm("Remove the product from shopping cart.")){
|
|
$.ajax({
|
|
type: "get",
|
|
url: "http://" + Site_url + "/single-city-tour/CartManager.asp?c=delect&Id=" + $(Obj).find("span").text(),
|
|
dataType: "xml",
|
|
cache: false,
|
|
success: function(msg){
|
|
if ($(msg).find("Sign").text() == "True"){
|
|
alert("The product has been removed from shopping cart. ");
|
|
$(".list_jq").html("");
|
|
synchronization_cart();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function edit_cart(Obj, Parents){
|
|
|
|
//alert($("#facebox .C_gp_s_box", parentsDiv).attr("id"));
|
|
//getnewcalendar($("#facebox .C_gp_s_box").attr("id"));
|
|
|
|
|
|
|
|
parentsDiv = $(Obj).parents("#facebox");
|
|
|
|
Id = $("input[name=Cart_Id_jq]", parentsDiv).val();
|
|
Name = $(".Cart_Name_jq", parentsDiv).html();
|
|
City = $(".Cart_City_jq", parentsDiv).html();
|
|
Duration = $(".Cart_Duration_jq", parentsDiv).html();
|
|
Adults = $(".Cart_Adults_jq", parentsDiv).val();
|
|
Children = $("select:eq(1)", parentsDiv).val();
|
|
Infant = $("select:eq(2)", parentsDiv).val();
|
|
TourDate = $("input:eq(0)", parentsDiv).val();
|
|
//Price = $(".Cart_PP_jq", parentsDiv).html();
|
|
CPP = $(".Cart_PP_jq", parentsDiv).html();
|
|
TourURL = document.location.href;
|
|
TourAttr = $(".Cart_TourAttr_jq", parentsDiv).html();
|
|
|
|
if (CPP == null) CPP = "0";
|
|
if (Price == null) Price = "$0";
|
|
Price = parseInt(CPP) * ( parseInt(Adults) + parseInt(Children) + parseInt(Infant) );
|
|
|
|
if ($("select:eq(0)", parentsDiv).val() == "-"){
|
|
alert("Please select the adult number!");
|
|
return false;
|
|
}
|
|
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/single-city-tour/CartManager.asp?c=update" +
|
|
"&Id=" + Id +
|
|
"&Qty=1" +
|
|
"&Price=" + Price +
|
|
"&CName=" + Name +
|
|
|
|
"&City=" + City +
|
|
"&Duration=" + Duration +
|
|
"&Adults_Num=" + Adults +
|
|
"&Child_Num=" + Children +
|
|
"&Infants_Num=" + Infant +
|
|
"&TripsDays=" + TourDate +
|
|
"&TourURL=" + TourURL +
|
|
"&TourAttr=" + TourAttr
|
|
,
|
|
dataType: "xml",
|
|
cache: false,
|
|
success: function(msg){
|
|
if ($(msg).find("Sign").text() == "True"){
|
|
alert("The product has been put into shopping cart.");
|
|
$(".list_jq").html("");
|
|
synchronization_cart();
|
|
$.facebox.close();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
/*function show_cartt_list(){
|
|
//var Cart_DOM = "";
|
|
$.ajax({
|
|
type: "get",
|
|
url: "http://" + Site_url + "/single-city-tour/CartManager.asp?c=contents" ,
|
|
dataType: "xml",
|
|
success: function(msg){
|
|
$(msg).find("CartItem").each(function(){
|
|
Cart_DOM = $(".shoppingList_hide").clone();
|
|
$(".C_Name", Cart_DOM).text($(this).find("Name").text());
|
|
$(".C_City", Cart_DOM).text($(this).find("City").text());
|
|
|
|
Adults = $(this).find("Adults").text();
|
|
Children = $(this).find("Children").text();
|
|
Infant = $(this).find("Infant").text()
|
|
cpp = parseInt($(this).find("Price").text()) / ( parseInt(Adults) + parseInt(Children) + parseInt(Infant) );
|
|
|
|
$(".C_Adults", Cart_DOM).text($(this).find("Adults").text());
|
|
$(".C_Children", Cart_DOM).text($(this).find("Children").text());
|
|
$(".C_Infant", Cart_DOM).text($(this).find("Infant").text());
|
|
$(".C_TourDate", Cart_DOM).text($(this).find("TourDate").text());
|
|
$(".C_Price", Cart_DOM).text($(this).find("Price").text());
|
|
$(".C_P_P", Cart_DOM).text(cpp);
|
|
$(".C_Id", Cart_DOM).text($(this).find("Id").text());
|
|
$(".C_Eidt", Cart_DOM).attr("href", "#" + "C_id" + $(this).find("Id").text());
|
|
|
|
var C_id = "C_id" + $(this).find("Id").text();
|
|
|
|
$(".C_gp_s_box", Cart_DOM).attr("id", C_id);
|
|
|
|
|
|
//facebox data
|
|
$( "#"+ C_id + " .Duration", Cart_DOM).text($(this).find("Duration").text());
|
|
$( "#"+ C_id + " .Attractions", Cart_DOM).text($(this).find("TourAttractions").text());
|
|
$( "#"+ C_id + " .g_p", Cart_DOM).text("$" + $(this).find("Price").text());
|
|
$( "#"+ C_id + " .f_TourName", Cart_DOM).text($(this).find("TourName").text());
|
|
|
|
$("select:eq(0)", Cart_DOM).append("<option value=\""+$(this).find("Adults").text()+"\" selected=\"selected\">"+$(this).find("Adults").text()+"</option>");
|
|
$("select:eq(1)", Cart_DOM).append("<option value=\""+$(this).find("Children").text()+"\" selected=\"selected\">"+$(this).find("Children").text()+"</option>");
|
|
$("select:eq(2)", Cart_DOM).append("<option value=\""+$(this).find("Infant").text()+"\" selected=\"selected\">"+$(this).find("Infant").text()+"</option>");
|
|
|
|
$(".tdTourDate", Cart_DOM).append("<input type=\"text\" class=\"roundCorner\" name=\"TripsDays\" id=\"TripsDays\" value=\"" + $(this).find("TourDate").text() + "\" onmousemove=\"javascript:getnewcalendar();\" />");
|
|
$(".tdTourDate", Cart_DOM).append("<input class=\"cid\" name=\"cid\" type=\"hidden\" value=\"" + $(this).find("Id").text() + "\" />");
|
|
$(".tdTourDate", Cart_DOM).append("<span class=\"C_cpp\" style=\"display: none;\">" + cpp + "</span>");
|
|
Cart_DOM.find('a[rel*=C_gpbox]').facebox();
|
|
Cart_DOM.appendTo(".Cart_container").show().addClass("shoppingList").removeClass("shoppingList_hide");
|
|
})
|
|
}
|
|
});
|
|
}*/
|
|
|
|
|
|
function get_cart_total(){
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/single-city-tour/CartManager.asp?c=total" ,
|
|
dataType: "xml",
|
|
cache: false,
|
|
success: function(msg){
|
|
$(".Cart_total_jq").text("$" + $(msg).find("Total").text());
|
|
}
|
|
});
|
|
}
|
|
function get_cart_totalitems(){
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/single-city-tour/CartManager.asp?c=totalitems" ,
|
|
dataType: "xml",
|
|
cache: false,
|
|
success: function(msg){
|
|
$(".Cart_totalitems_jq").html($(msg).find("Totalitems").text());
|
|
if ($(msg).find("Totalitems").text() != "0") $(".totalPrice").show();
|
|
}
|
|
});
|
|
}
|
|
|
|
function show_xml(){
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/single-city-tour/CartManager.asp?c=contents",
|
|
dataType: "html",
|
|
cache: false,
|
|
success: function(msg){
|
|
alert(msg);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
/*
|
|
* Shopping Cart
|
|
*/
|
|
|
|
|
|
|
|
function show_cartt_list(){
|
|
//var Cart_DOM = "";
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/single-city-tour/CartManager.asp?c=contents" ,
|
|
dataType: "xml",
|
|
cache: false,
|
|
success: function(msg){
|
|
$(msg).find("CartItem").each(function(){
|
|
var Id = $(this).find("Id").text(); // .Cart_Id_jq
|
|
var Price = parseInt($(this).find("Price").text()); // .Cart_Price_jq
|
|
var Name = $(this).find("Name").text(); // .Cart_Name_jq
|
|
var City = $(this).find("City").text(); // .Cart_City_jq
|
|
var Duration = $(this).find("Duration").text(); // .Cart_Duration_jq
|
|
var Adults = parseInt($(this).find("Adults").text()); // .Cart_Adults_jq
|
|
var Children = parseInt($(this).find("Children").text()); // .Cart_Children_jq
|
|
var Infant = parseInt($(this).find("Infant").text()); // .Cart_Infant_jq
|
|
var NOP = Adults + Children + Infant; // 总人数 .NOP
|
|
var PP = Price / NOP; // 平均价 .Cart_PP_jq
|
|
var TourDate = $(this).find("TourDate").text(); // .Cart_TourDate_jq
|
|
var TourURL = $(this).find("TourURL").text(); // .Cart_TourURL_jq
|
|
var TourAttr = $(this).find("TourAttractions").text(); // .Cart_TourAttr_jq
|
|
|
|
var Cart_List_template = $(".Cart_List_template_jq").clone();
|
|
//填充数据 Cart_List_template
|
|
$(".Cart_Name_jq", Cart_List_template).html(Name);
|
|
$(".Cart_City_jq", Cart_List_template).html(City);
|
|
$(".Cart_Duration_jq", Cart_List_template).html(" / " + Duration);
|
|
$(".Cart_Adults_jq", Cart_List_template).html("Adults: " + Adults);
|
|
if(Children != 0) $(".Cart_Children_jq", Cart_List_template).html("Children: " + Children );
|
|
if(Children != 0) $(".Cart_Infant_jq", Cart_List_template).html("Infant: " + Infant);
|
|
$(".Cart_TourDate_jq", Cart_List_template).html(TourDate);
|
|
$(".Cart_Price_jq", Cart_List_template).html(Price);
|
|
$(".Cart_PP_jq", Cart_List_template).html(PP);
|
|
$(".Cart_Delect_jq", Cart_List_template).html(Id);
|
|
//$("", Cart_List_template).html();
|
|
|
|
$(".Cart_Edit_jq", Cart_List_template).attr("href","#ID_" + Id);
|
|
$(".Cart_Edit_jq", Cart_List_template).attr("rel","Cart_box");
|
|
$(".edit div", Cart_List_template).attr("id","ID_" + Id);
|
|
|
|
|
|
//填充数据 Cart_Edit_template_jq
|
|
var Cart_Edit_template = $(".Cart_Edit_template_jq").clone();
|
|
$(".Cart_Name_jq", Cart_Edit_template).html(City + " " + Name);
|
|
$(".Cart_City_jq", Cart_Edit_template).html(City);
|
|
$(".Cart_Duration_jq", Cart_Edit_template).html(Duration);
|
|
$("select:eq(0)", Cart_Edit_template).append("<option value='" + Adults + "' selected=\"selected\">" + Adults +"</option>");
|
|
$("select:eq(1)", Cart_Edit_template).append("<option value='" + Children + "' selected=\"selected\">" + Children +"</option>");
|
|
$("select:eq(2)", Cart_Edit_template).append("<option value='" + Infant + "' selected=\"selected\">" + Infant +"</option>");
|
|
|
|
$(".Date_ID_jq", Cart_Edit_template).append("<input type=\"text\" class=\"roundCorner Cart_Id_jq\" name=\"Cart_TD_jq\" id=\"Cart_TD_jq\" value=\"" + TourDate + "\" onmousemove=\"javascript:getnewcalendar(this);\" />");
|
|
$(".Date_ID_jq", Cart_Edit_template).append("<input name=\"Cart_Id_jq\" type=\"hidden\" value=\""+ Id +"\" />");
|
|
|
|
$(".Cart_TourDate_jq", Cart_Edit_template).html(TourDate);
|
|
$(".Cart_Price_jq", Cart_Edit_template).html(Price);
|
|
$(".Cart_PP_jq", Cart_Edit_template).html(PP);
|
|
$(".Cart_Delect_jq", Cart_Edit_template).html(Id);
|
|
$(".Cart_TourAttr_jq", Cart_Edit_template).html(TourAttr);
|
|
|
|
|
|
$("#ID_" + Id, Cart_List_template).html(Cart_Edit_template.html());
|
|
|
|
|
|
|
|
$("a[rel*=Cart_box]",Cart_List_template).facebox();
|
|
|
|
Cart_List_template.removeClass().addClass("Cart_Item").prependTo(".list_jq").show();
|
|
Cart_Edit_template = null;
|
|
Cart_List_template = null;
|
|
})
|
|
}
|
|
});
|
|
}
|
|
|
|
function get_cart_name(){
|
|
$(".Cart_colina_jq").html(Cart_colina);
|
|
} |