var countryZone = 7; //时区计算时请记住是按照与UTC时间差算的,所以西区应为正值,东区为负值,例如中国为+8,而在这里应填-8 $(function () { if (window.chrome) { $('.banner li').css('background-size', '100% 100%'); } $('.banner').unslider({ arrows: true, keys: true, fluid: true, dots: true }); checkDateTime(countryZone); $("div.cart_box").mouseover(function () { $(this).removeClass("cart_box_hover").addClass("cart_box_hover"); $("div.cart_items").show(); $("div.cart_line").show(); $.get("/api/op_cart.aspx", { type: 'list', r: Math.random() }, function (data) { var ici = jQuery.parseJSON(data); if (ici.length > 0) { var tmp = ''; for (var i = 0; i < ici.length; i++) { tmp += '
'; tmp += ''; tmp += '' + ici[i].Title + ''; tmp += '
¥' + ici[i].Price + '元X' + ici[i].Quantity + '
删除
'; } $(".cart_item_list").html(tmp); } else { $(".cart_item_list").html("
暂无商品
"); } calCart(); }); }); $("div.cart_bg").mouseleave(function () { $("div.cart_box").removeClass("cart_box_hover"); $("div.cart_items").hide(); $("div.cart_line").hide(); }); $("#search_type li").click(function () { $("#type_name").text($(this).text()); $("#type_name").attr("typeid", $(this).attr("typeid")); switch (parseInt($("#type_name").attr("typeid"))) { case 0: $("#keywordstb").attr("placeholder", "输入商品关键字进行搜索"); break; case 1: $("#keywordstb").attr("placeholder", "输入标题关键字进行搜索"); break; case 2: $("#keywordstb").attr("placeholder", "输入运单号进行查询"); break; } }); $("#searchbtn").click(function () { if ($("#keywordstb").val() != '') { var tmp = encodeURIComponent($("#keywordstb").val()); switch (parseInt($("#type_name").attr("typeid"))) { case 0: location.href = "/search_product.aspx?keyword=" + tmp; break; case 1: location.href = "/search.aspx?keyword=" + tmp; break; case 2: location.href = "/check_delivery.aspx?no=" + tmp; break; } } else { $("#infoTxt").text("请输入关键字以进行搜索!"); $('#InfoDlg').modal('show'); return false; } }); $("#search_type2 li").click(function () { $("#type_name2").text($(this).text()); $("#type_name2").attr("typeid", $(this).attr("typeid")); switch (parseInt($("#type_name2").attr("typeid"))) { case 0: $("#keywordstb2").attr("placeholder", "输入商品关键字进行搜索"); break; case 1: $("#keywordstb2").attr("placeholder", "输入标题关键字进行搜索"); break; case 2: $("#keywordstb2").attr("placeholder", "输入运单号进行查询"); break; } }); $("#searchbtn2").click(function () { if ($("#keywordstb2").val() != '') { var tmp = encodeURIComponent($("#keywordstb2").val()); switch (parseInt($("#type_name2").attr("typeid"))) { case 0: location.href = "/search_product.aspx?keyword=" + tmp; break; case 1: location.href = "/search.aspx?keyword=" + tmp; break; case 2: location.href = "/check_delivery.aspx?no=" + tmp; break; } } else { $("#infoTxt").text("请输入关键字以进行搜索!"); $('#InfoDlg').modal('show'); return false; } }); $.get("/api/op_cart.aspx", { type: 'count', r: Math.random() }, function (data) { var tmp = data.split('|'); $(".cart_total").text(tmp[0]); $(".cart_price").text(tmp[1]); }); }); //删除购物车商品 function delItem(cartId) { $.get("/api/op_cart.aspx", { type: 'del', cartid: cartId, r: Math.random() }, function (data) { if (data == '1') { $("#item_" + cartId).remove(); calCart(); } }); } //统计购物车信息 function calCart() { var c = 0; var price = 0; if ($("dl.cart_item").length > 0) { $("dl.cart_item").each(function () { c += parseInt($(this).attr("qty")); price += parseFloat($(this).attr("price") * c); }); } else { $(".cart_item_list").html("
暂无商品
"); } $(".cart_total").text(c); $(".cart_price").text(price); } function checkLogin() { var username = $("#nametb").val(); var password = $("#pwdtb").val(); var isRember = $("#remembercb").prop("checked"); if (username == '') { $("#infoTxt").text("请输入用户名!"); $('#InfoDlg').modal('show'); return false; } if (password == '') { $("#infoTxt").text("请输入密码!"); $('#InfoDlg').modal('show'); return false; } $.get("../api/op_user.aspx", { op: 'login', name: username, pwd: password, remember: isRember, code: '', r: Math.random() }, function (data) { switch (parseInt(data)) { case -99: { $("#infoTxt").text("非法操作,未指定操作类型!"); $('#InfoDlg').modal('show'); return false; } break; case -5: { $("#infoTxt").text("请输入正确的验证码!"); $('#InfoDlg').modal('show'); return false; } break; case -2: { $("#infoTxt").text("用户名或密码不正确!"); $('#InfoDlg').modal('show'); return false; } break; case -3: { $("#infoTxt").text("您已进入找回密码流程,请通过邮件找回或联系管理员处理!"); $('#InfoDlg').modal('show'); return false; } break; case -1: { $("#infoTxt").text("登录失败!"); $('#InfoDlg').modal('show'); return false; } break; default: { $("#infoTxt").text("登录成功!"); $('#InfoDlg').modal('show'); location.reload(); } break; } }); return false; } var timerRunning = false; function checkDateTime(cz) { var addTime = 0; if (timerRunning) { clearTimeout(updatetime); timerRunning = false; } for (var i = 1; i <=