function createXmlHttp() {
if (typeof XMLHttpRequest != "undefined") {
return new XMLHttpRequest();
}
else if (window.ActiveXObject) {
var aVersions = ["MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp"];
for (var i = 0; i < aVersions.lenght; i++) {
try {
var oXmlHttp = new ActiveXObject(aVersions[i]);
return oXmlHttp;
}
catch (oError) {
}
}
}
throw new Error("XMLHttp object could be created.");
}
//ContentPlaceHolder1_drpCity ContentPlaceHolder1_drpCounty
function Getxml(m) {
var thisId = "";
if (m == 1) {
thisId = "#ContentPlaceHolder1_drpCity";
}
else if (m == 0) {
thisId = "#ContentPlaceHolder1_drpProvince";
}
var parentId = $(thisId).val();
var oXmlHppt = createXmlHttp();
var url = "JSonProvinceData.aspx?parentId=" + parentId;
oXmlHppt.open("get", url, true);
oXmlHppt.onreadystatechange = function () {
if (oXmlHppt.readyState == 4) // xmlhttp.readyState == 4 响应已完成;您可以获取并使用服务器的响应了
{
if (oXmlHppt.status == 200) //XMLHttpRequest对象的status属性一般用来返回服务器的HTTP状态码。status为200表示“成功”
{
//alert(oXmlHppt.responseText);
GetJsonData(oXmlHppt.responseText, m); //oXmlHppt.responseXML拿到xml文档
}
}
}
oXmlHppt.send(null);
}
$(document).ready(function () {
$('#ContentPlaceHolder1_drpProvince').change(function () {
$('#ContentPlaceHolder1_drpCity').empty();
$('#ContentPlaceHolder1_drpCity').append("<option value='-1'>请选择城市</option>");
$('#ContentPlaceHolder1_drpCounty').empty();
$('#ContentPlaceHolder1_drpCounty').append("<option value='-1'>请选择区县</option>");
Getxml(0);
});
});
$(document).ready(function () {
$('#ContentPlaceHolder1_drpCity').change(function () {
Getxml(1);
});
});
function GetJsonData(data, m) {
var sJSon = eval("(" + data + ")");
if (m == 0) {
$('#ContentPlaceHolder1_drpCity').empty();
//<option value="-1">请选择城市</option><option value="313">白银市</option>
$('#ContentPlaceHolder1_drpCity').append("<option value='-1'>请选择城市</option>")
for (var i = 0; i < sJSon.length; i++) {
$('#ContentPlaceHolder1_drpCity').append("<option value='" + sJSon[i].Codeid + "'>" + sJSon[i].CityName + "</option>");
}
}
else if (m == 1) {
$('#ContentPlaceHolder1_drpCounty').empty();
$('#ContentPlaceHolder1_drpCounty').append("<option value='-1'>请选择区县</option>");
for (var i = 0; i < sJSon.length; i++) {
$('#ContentPlaceHolder1_drpCounty').append("<option value='" + sJSon[i].Codeid + "'>" + sJSon[i].CityName + "</option>");
}
}
}
//收货地址
function GetconsigneeInfo() {
var oXmlHppt1 = createXmlHttp();
var url = "JsonconsigneeInfo.aspx?cj=" + Math.random();
oXmlHppt1.open("get", url, false);
oXmlHppt1.onreadystatechange = function () {
if (oXmlHppt1.readyState == 4) // xmlhttp.readyState == 4 响应已完成;您可以获取并使用服务器的响应了
{
if (oXmlHppt1.status == 200) //XMLHttpRequest对象的status属性一般用来返回服务器的HTTP状态码。status为200表示“成功”
{
//alert(oXmlHppt1.responseText);
GetJsonDataConsignee(oXmlHppt1.responseText); //oXmlHppt.responseXML拿到xml文档
}
}
}
oXmlHppt1.send(null);
}
function GetJsonDataConsignee(dataObj) {
var sJSon = eval("(" + dataObj + ")");
alert(sJSon.length);
$('.myaddrlist').empty();
for (var j = 0; j < sJSon.length; j++) {
if (sJSon[j].Isdefault == "1") {
$('.myaddrlist').append("<li class='curr' οnclick='selectedLi(this)' οnmοuseοver='selectedLiHover(this)' οnmοuseοut='selectedLiout(this)'> <p class='address-name'> <strong>" + sJSon[j].ConsigneeAddressName + "</strong> <span class='address-close' οnclick='deleteConsignee(this)'>删除</span> <a class='address-edit' οnclick='editConsignee(this)'>[修改]</a> <input type='hidden' value='" + sJSon[j].ConsigneeId + "'/> </p> <p class='listp'> <span class='user-name'>" + sJSon[j].ConsigneeName + "</span>收</p> <p class='listp' id='listpConsigneeProvinceAddress'>" + sJSon[j].ConsigneeProvinceAddress + "</p> <p class='listp' id='listpConsigneeAddress'>" + sJSon[j].ConsigneeAddress + "</p> <p class='listp' id='listpMoboPhone'>手机:<span>" + sJSon[j].MoboPhone + "</p></span><p class='listp' id='listpConsigneePostcode'> 邮政编码:<span>" + sJSon[j].ConsigneePostcode + "</span></p><s class='icon'></s> <input type='hidden' value='" + sJSon[j].Isdefault + "id='addSel'> </li>");
}
else {
$('.myaddrlist').append("<li class='' οnclick='selectedLi(this)' οnmοuseοver='selectedLiHover(this)' οnmοuseοut='selectedLiout(this)'> <p class='address-name'> <strong>" + sJSon[j].ConsigneeAddressName + "</strong> <span class='address-close' οnclick='deleteConsignee(this)'>删除</span> <a class='address-edit' οnclick='editConsignee(this)'>[修改]</a> <input type='hidden' value='" + sJSon[j].ConsigneeId + "'/> </p> <p class='listp'> <span class='user-name'>" + sJSon[j].ConsigneeName + "</span>收</p> <p class='listp' id='listpConsigneeProvinceAddress'>" + sJSon[j].ConsigneeProvinceAddress + "</p> <p class='listp' id='listpConsigneeAddress'>" + sJSon[j].ConsigneeAddress + "</p> <p class='listp' id='listpMoboPhone'>手机:<span>" + sJSon[j].MoboPhone + "</p></span><p class='listp' id='listpConsigneePostcode'> 邮政编码:<span>" + sJSon[j].ConsigneePostcode + "</span></p><s class='icon'></s> <input type='hidden' value='" + sJSon[j].Isdefault + "id='addSel'> </li>");
}
}
}
//选择配送方式
$(document).ready(function () {
GetSendWayMoney();
$('#ContentPlaceHolder1_drpSendWay').change(function () {
var sendWayId = $(this).find("option:selected").val();
var oXmlHppt = createXmlHttp();
var url = "JsonSendWay.aspx?sendWayId=" + sendWayId;
oXmlHppt.open("get", url, true);
oXmlHppt.onreadystatechange = function () {
if (oXmlHppt.readyState == 4) // xmlhttp.readyState == 4 响应已完成;您可以获取并使用服务器的响应了
{
if (oXmlHppt.status == 200) //XMLHttpRequest对象的status属性一般用来返回服务器的HTTP状态码。status为200表示“成功”
{
GetJsonDataSendWay(oXmlHppt.responseText); //oXmlHppt.responseXML拿到xml文档
}
}
}
oXmlHppt.send(null);
});
});
function GetJsonDataSendWay(data) {
var sJSon = eval("(" + data + ")");
//var provinceAdress = $('#ContentPlaceHolder1_drpProvince option:selected').text();
$('#desc1').text(sJSon.SendDescribe);
};
//快递运费
function GetSendWayMoney()
{
var consigneeProvinceAddress = $('.myaddrlist .curr').find("#listpConsigneeProvinceAddress").text();
var dfetg = $('.myaddrlist li').attr("className");
var subtotalMoney = $('#ContentPlaceHolder1_subtotalMoney').text();
if ($.trim(consigneeProvinceAddress).split(" ")[0] == "上海") {
if (parseFloat(subtotalMoney) > 99.00) {
$('#shipFee1').text("0.00");
$('#sendWayMoney').text("0.00");
$('.priceC_red').text(subtotalMoney);
}
else {
$('#shipFee1').text("10.00");
$('#sendWayMoney').text("10.00");
$('.priceC_red').text((parseFloat(subtotalMoney) + 10.00));
}
}
else {
if (parseFloat(subtotalMoney) > 299.00) {
$('#shipFee1').text("0.00");
$('#sendWayMoney').text("0.00");
$('.priceC_red').text(subtotalMoney);
}
else {
$('#shipFee1').text("15.00");
$('#sendWayMoney').text("15.00");
$('.priceC_red').text((parseFloat(subtotalMoney) + 10.00));
}
}
}