//选项卡
function LoginSelect(n) {
var tli = document.getElementById("Login_menu").getElementsByTagName("li");
var mli = document.getElementById("Login_main").getElementsByTagName("ul");
//alert(tli.innerHTML)
for (i = 0; i < tli.length; i++) {
tli[i].className = i == n ? "hover" : "";
mli[i].style.display = i == n ? "block" : "none";
}
}
function LoginClose() {
document.getElementById("LoginBox").style.display = "none";
}
function LoginShow(ishow) {
document.getElementById("LoginBox").style.display = "block";
if (ishow == "1") {
LoginSelect(1);
}
}
function getByCart() {
getAjax("/Mall/Order/GetByCart.ashx", "", function (rs) {
if (rs != "") {
$("#ByCartA").html("购物车(" + rs + ")");
} else {
$("#ByCartA").html("购物车");
}
});
}
getAjax("/Mall/Mall_HeadLoginStatus.ashx", "id=2", function (rs) {
if (rs != "end") {
$("#login").html("您好 : " + rs + " , 购物车 | 学习卡 | 退出");
getByCart(); //查询购物车
}
});
function MinCheckUserDataValid() {
if (!H_LoginBtn()) {
return false;
}
else {
var userName = $("#H_txtUserNames").val();
var userPwd = $("#H_txtUserPwds").val();
var txtCode = $("#H_txtCodes").val();
var parm = 'action=login&user_Account=' + escape(userName) + '&userPwd=' + escape(userPwd) + '&code=' + escape(txtCode);
$.get('/Frame/Frame.ashx', parm, function (rs) {
if (parseInt(rs) == 1) {
$("#H_txtCodes").focus();
$("#H_errorMsg1").html("验证码输入不正确");
ToggleCode("Verify_codeImag", '/Ajax/Verify_code.ashx');
return false;
} else if (parseInt(rs) == 2) {
$("#H_txtUserNames").focus();
$("#H_errorMsg1").html("账户被锁,联系管理员");
return false;
} else if (parseInt(rs) == 4) {
$("#H_txtUserNames").focus();
$("#H_errorMsg1").html("账户或密码有错误");
return false;
} else if (parseInt(rs) == 6) {
$("#H_errorMsg1").focus();
$("#H_errorMsg1").html("该用户已经登录");
return false;
} else if (parseInt(rs) == 3) {
setTimeout(Load, 1000);
} else {
CheckingLogin(0);
alert('服务器连接不上,联系管理员!');
window.location.href = window.location.href.replace('#', '');
return false;
}
});
}
}
function H_LoginBtn() {
var name = $("#H_txtUserNames").val();
var pwd = $("#H_txtUserPwds").val();
var code = $("#H_txtCodes").val();
$("#H_errorMsg1").html("");
if (name == "") {
$("#H_txtUserNames").focus();
$("#H_errorMsg1").html("账户不能为空");
return false;
} else if (pwd == "") {
$("#H_txtUserPwds").focus();
$("#H_errorMsg1").html("密码不能为空");
return false;
} else if (code == "") {
$("#H_txtCodes").focus();
$("#H_errorMsg1").html("验证码不能为空");
return false;
} else {
return true;
}
}
function Load() {
var url = document.referrer; //课程的地址
if (url != "") {
window.location.href = url;
}
else {
window.location.href = '/Member/MemberCenter.aspx';
}
return false;
}
function animatenTop(thisTop, thisLeft) {
var CopyDiv = '';
var topLength = 200; //取得到购物车的宽度
var leftLength = $('#ByCartA').offset().left; //取得到购物车的宽度
$("body").append(CopyDiv);
$("body").children("#box").animate({ width: "30px", height: "30px", "top": topLength, "left": leftLength, "opacity": .1 }, 1200, function () { $(this).remove(); getByCart(); });
}
//添加购物车
function addByCart(shopname, shopid, property, price, type, buy) {
var parm = "shopname=" + shopname + "&shopid=" + shopid + "&property=" + property + "&price=" + price + "&type=" + type + "&buy=" + buy;
getAjax("/Mall/Order/AddShoppingCart.ashx", parm, function (rs) {
if (rs == "1") {
var thisTop = $("#csinfo_buycart").offset().top; //所在位置的高度
var thisLeft = $("#csinfo_buycart").offset().left; //所在位置的宽度
animatenTop(thisTop, thisLeft);
}
else if (rs == "2") {
//alert("购物车false");
}
else if (rs == "3") {
//alert("login");
window.location.href = "/Frame/Login.aspx";
}
else if (rs == "0") {
alert("此物品已存在购物车");
}
else {
window.location.href = "/Mall/Order/Mall_Finance_Order.aspx?" + rs;
}
});
}
function LoginBtn() {
var name = $("#txtUserNames").val();
var pwd = $("#txtUserPwds").val();
var code = $("#txtCodes").val();
$("#errorMsg1").html("");
if (name == "") {
$("#txtUserNames").focus();
$("#errorMsg1").html("账户不能为空");
return false;
} else if (pwd == "") {
$("#txtUserPwds").focus();
$("#errorMsg1").html("密码不能为空");
return false;
} else if (code == "") {
$("#txtCodes").focus();
$("#errorMsg1").html("验证码不能为空");
return false;
} else {
return true;
}
}
function IsLogin(obj) {
var url = obj.href;
getAjax("/Mall/GetLogin.ashx", "", function (rs) {
if (rs == "1") {
window.location.open(url);
}
else {
LoginShow();
return false;
}
});
}
function getAjax(url, parm, callBack) {
$.ajax({
type: 'post',
dataType: "text",
url: url,
data: parm,
cache: false,
async: false,
success: function (msg) {
callBack(msg);
}
});
}