作者:火影魂XJ_710 | 来源:互联网 | 2014-11-14 09:58
varareaTabContainer=$(#JD-stock.tabli);varprovinceContainer=$(#stock_province_item);varcityContainer=$(#stock_city_item);varcurrentProvinceId;varis
var areaTabCOntainer= $("#JD-stock .tab li");
var provinceCOntainer= $("#stock_province_item");
var cityCOntainer= $("#stock_city_item");
var currentProvinceId;
var isFirst = 0;
//当前地域信息
var currentAreaInfo;
$(function () {
GetCityByMemberId();
$("#store-selector").unbind("mouseover").bind("mouseover", function () {
$('#store-selector').addClass('hover');
$("#store-selector .content").show();
});
$("#store-selector").unbind("mouseout").bind("mouseout", function () {
$('#store-selector').removeClass('hover')
});
areaTabContainer.eq(0).find("a").click(function () {
GetProvince();
areaTabContainer.removeClass("curr");
areaTabContainer.eq(0).addClass("curr").show();
provinceContainer.show();
cityContainer.hide();
});
areaTabContainer.eq(1).find("a").click(function () {
areaTabContainer.removeClass("curr");
areaTabContainer.eq(1).addClass("curr").show();
provinceContainer.hide();
cityContainer.show();
});
});
function GetCityByMemberId() {
var temp = Math.random();
//$.post("/Member/GetCityByMemberId?temp=" + temp, function (data) {
// //$("#loginName").text(data.UserName);
// var address = data.CityName;
// $("#store-selector .text div").html(address).attr("title", address);
// areaTabContainer.eq(0).find("em").html(data.ProvinceName);
// areaTabContainer.eq(1).find("em").html(data.CityName);
// $("#currentCityId").val(data.CityId);
// $("#currentProvinceId").val(data.ProvinceId);
// currentProvinceId = data.ProvinceId;
GetCityByProvinceId($("#currentProvinceId").val(), areaTabContainer.eq(0).find("em").html());
//});
}
function GetProvince() {
var temp = Math.random();
$.post("/Member/GetProvince?temp=" + temp, function (data) {
var html = ["
");
provinceContainer.html(html.join(""));
provinceContainer.find("a").click(function () {
$("#store-selector").unbind("mouseout");
chooseProvince($(this).attr("data-value"), $(this).html());
});
});
}
function GetCityByProvinceId(provinceId, provinceName) {
var temp = Math.random();
$.post("/Member/GetCity", "provinceId=" + provinceId + "&temp=" + temp, function (data) {
var html = ["
");
cityContainer.html(html.join(""));
cityContainer.find("a").click(function (e) {
$("#store-selector").unbind("mouseout");
chooseCity($(this).attr("data-value"), $(this).html(), provinceId, provinceName);
});
});
}
function chooseProvince(provinceId, provinceName) {
$("#currentProvinceId").val(provinceId);
provinceContainer.hide();
areaTabContainer.eq(0).removeClass("curr").find("em").html(provinceName);
areaTabContainer.eq(1).addClass("curr").show().find("em").html("请选择");
cityContainer.show();
cityContainer.html("");
GetCityByProvinceId(provinceId, provinceName);
}
function chooseCity(cityId, cityName, provinceId, provinceName) {
areaTabContainer.eq(1).find("em").html(cityName);
$("#store-selector .text div").html(cityName).attr("title", cityName);
$("#currentCityId").val(cityId);
$('#store-selector').removeClass('hover');
$.post("/Member/AddAddressSession", {
ProvinceId: provinceId,
ProvinceName: provinceName,
CityId: cityId,
CityName: cityName
}, function (data) {
window.location.href = window.location.href;
});
}
var address = @Html.GetAddress(account.Id);