var countryZone = 8; //时区计算时请记住是按照与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 <= 2; i++) { var today = new Date(); var tz = today.getTimezoneOffset(); var zone = tz / 60; //如果是东区则返回负值,西区则返回正值 var month = today.getMonth() + 1; var date = today.getDate(); if (i == 2) { //计算某国时间 addTime = zone - cz; //if ((month > 3 || month == 3 && date > 24) && (month < 10 || month == 10 && date < 24)) //夏时制 // today = today.dateAdd("h", addTime); //else today = today.dateAdd("h", addTime); } else { //计算北京时间 if (zone != -8) { //如果当前电脑不在中国 addTime = zone + 8; today = today.dateAdd("h", addTime); } } var year = today.getYear() + 00; month = today.getMonth() + 1; date = today.getDate(); var day = today.getDay(); var hour = today.getHours(); var minute = today.getMinutes(); var second = today.getSeconds(); var dateTime = addZero(hour) + ":" + addZero(minute) + ":" + addZero(second) + "," + addZero(month) + "/" + addZero(date); if (i == 1) //北京时间 $("#bj_time").text(dateTime); //$("#bj_time").text(zone + "/" + addTime + "/" + dateTime); else//他国时间 $("#mg_time").text(dateTime); } updatetime = setTimeout("checkDateTime(" + countryZone + ")", 1000); timerRunning = true; } function addZero(num, end) { return num < 10 ? "0" + num : num; } /* 得到日期年月日等加数字后的日期 */ Date.prototype.dateAdd = function (interval, number) { var d = this; var k = { 'y': 'FullYear', 'q': 'Month', 'm': 'Month', 'w': 'Date', 'd': 'Date', 'h': 'Hours', 'n': 'Minutes', 's': 'Seconds', 'ms': 'MilliSeconds' }; var n = { 'q': 3, 'w': 7 }; eval('d.set' + k[interval] + '(d.get' + k[interval] + '()+' + ((n[interval] || 1) * number) + ')'); return d; }
Powered by MajExpress!